changeset 2262:bee005ace1bf

Work in progress: merging new texture features into SDL blit system
author Sam Lantinga <slouken@libsdl.org>
date Fri, 17 Aug 2007 06:21:58 +0000
parents c20476d7d7b3
children 900c35d8e8fd
files src/video/SDL_RLEaccel.c src/video/SDL_blit.c src/video/SDL_blit.h src/video/SDL_blit_0.c src/video/SDL_blit_1.c src/video/SDL_blit_A.c src/video/SDL_blit_N.c src/video/SDL_blit_auto.c src/video/SDL_blit_auto.h src/video/SDL_blit_copy.c src/video/SDL_rendercopy.c src/video/SDL_rendercopy.h src/video/SDL_renderer_sw.c src/video/dummy/SDL_nullrender.c src/video/sdlgenblit.pl
diffstat 15 files changed, 5885 insertions(+), 6130 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/SDL_RLEaccel.c	Fri Aug 17 03:22:03 2007 +0000
+++ b/src/video/SDL_RLEaccel.c	Fri Aug 17 06:21:58 2007 +0000
@@ -906,7 +906,7 @@
     }
 
     alpha = (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA
-        ? (src->map->cmod >> 24) : 255;
+        ? src->map->info.a : 255;
     /* if left or right edge clipping needed, call clip blit */
     if (srcrect->x || srcrect->w != src->w) {
         RLEClipBlit(w, srcbuf, dst, dstbuf, srcrect, alpha);
@@ -1715,7 +1715,7 @@
     skip = run = 0;
     dst = rlebuf;
     rgbmask = ~surface->format->Amask;
-    ckey = surface->map->ckey & rgbmask;
+    ckey = surface->map->info.colorkey & rgbmask;
     lastline = dst;
     getpix = getpixes[bpp - 1];
     w = surface->w;
@@ -1948,7 +1948,7 @@
                 }
 
                 /* fill it with the background colour */
-                SDL_FillRect(surface, NULL, surface->map->ckey);
+                SDL_FillRect(surface, NULL, surface->map->info.colorkey);
 
                 /* now render the encoded surface */
                 full.x = full.y = 0;
--- a/src/video/SDL_blit.c	Fri Aug 17 03:22:03 2007 +0000
+++ b/src/video/SDL_blit.c	Fri Aug 17 06:21:58 2007 +0000
@@ -61,31 +61,23 @@
 
     /* Set up source and destination buffer pointers, and BLIT! */
     if (okay && srcrect->w && srcrect->h) {
-        SDL_BlitInfo info;
-        SDL_loblit RunBlit;
+        SDL_BlitInfo *info = &src->map->info;
 
         /* Set up the blit information */
-        info.s_pixels = (Uint8 *) src->pixels +
+        info->src = (Uint8 *) src->pixels +
             (Uint16) srcrect->y * src->pitch +
-            (Uint16) srcrect->x * src->format->BytesPerPixel;
-        info.s_width = srcrect->w;
-        info.s_height = srcrect->h;
-        info.s_skip = src->pitch - info.s_width * src->format->BytesPerPixel;
-        info.d_pixels = (Uint8 *) dst->pixels +
+            (Uint16) srcrect->x * info->src_fmt->BytesPerPixel;
+        info.src_w = srcrect->w;
+        info.src_h = srcrect->h;
+        info.dst = (Uint8 *) dst->pixels +
             (Uint16) dstrect->y * dst->pitch +
-            (Uint16) dstrect->x * dst->format->BytesPerPixel;
-        info.d_width = dstrect->w;
-        info.d_height = dstrect->h;
-        info.d_skip = dst->pitch - info.d_width * dst->format->BytesPerPixel;
-        info.src = src->format;
-        info.table = src->map->table;
-        info.dst = dst->format;
-        info.ckey = src->map->ckey;
-        info.cmod = src->map->cmod;
-        RunBlit = (SDL_loblit) src->map->data;
+            (Uint16) dstrect->x * info->dst_fmt->BytesPerPixel;
+        info.dst_w = dstrect->w;
+        info.dst_h = dstrect->h;
+        RunBlit = (SDL_BlitFunc) src->map->data;
 
         /* Run the actual software blit */
-        RunBlit(&info);
+        RunBlit(info);
     }
 
     /* We need to unlock the surfaces if they're locked */
@@ -124,50 +116,67 @@
 }
 #endif /* __MACOSX__ */
 
-static SDL_loblit
-SDL_ChooseBlitFunc(SDL_BlitEntry * entries, int count)
+static SDL_BlitFunc
+SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitEntry * entries)
 {
     int i;
     static Uint32 features = 0xffffffff;
 
+    /* Get the available CPU features */
     if (features == 0xffffffff) {
-        const char *override = SDL_getenv("SDL_BLIT_FEATURES");
+        const char *override = SDL_getenv("SDL_BLIT_CPU_FEATURES");
 
-        features = SDL_BLIT_ANY;
+        features = SDL_CPU_ANY;
 
         /* Allow an override for testing .. */
         if (override) {
             SDL_sscanf(override, "%u", &features);
         } else {
             if (SDL_HasMMX()) {
-                features |= SDL_BLIT_MMX;
+                features |= SDL_CPU_MMX;
+            }
+            if (SDL_Has3DNow()) {
+                features |= SDL_CPU_3DNOW;
             }
             if (SDL_HasSSE()) {
-                features |= SDL_BLIT_SSE;
+                features |= SDL_CPU_SSE;
+            }
+            if (SDL_HasSSE2()) {
+                features |= SDL_CPU_SSE2;
             }
             if (SDL_HasAltiVec()) {
                 if (SDL_UseAltivecPrefetch()) {
-                    features |= SDL_BLIT_ALTIVEC_PREFETCH;
+                    features |= SDL_CPU_ALTIVEC_PREFETCH;
                 } else {
-                    features |= SDL_BLIT_ALTIVEC_NOPREFETCH;
+                    features |= SDL_CPU_ALTIVEC_NOPREFETCH;
                 }
             }
         }
     }
 
-    for (i = count; i > 0; --i) {
-        if (features & entries[i].features) {
-            return entries[i].blit;
+    for (i = 0; entries[i].blit; ++i) {
+        if (src_format != entries[i].src_format) {
+            continue;
+        }
+        if (dst_format != entries[i].dst_format) {
+            continue;
         }
+        if ((flags & entries[i].flags) != flags) {
+            continue;
+        }
+        if (!(features & entries[i].cpu)) {
+            continue;
+        }
+        return entries[i].func;
     }
-    return entries[0].blit;
+    return NULL;
 }
 
 /* Figure out which of many blit routines to set up on a surface */
 int
 SDL_CalculateBlit(SDL_Surface * surface)
 {
-    SDL_loblit blit = NULL;
+    SDL_BlitFunc blit = NULL;
     int blit_index;
 
     /* Clean everything out to start */
@@ -210,6 +219,10 @@
             }
         }
     }
+    if (blit == NULL) {
+        blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_GeneratedBlitFuncTable);
+    }
+
     /* Make sure we have a blit function */
     if (blit == NULL) {
         SDL_InvalidateMap(surface->map);
--- a/src/video/SDL_blit.h	Fri Aug 17 03:22:03 2007 +0000
+++ b/src/video/SDL_blit.h	Fri Aug 17 06:21:58 2007 +0000
@@ -33,67 +33,74 @@
 #ifdef __SSE__
 #include <xmmintrin.h>
 #endif
+#ifdef __SSE2__
+#include <emmintrin.h>
+#endif
 
 #include "SDL_cpuinfo.h"
 #include "SDL_endian.h"
 
-/* The structure passed to the low level blit functions */
-typedef struct
-{
-    Uint8 *s_pixels;
-    int s_width;
-    int s_height;
-    int s_skip;
-    Uint8 *d_pixels;
-    int d_width;
-    int d_height;
-    int d_skip;
-    SDL_PixelFormat *src;
+/* SDL blit copy flags */
+#define SDL_COPY_MODULATE_COLOR     0x0001
+#define SDL_COPY_MODULATE_ALPHA     0x0002
+#define SDL_COPY_MASK               0x0010
+#define SDL_COPY_BLEND              0x0020
+#define SDL_COPY_ADD                0x0040
+#define SDL_COPY_MOD                0x0080
+#define SDL_COPY_COLORKEY           0x0100
+#define SDL_COPY_NEAREST            0x0200
+
+/* SDL blit CPU flags */
+#define SDL_CPU_ANY                 0x0000
+#define SDL_CPU_MMX                 0x0001
+#define SDL_CPU_3DNOW               0x0002
+#define SDL_CPU_SSE                 0x0004
+#define SDL_CPU_SSE2                0x0008
+#define SDL_CPU_ALTIVEC_PREFETCH    0x0010
+#define SDL_CPU_ALTIVEC_NOPREFETCH  0x0020
+
+typedef struct {
+    Uint8 *src;
+    int src_w, src_h;
+    int src_pitch;
+    Uint8 *dst;
+    int dst_w, dst_h;
+    int dst_pitch;
+    SDL_PixelFormat *src_fmt;
+    SDL_PixelFormat *dst_fmt;
     Uint8 *table;
-    SDL_PixelFormat *dst;
-    Uint32 ckey, cmod;
+    int flags;
+    Uint32 colorkey;
+    Uint8 r, g, b, a;
 } SDL_BlitInfo;
 
-/* The type definition for the low level blit functions */
-typedef void (*SDL_loblit) (SDL_BlitInfo * info);
+typedef void (SDLCALL * SDL_BlitFunc)(SDL_BlitInfo *info);
+
+typedef struct {
+    Uint32 src_format;
+    Uint32 dst_format;
+    int flags;
+    int cpu;
+    SDL_BlitFunc func;
+} SDL_BlitFuncEntry;
 
 /* Blit mapping definition */
 typedef struct SDL_BlitMap
 {
     SDL_Surface *dst;
     int identity;
-    Uint8 *table;
     SDL_blit blit;
     void *data;
-    Uint32 ckey;                /* colorkey */
-    Uint32 cmod;                /* ARGB modulation */
+    SDL_BlitInfo info;
 
     /* the version count matches the destination; mismatch indicates
        an invalid mapping */
     unsigned int format_version;
 } SDL_BlitMap;
 
-#define SDL_BLIT_ANY                0x00000000
-#define SDL_BLIT_MMX                0x00000001
-#define SDL_BLIT_SSE                0x00000002
-#define SDL_BLIT_ALTIVEC_PREFETCH   0x00000004
-#define SDL_BLIT_ALTIVEC_NOPREFETCH 0x00000008
-
-typedef struct SDL_BlitEntry
-{
-    Uint32 features;
-    SDL_loblit blit;
-} SDL_BlitEntry;
-
 /* Functions found in SDL_blit.c */
 extern int SDL_CalculateBlit(SDL_Surface * surface);
 
-/* Functions found in SDL_blit_{0,1,N,A}.c */
-extern SDL_loblit SDL_CalculateBlit0(SDL_Surface * surface, int complex);
-extern SDL_loblit SDL_CalculateBlit1(SDL_Surface * surface, int complex);
-extern SDL_loblit SDL_CalculateBlitN(SDL_Surface * surface, int complex);
-extern SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface * surface, int complex);
-
 /*
  * Useful macros for blitting routines
  */
--- a/src/video/SDL_blit_0.c	Fri Aug 17 03:22:03 2007 +0000
+++ b/src/video/SDL_blit_0.c	Fri Aug 17 06:21:58 2007 +0000
@@ -35,12 +35,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = info->src;
     srcskip = info->s_skip;
-    dst = info->d_pixels;
-    dstskip = info->d_skip;
+    dst = info->dst;
+    dstskip = info->dst_pitch;
     map = info->table;
     srcskip += width - (width + 7) / 8;
 
@@ -90,12 +90,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = info->src;
     srcskip = info->s_skip;
-    dst = (Uint16 *) info->d_pixels;
-    dstskip = info->d_skip / 2;
+    dst = (Uint16 *) info->dst;
+    dstskip = info->dst_pitch / 2;
     map = (Uint16 *) info->table;
     srcskip += width - (width + 7) / 8;
 
@@ -125,12 +125,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = info->src;
     srcskip = info->s_skip;
-    dst = info->d_pixels;
-    dstskip = info->d_skip;
+    dst = info->dst;
+    dstskip = info->dst_pitch;
     map = info->table;
     srcskip += width - (width + 7) / 8;
 
@@ -164,12 +164,12 @@
     int c;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = info->src;
     srcskip = info->s_skip;
-    dst = (Uint32 *) info->d_pixels;
-    dstskip = info->d_skip / 4;
+    dst = (Uint32 *) info->dst;
+    dstskip = info->dst_pitch / 4;
     map = (Uint32 *) info->table;
     srcskip += width - (width + 7) / 8;
 
@@ -194,12 +194,12 @@
 static void
 BlitBto1Key(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
-    Uint8 *dst = info->d_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
+    Uint8 *dst = info->dst;
     int srcskip = info->s_skip;
-    int dstskip = info->d_skip;
+    int dstskip = info->dst_pitch;
     Uint32 ckey = info->ckey;
     Uint8 *palmap = info->table;
     int c;
@@ -247,12 +247,12 @@
 static void
 BlitBto2Key(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
-    Uint16 *dstp = (Uint16 *) info->d_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
+    Uint16 *dstp = (Uint16 *) info->dst;
     int srcskip = info->s_skip;
-    int dstskip = info->d_skip;
+    int dstskip = info->dst_pitch;
     Uint32 ckey = info->ckey;
     Uint8 *palmap = info->table;
     int c;
@@ -282,12 +282,12 @@
 static void
 BlitBto3Key(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
-    Uint8 *dst = info->d_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
+    Uint8 *dst = info->dst;
     int srcskip = info->s_skip;
-    int dstskip = info->d_skip;
+    int dstskip = info->dst_pitch;
     Uint32 ckey = info->ckey;
     Uint8 *palmap = info->table;
     int c;
@@ -316,12 +316,12 @@
 static void
 BlitBto4Key(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
+    Uint32 *dstp = (Uint32 *) info->dst;
     int srcskip = info->s_skip;
-    int dstskip = info->d_skip;
+    int dstskip = info->dst_pitch;
     Uint32 ckey = info->ckey;
     Uint8 *palmap = info->table;
     int c;
@@ -351,12 +351,12 @@
 static void
 BlitBtoNAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
-    Uint8 *dst = info->d_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
+    Uint8 *dst = info->dst;
     int srcskip = info->s_skip;
-    int dstskip = info->d_skip;
+    int dstskip = info->dst_pitch;
     const SDL_Color *srcpal = info->src->palette->colors;
     SDL_PixelFormat *dstfmt = info->dst;
     int dstbpp;
@@ -396,12 +396,12 @@
 static void
 BlitBtoNAlphaKey(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
-    Uint8 *dst = info->d_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
+    Uint8 *dst = info->dst;
     int srcskip = info->s_skip;
-    int dstskip = info->d_skip;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     const SDL_Color *srcpal = srcfmt->palette->colors;
--- a/src/video/SDL_blit_1.c	Fri Aug 17 03:22:03 2007 +0000
+++ b/src/video/SDL_blit_1.c	Fri Aug 17 06:21:58 2007 +0000
@@ -39,12 +39,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = info->src;
     srcskip = info->s_skip;
-    dst = info->d_pixels;
-    dstskip = info->d_skip;
+    dst = info->dst;
+    dstskip = info->dst_pitch;
     map = info->table;
 
     while (height--) {
@@ -90,12 +90,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = info->src;
     srcskip = info->s_skip;
-    dst = info->d_pixels;
-    dstskip = info->d_skip;
+    dst = info->dst;
+    dstskip = info->dst_pitch;
     map = (Uint16 *) info->table;
 
 #ifdef USE_DUFFS_LOOP
@@ -196,12 +196,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = info->src;
     srcskip = info->s_skip;
-    dst = info->d_pixels;
-    dstskip = info->d_skip;
+    dst = info->dst;
+    dstskip = info->dst_pitch;
     map = info->table;
 
     while (height--) {
@@ -244,12 +244,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = info->src;
     srcskip = info->s_skip;
-    dst = (Uint32 *) info->d_pixels;
-    dstskip = info->d_skip / 4;
+    dst = (Uint32 *) info->dst;
+    dstskip = info->dst_pitch / 4;
     map = (Uint32 *) info->table;
 
     while (height--) {
@@ -283,12 +283,12 @@
 static void
 Blit1to1Key(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     Uint8 *palmap = info->table;
     Uint32 ckey = info->ckey;
 
@@ -330,12 +330,12 @@
 static void
 Blit1to2Key(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint16 *dstp = (Uint16 *) info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint16 *dstp = (Uint16 *) info->dst;
+    int dstskip = info->dst_pitch;
     Uint16 *palmap = (Uint16 *) info->table;
     Uint32 ckey = info->ckey;
 
@@ -362,12 +362,12 @@
 static void
 Blit1to3Key(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     Uint8 *palmap = info->table;
     Uint32 ckey = info->ckey;
     int o;
@@ -395,12 +395,12 @@
 static void
 Blit1to4Key(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch;
     Uint32 *palmap = (Uint32 *) info->table;
     Uint32 ckey = info->ckey;
 
@@ -427,12 +427,12 @@
 static void
 Blit1toNAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *dstfmt = info->dst;
     const SDL_Color *srcpal = info->src->palette->colors;
     int dstbpp;
@@ -468,12 +468,12 @@
 static void
 Blit1toNAlphaKey(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     const SDL_Color *srcpal = info->src->palette->colors;
--- a/src/video/SDL_blit_A.c	Fri Aug 17 03:22:03 2007 +0000
+++ b/src/video/SDL_blit_A.c	Fri Aug 17 06:21:58 2007 +0000
@@ -30,12 +30,12 @@
 static void
 BlitNto1SurfaceAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     Uint8 *palmap = info->table;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
@@ -86,12 +86,12 @@
 static void
 BlitNto1PixelAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     Uint8 *palmap = info->table;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
@@ -142,12 +142,12 @@
 static void
 BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     Uint8 *palmap = info->table;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
@@ -203,12 +203,12 @@
 static void
 BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip >> 2;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch >> 2;
     Uint32 dalpha = info->dst->Amask;
 
     __m64 src1, src2, dst1, dst2, lmask, hmask, dsta;
@@ -267,12 +267,12 @@
         /* only call a128 version when R,G,B occupy lower bits */
         BlitRGBtoRGBSurfaceAlpha128MMX(info);
     } else {
-        int width = info->d_width;
-        int height = info->d_height;
-        Uint32 *srcp = (Uint32 *) info->s_pixels;
+        int width = info->dst_w;
+        int height = info->dst_h;
+        Uint32 *srcp = (Uint32 *) info->src;
         int srcskip = info->s_skip >> 2;
-        Uint32 *dstp = (Uint32 *) info->d_pixels;
-        int dstskip = info->d_skip >> 2;
+        Uint32 *dstp = (Uint32 *) info->dst;
+        int dstskip = info->dst_pitch >> 2;
         Uint32 dalpha = df->Amask;
         Uint32 amult;
 
@@ -356,12 +356,12 @@
 static void
 BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip >> 2;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch >> 2;
     SDL_PixelFormat *sf = info->src;
     Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask;
     Uint32 amask = sf->Amask;
@@ -542,11 +542,11 @@
 static void
 Blit32to565PixelAlphaAltivec(SDL_BlitInfo * info)
 {
-    int height = info->d_height;
-    Uint8 *src = (Uint8 *) info->s_pixels;
+    int height = info->dst_h;
+    Uint8 *src = (Uint8 *) info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = (Uint8 *) info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = (Uint8 *) info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
 
     vector unsigned char v0 = vec_splat_u8(0);
@@ -617,7 +617,7 @@
         vector unsigned char valigner;
         vector unsigned char vsrc;
         vector unsigned char voverflow;
-        int width = info->d_width;
+        int width = info->dst_w;
 
 #define ONE_PIXEL_BLEND(condition, widthvar) \
         while (condition) { \
@@ -718,11 +718,11 @@
 static void
 Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info)
 {
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip >> 2;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch >> 2;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     unsigned sA = (info->cmod >> 24);
@@ -766,7 +766,7 @@
     vrgbmask = vec_splat(vrgbmask, 0);
 
     while (height--) {
-        int width = info->d_width;
+        int width = info->dst_w;
 #define ONE_PIXEL_BLEND(condition, widthvar) \
         while (condition) { \
             Uint32 Pixel; \
@@ -844,12 +844,12 @@
 static void
 Blit32to32PixelAlphaAltivec(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip >> 2;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch >> 2;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     vector unsigned char mergePermute;
@@ -875,7 +875,7 @@
     vsdstPermute = calc_swizzle32(dstfmt, NULL);
 
     while (height--) {
-        width = info->d_width;
+        width = info->dst_w;
 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
             Uint32 Pixel; \
             unsigned sR, sG, sB, dR, dG, dB, sA, dA; \
@@ -942,12 +942,12 @@
 static void
 BlitRGBtoRGBPixelAlphaAltivec(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip >> 2;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch >> 2;
     vector unsigned char mergePermute;
     vector unsigned char valphaPermute;
     vector unsigned char valphamask;
@@ -965,7 +965,7 @@
 
     vpixelmask = vec_nor(valphamask, v0);
     while (height--) {
-        width = info->d_width;
+        width = info->dst_w;
 #define ONE_PIXEL_BLEND(condition, widthvar) \
         while ((condition)) { \
             Uint32 dalpha; \
@@ -1040,11 +1040,11 @@
 Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info)
 {
     /* XXX : 6 */
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip >> 2;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch >> 2;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     unsigned sA = (info->cmod >> 24);
@@ -1076,7 +1076,7 @@
     vbits = (vector unsigned char) vec_splat_s8(-1);
 
     while (height--) {
-        int width = info->d_width;
+        int width = info->dst_w;
 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
             Uint32 Pixel; \
             unsigned sR, sG, sB, dR, dG, dB; \
@@ -1137,11 +1137,11 @@
 BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo * info)
 {
     unsigned alpha = (info->cmod >> 24);
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip >> 2;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch >> 2;
     vector unsigned char mergePermute;
     vector unsigned char valpha;
     vector unsigned char valphamask;
@@ -1160,7 +1160,7 @@
     valpha = vec_splat(valpha, 0);
 
     while (height--) {
-        int width = info->d_width;
+        int width = info->dst_w;
 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
             Uint32 s = *srcp; \
             Uint32 d = *dstp; \
@@ -1224,12 +1224,12 @@
 static void
 BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip >> 2;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch >> 2;
 
     while (height--) {
 	    /* *INDENT-OFF* */
@@ -1253,12 +1253,12 @@
     if (alpha == 128) {
         BlitRGBtoRGBSurfaceAlpha128(info);
     } else {
-        int width = info->d_width;
-        int height = info->d_height;
-        Uint32 *srcp = (Uint32 *) info->s_pixels;
+        int width = info->dst_w;
+        int height = info->dst_h;
+        Uint32 *srcp = (Uint32 *) info->src;
         int srcskip = info->s_skip >> 2;
-        Uint32 *dstp = (Uint32 *) info->d_pixels;
-        int dstskip = info->d_skip >> 2;
+        Uint32 *dstp = (Uint32 *) info->dst;
+        int dstskip = info->dst_pitch >> 2;
         Uint32 s;
         Uint32 d;
         Uint32 s1;
@@ -1321,12 +1321,12 @@
 static void
 BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip >> 2;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch >> 2;
 
     while (height--) {
 	    /* *INDENT-OFF* */
@@ -1374,12 +1374,12 @@
 static void
 BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip >> 2;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch >> 2;
     SDL_PixelFormat *sf = info->src;
     Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask;
     Uint32 amask = sf->Amask;
@@ -1456,12 +1456,12 @@
 static void
 Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint16 *srcp = (Uint16 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint16 *srcp = (Uint16 *) info->src;
     int srcskip = info->s_skip >> 1;
-    Uint16 *dstp = (Uint16 *) info->d_pixels;
-    int dstskip = info->d_skip >> 1;
+    Uint16 *dstp = (Uint16 *) info->dst;
+    int dstskip = info->dst_pitch >> 1;
 
     while (height--) {
         if (((uintptr_t) srcp ^ (uintptr_t) dstp) & 2) {
@@ -1562,12 +1562,12 @@
     if (alpha == 128) {
         Blit16to16SurfaceAlpha128(info, 0xf7de);
     } else {
-        int width = info->d_width;
-        int height = info->d_height;
-        Uint16 *srcp = (Uint16 *) info->s_pixels;
+        int width = info->dst_w;
+        int height = info->dst_h;
+        Uint16 *srcp = (Uint16 *) info->src;
         int srcskip = info->s_skip >> 1;
-        Uint16 *dstp = (Uint16 *) info->d_pixels;
-        int dstskip = info->d_skip >> 1;
+        Uint16 *dstp = (Uint16 *) info->dst;
+        int dstskip = info->dst_pitch >> 1;
         Uint32 s, d;
 
         __m64 src1, dst1, src2, dst2, gmask, bmask, mm_res, mm_alpha;
@@ -1699,12 +1699,12 @@
     if (alpha == 128) {
         Blit16to16SurfaceAlpha128(info, 0xfbde);
     } else {
-        int width = info->d_width;
-        int height = info->d_height;
-        Uint16 *srcp = (Uint16 *) info->s_pixels;
+        int width = info->dst_w;
+        int height = info->dst_h;
+        Uint16 *srcp = (Uint16 *) info->src;
         int srcskip = info->s_skip >> 1;
-        Uint16 *dstp = (Uint16 *) info->d_pixels;
-        int dstskip = info->d_skip >> 1;
+        Uint16 *dstp = (Uint16 *) info->dst;
+        int dstskip = info->dst_pitch >> 1;
         Uint32 s, d;
 
         __m64 src1, dst1, src2, dst2, rmask, gmask, bmask, mm_res, mm_alpha;
@@ -1839,12 +1839,12 @@
     if (alpha == 128) {
         Blit16to16SurfaceAlpha128(info, 0xf7de);
     } else {
-        int width = info->d_width;
-        int height = info->d_height;
-        Uint16 *srcp = (Uint16 *) info->s_pixels;
+        int width = info->dst_w;
+        int height = info->dst_h;
+        Uint16 *srcp = (Uint16 *) info->src;
         int srcskip = info->s_skip >> 1;
-        Uint16 *dstp = (Uint16 *) info->d_pixels;
-        int dstskip = info->d_skip >> 1;
+        Uint16 *dstp = (Uint16 *) info->dst;
+        int dstskip = info->dst_pitch >> 1;
         alpha >>= 3;            /* downscale alpha to 5 bits */
 
         while (height--) {
@@ -1878,12 +1878,12 @@
     if (alpha == 128) {
         Blit16to16SurfaceAlpha128(info, 0xfbde);
     } else {
-        int width = info->d_width;
-        int height = info->d_height;
-        Uint16 *srcp = (Uint16 *) info->s_pixels;
+        int width = info->dst_w;
+        int height = info->dst_h;
+        Uint16 *srcp = (Uint16 *) info->src;
         int srcskip = info->s_skip >> 1;
-        Uint16 *dstp = (Uint16 *) info->d_pixels;
-        int dstskip = info->d_skip >> 1;
+        Uint16 *dstp = (Uint16 *) info->dst;
+        int dstskip = info->dst_pitch >> 1;
         alpha >>= 3;            /* downscale alpha to 5 bits */
 
         while (height--) {
@@ -1913,12 +1913,12 @@
 static void
 BlitARGBto565PixelAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint16 *dstp = (Uint16 *) info->d_pixels;
-    int dstskip = info->d_skip >> 1;
+    Uint16 *dstp = (Uint16 *) info->dst;
+    int dstskip = info->dst_pitch >> 1;
 
     while (height--) {
 	    /* *INDENT-OFF* */
@@ -1959,12 +1959,12 @@
 static void
 BlitARGBto555PixelAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip >> 2;
-    Uint16 *dstp = (Uint16 *) info->d_pixels;
-    int dstskip = info->d_skip >> 1;
+    Uint16 *dstp = (Uint16 *) info->dst;
+    int dstskip = info->dst_pitch >> 1;
 
     while (height--) {
 	    /* *INDENT-OFF* */
@@ -2006,12 +2006,12 @@
 static void
 BlitNtoNSurfaceAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     int srcbpp = srcfmt->BytesPerPixel;
@@ -2050,12 +2050,12 @@
 static void
 BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     Uint32 ckey = info->ckey;
@@ -2096,12 +2096,12 @@
 static void
 BlitNtoNPixelAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
 
--- a/src/video/SDL_blit_N.c	Fri Aug 17 03:22:03 2007 +0000
+++ b/src/video/SDL_blit_N.c	Fri Aug 17 06:21:58 2007 +0000
@@ -158,11 +158,11 @@
 static void
 Blit_RGB888_RGB565Altivec(SDL_BlitInfo * info)
 {
-    int height = info->d_height;
-    Uint8 *src = (Uint8 *) info->s_pixels;
+    int height = info->dst_h;
+    Uint8 *src = (Uint8 *) info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = (Uint8 *) info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = (Uint8 *) info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     vector unsigned char valpha = vec_splat_u8(0);
     vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL);
@@ -186,7 +186,7 @@
         vector unsigned char voverflow;
         vector unsigned char vsrc;
 
-        int width = info->d_width;
+        int width = info->dst_w;
         int extrawidth;
 
         /* do scalar until we can align... */
@@ -262,11 +262,11 @@
 static void
 Blit_RGB565_32Altivec(SDL_BlitInfo * info)
 {
-    int height = info->d_height;
-    Uint8 *src = (Uint8 *) info->s_pixels;
+    int height = info->dst_h;
+    Uint8 *src = (Uint8 *) info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = (Uint8 *) info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = (Uint8 *) info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     unsigned alpha;
@@ -336,7 +336,7 @@
         vector unsigned char voverflow;
         vector unsigned char vsrc;
 
-        int width = info->d_width;
+        int width = info->dst_w;
         int extrawidth;
 
         /* do scalar until we can align... */
@@ -410,11 +410,11 @@
 static void
 Blit_RGB555_32Altivec(SDL_BlitInfo * info)
 {
-    int height = info->d_height;
-    Uint8 *src = (Uint8 *) info->s_pixels;
+    int height = info->dst_h;
+    Uint8 *src = (Uint8 *) info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = (Uint8 *) info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = (Uint8 *) info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     unsigned alpha;
@@ -484,7 +484,7 @@
         vector unsigned char voverflow;
         vector unsigned char vsrc;
 
-        int width = info->d_width;
+        int width = info->dst_w;
         int extrawidth;
 
         /* do scalar until we can align... */
@@ -559,11 +559,11 @@
 static void
 Blit32to32KeyAltivec(SDL_BlitInfo * info)
 {
-    int height = info->d_height;
-    Uint32 *srcp = (Uint32 *) info->s_pixels;
+    int height = info->dst_h;
+    Uint32 *srcp = (Uint32 *) info->src;
     int srcskip = info->s_skip;
-    Uint32 *dstp = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint32 *dstp = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     int srcbpp = srcfmt->BytesPerPixel;
     SDL_PixelFormat *dstfmt = info->dst;
@@ -578,7 +578,7 @@
     vector unsigned int vckey;
     vector unsigned int vrgbmask;
     vpermute = calc_swizzle32(srcfmt, dstfmt);
-    if (info->d_width < 16) {
+    if (info->dst_w < 16) {
         if (copy_alpha) {
             BlitNtoNKeyCopyAlpha(info);
         } else {
@@ -631,7 +631,7 @@
                 widthvar--; \
             } \
         }
-        int width = info->d_width;
+        int width = info->dst_w;
         ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
         assert(width > 0);
         if (width > 0) {
@@ -677,11 +677,11 @@
 static void
 ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info)
 {
-    int height = info->d_height;
-    Uint32 *src = (Uint32 *) info->s_pixels;
+    int height = info->dst_h;
+    Uint32 *src = (Uint32 *) info->src;
     int srcskip = info->s_skip;
-    Uint32 *dst = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint32 *dst = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     vector unsigned int vzero = vec_splat_u32(0);
@@ -704,7 +704,7 @@
         Uint32 bits;
         Uint8 r, g, b, a;
 
-        int width = info->d_width;
+        int width = info->dst_w;
         int extrawidth;
 
         /* do scalar until we can align... */
@@ -756,11 +756,11 @@
     const int scalar_dst_lead = sizeof(Uint32) * 4;
     const int vector_dst_lead = sizeof(Uint32) * 16;
 
-    int height = info->d_height;
-    Uint32 *src = (Uint32 *) info->s_pixels;
+    int height = info->dst_h;
+    Uint32 *src = (Uint32 *) info->src;
     int srcskip = info->s_skip;
-    Uint32 *dst = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint32 *dst = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     vector unsigned int vzero = vec_splat_u32(0);
@@ -783,7 +783,7 @@
         Uint32 bits;
         Uint8 r, g, b, a;
 
-        int width = info->d_width;
+        int width = info->dst_w;
         int extrawidth;
 
         /* do scalar until we can align... */
@@ -898,12 +898,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = (Uint32 *) info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = (Uint32 *) info->src;
     srcskip = info->s_skip / 4;
-    dst = info->d_pixels;
-    dstskip = info->d_skip;
+    dst = info->dst;
+    dstskip = info->dst_pitch;
     map = info->table;
 
     if (map == NULL) {
@@ -1015,12 +1015,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = (Uint32 *) info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = (Uint32 *) info->src;
     srcskip = info->s_skip / 4;
-    dst = (Uint16 *) info->d_pixels;
-    dstskip = info->d_skip / 2;
+    dst = (Uint16 *) info->dst;
+    dstskip = info->dst_pitch / 2;
 
 #ifdef USE_DUFFS_LOOP
     while (height--) {
@@ -1139,12 +1139,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = (Uint32 *) info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = (Uint32 *) info->src;
     srcskip = info->s_skip / 4;
-    dst = (Uint16 *) info->d_pixels;
-    dstskip = info->d_skip / 2;
+    dst = (Uint16 *) info->dst;
+    dstskip = info->dst_pitch / 2;
 
 #ifdef USE_DUFFS_LOOP
     while (height--) {
@@ -1252,12 +1252,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = (Uint8 *) info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = (Uint8 *) info->src;
     srcskip = info->s_skip;
-    dst = (Uint32 *) info->d_pixels;
-    dstskip = info->d_skip / 4;
+    dst = (Uint32 *) info->dst;
+    dstskip = info->dst_pitch / 4;
 
 #ifdef USE_DUFFS_LOOP
     while (height--) {
@@ -1874,12 +1874,12 @@
     int srcskip, dstskip;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = (Uint32 *) info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = (Uint32 *) info->src;
     srcskip = info->s_skip / 4;
-    dst = info->d_pixels;
-    dstskip = info->d_skip;
+    dst = info->dst;
+    dstskip = info->dst_pitch;
     map = info->table;
 
 #ifdef USE_DUFFS_LOOP
@@ -1947,12 +1947,12 @@
     SDL_PixelFormat *srcfmt;
 
     /* Set up some basic variables */
-    width = info->d_width;
-    height = info->d_height;
-    src = info->s_pixels;
+    width = info->dst_w;
+    height = info->dst_h;
+    src = info->src;
     srcskip = info->s_skip;
-    dst = info->d_pixels;
-    dstskip = info->d_skip;
+    dst = info->dst;
+    dstskip = info->dst_pitch;
     map = info->table;
     srcfmt = info->src;
     srcbpp = srcfmt->BytesPerPixel;
@@ -2028,12 +2028,12 @@
 static void
 Blit4to4MaskAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint32 *src = (Uint32 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint32 *src = (Uint32 *) info->src;
     int srcskip = info->s_skip;
-    Uint32 *dst = (Uint32 *) info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint32 *dst = (Uint32 *) info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
 
@@ -2077,12 +2077,12 @@
 static void
 BlitNtoN(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     int srcbpp = srcfmt->BytesPerPixel;
     SDL_PixelFormat *dstfmt = info->dst;
@@ -2112,12 +2112,12 @@
 static void
 BlitNtoNCopyAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     int srcbpp = srcfmt->BytesPerPixel;
     SDL_PixelFormat *dstfmt = info->dst;
@@ -2142,12 +2142,12 @@
 static void
 BlitNto1Key(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     SDL_PixelFormat *srcfmt = info->src;
     const Uint8 *palmap = info->table;
     Uint32 ckey = info->ckey;
@@ -2208,12 +2208,12 @@
 static void
 Blit2to2Key(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint16 *srcp = (Uint16 *) info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint16 *srcp = (Uint16 *) info->src;
     int srcskip = info->s_skip;
-    Uint16 *dstp = (Uint16 *) info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint16 *dstp = (Uint16 *) info->dst;
+    int dstskip = info->dst_pitch;
     Uint32 ckey = info->ckey;
     Uint32 rgbmask = ~info->src->Amask;
 
@@ -2242,12 +2242,12 @@
 static void
 BlitNtoNKey(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     Uint32 ckey = info->ckey;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
@@ -2285,12 +2285,12 @@
 static void
 BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
 {
-    int width = info->d_width;
-    int height = info->d_height;
-    Uint8 *src = info->s_pixels;
+    int width = info->dst_w;
+    int height = info->dst_h;
+    Uint8 *src = info->src;
     int srcskip = info->s_skip;
-    Uint8 *dst = info->d_pixels;
-    int dstskip = info->d_skip;
+    Uint8 *dst = info->dst;
+    int dstskip = info->dst_pitch;
     Uint32 ckey = info->ckey;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_blit_auto.c	Fri Aug 17 06:21:58 2007 +0000
@@ -0,0 +1,5357 @@
+/* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2006 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* *INDENT-OFF* */
+
+#include "SDL_video.h"
+#include "SDL_blit.h"
+#include "SDL_blit_auto.h"
+
+static SDL_BlitFuncEntry _SDL_GeneratedBlitFuncTable[] = {
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale },
+    { 0, 0, 0, 0, NULL }
+};
+
+SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable = _SDL_GeneratedBlitFuncTable;
+
+void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            *dst = *src;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_RGB888_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 = 0xFF;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_RGB888_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 = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_RGB888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_RGB888_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 = 0xFF;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_RGB888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_BGR888_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 = 0xFF;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_BGR888_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 = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_BGR888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_BGR888_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 = 0xFF;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGB888_BGR888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_RGB888_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;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_RGB888_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;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_RGB888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_RGB888_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;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_RGB888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            *dst = *src;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_BGR888_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;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_BGR888_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;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_BGR888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_BGR888_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;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGR888_BGR888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_RGB888_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;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_RGB888_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;
+            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_RGB888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_RGB888_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;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_RGB888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_BGR888_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;
+            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_BGR888_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;
+            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_BGR888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_BGR888_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;
+            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ARGB8888_BGR888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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;
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_RGB888_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 >> 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 = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_RGB888_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 >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_RGB888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_RGB888_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 >> 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 = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_RGB888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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;
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_BGR888_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 >> 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; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_BGR888_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 >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_BGR888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_BGR888_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 >> 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; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_RGBA8888_BGR888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_RGB888_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;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_RGB888_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;
+            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_RGB888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_RGB888_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;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_RGB888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_BGR888_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;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_BGR888_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;
+            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_BGR888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            pixel = *src;
+            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_BGR888_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;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_ABGR8888_BGR888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            srcpixel = *src;
+            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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 = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_RGB888_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;
+            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 = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            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 = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_RGB888_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;
+            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_RGB888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_RGB888_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;
+            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 = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_RGB888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            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 = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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 = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_BGR888_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;
+            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; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            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; dstA = 0xFF;
+            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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_BGR888_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;
+            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_BGR888_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;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                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;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                R = (R * modulateR) / 255;
+                G = (G * modulateG) / 255;
+                B = (B * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                A = (A * modulateA) / 255;
+            }
+            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_BGR888_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;
+            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; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+void SDL_Blit_BGRA8888_BGR888_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, dstA;
+    int srcy, srcx;
+    int posy, posx;
+    int incy, incx;
+
+    srcy = 0;
+    posy = 0;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
+
+    while (info->dst_h--) {
+        Uint32 *src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        srcx = -1;
+        posx = 0x10000L;
+        while (posy >= 0x10000L) {
+            ++srcy;
+            posy -= 0x10000L;
+        }
+        while (n--) {
+            if (posx >= 0x10000L) {
+                while (posx >= 0x10000L) {
+                    ++srcx;
+                    posx -= 0x10000L;
+                }
+                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            }
+            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; dstA = 0xFF;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                srcR = (srcR * modulateR) / 255;
+                srcG = (srcG * modulateG) / 255;
+                srcB = (srcB * modulateB) / 255;
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                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_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
+                if (srcA) {
+                    dstR = srcR;
+                    dstG = srcG;
+                    dstB = srcB;
+                }
+                break;
+            case SDL_COPY_BLEND:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                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:
+                dstR = (srcR * dstR) / 255;
+                dstG = (srcG * dstG) / 255;
+                dstB = (srcB * dstB) / 255;
+                break;
+            }
+            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+/* *INDENT-ON* */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_blit_auto.h	Fri Aug 17 06:21:58 2007 +0000
@@ -0,0 +1,31 @@
+/* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2006 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* *INDENT-OFF* */
+
+extern SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable;
+
+/* *INDENT-ON* */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_blit_copy.c	Fri Aug 17 03:22:03 2007 +0000
+++ b/src/video/SDL_blit_copy.c	Fri Aug 17 06:21:58 2007 +0000
@@ -95,12 +95,12 @@
     int w, h;
     int srcskip, dstskip;
 
-    w = info->d_width * info->dst->BytesPerPixel;
-    h = info->d_height;
-    src = info->s_pixels;
-    dst = info->d_pixels;
+    w = info->dst_w * info->dst->BytesPerPixel;
+    h = info->dst_h;
+    src = info->src;
+    dst = info->dst;
     srcskip = w + info->s_skip;
-    dstskip = w + info->d_skip;
+    dstskip = w + info->dst_pitch;
 
 #ifdef __SSE__
     if (SDL_HasSSE() && !((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) {
@@ -139,10 +139,10 @@
     int w, h;
     int skip;
 
-    w = info->d_width * info->dst->BytesPerPixel;
-    h = info->d_height;
-    src = info->s_pixels;
-    dst = info->d_pixels;
+    w = info->dst_w * info->dst->BytesPerPixel;
+    h = info->dst_h;
+    src = info->src;
+    dst = info->dst;
     skip = w + info->s_skip;
     if ((dst < src) || (dst >= (src + h * skip))) {
         SDL_BlitCopy(info);
--- a/src/video/SDL_rendercopy.c	Fri Aug 17 03:22:03 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5469 +0,0 @@
-/* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2006 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* *INDENT-OFF* */
-
-#include "SDL_video.h"
-#include "SDL_rendercopy.h"
-
-static struct {
-    Uint32 src_format;
-    Uint32 dst_format;
-    int modMode;
-    int blendMode;
-    int scaleMode;
-    SDL_RenderCopyFunc func;
-} SDL_RenderCopyFuncTable[] = {
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_RGB888_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGB888_RGB888_Blend },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_RGB888_Blend_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_RGB888_RGB888_Modulate },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGB888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_RGB888_Modulate_Blend_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_BGR888_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGB888_BGR888_Blend },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_BGR888_Blend_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_RGB888_BGR888_Modulate },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGB888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_BGR888_Modulate_Blend_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_RGB888_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGR888_RGB888_Blend },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_RGB888_Blend_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_BGR888_RGB888_Modulate },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGR888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_RGB888_Modulate_Blend_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_BGR888_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGR888_BGR888_Blend },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_BGR888_Blend_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_BGR888_BGR888_Modulate },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGR888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_BGR888_Modulate_Blend_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_RGB888_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ARGB8888_RGB888_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_RGB888_Blend_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_ARGB8888_RGB888_Modulate },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_BGR888_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ARGB8888_BGR888_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_BGR888_Blend_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_ARGB8888_BGR888_Modulate },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_RGB888_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGBA8888_RGB888_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_RGB888_Blend_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_RGBA8888_RGB888_Modulate },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_BGR888_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGBA8888_BGR888_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_BGR888_Blend_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_RGBA8888_BGR888_Modulate },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_RGB888_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ABGR8888_RGB888_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_RGB888_Blend_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_ABGR8888_RGB888_Modulate },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_BGR888_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ABGR8888_BGR888_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_BGR888_Blend_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_ABGR8888_BGR888_Modulate },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_RGB888_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGRA8888_RGB888_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_RGB888_Blend_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_BGRA8888_RGB888_Modulate },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_BGR888_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGRA8888_BGR888_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_BGR888_Blend_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_BGRA8888_BGR888_Modulate },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend_Scale },
-};
-
-SDL_RenderCopyFunc SDL_GetRenderCopyFunc(Uint32 src_format, Uint32 dst_format, int modMode, int blendMode, int scaleMode)
-{
-    int i;
-
-    for (i = 0; i < SDL_arraysize(SDL_RenderCopyFuncTable); ++i) {
-        if (src_format != SDL_RenderCopyFuncTable[i].src_format) {
-            continue;
-        }
-        if (dst_format != SDL_RenderCopyFuncTable[i].dst_format) {
-            continue;
-        }
-        if ((modMode & SDL_RenderCopyFuncTable[i].modMode) != modMode) {
-            continue;
-        }
-        if ((blendMode & SDL_RenderCopyFuncTable[i].blendMode) != blendMode) {
-            continue;
-        }
-        if ((scaleMode & SDL_RenderCopyFuncTable[i].scaleMode) != scaleMode) {
-            continue;
-        }
-        return SDL_RenderCopyFuncTable[i].func;
-    }
-    return NULL;
-}
-
-int SDL_RenderCopy_RGB888_RGB888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            *dst = *src;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_RGB888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_RGB888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_BGR888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_BGR888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_BGR888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGB888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_RGB888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_RGB888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_RGB888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_BGR888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            *dst = *src;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_BGR888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_BGR888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGR888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_RGB888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_RGB888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_RGB888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_BGR888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_BGR888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_BGR888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
-            dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_RGB888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_RGB888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            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; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            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; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_RGB888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            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; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            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; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_BGR888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_BGR888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            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; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            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; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_BGR888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            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; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            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; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_RGB888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_RGB888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_RGB888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_BGR888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_BGR888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_BGR888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            srcpixel = *src;
-            srcA = (Uint8)(srcpixel >> 24); 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 = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_RGB888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_RGB888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            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 = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            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 = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_RGB888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            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 = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            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 = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_BGR888_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_BGR888_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            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; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            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; dstA = 0xFF;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_BGR888_Modulate(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            pixel = *src;
-            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 pixel;
-    Uint32 R, G, B, A;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            pixel = *src;
-            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                R = (R * modulateR) / 255;
-                G = (G * modulateG) / 255;
-                B = (B * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                A = (A * modulateA) / 255;
-            }
-            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
-            *dst = pixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-
-    while (data->dst_h--) {
-        Uint32 *src = (Uint32 *)data->src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        while (n--) {
-            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; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            ++src;
-            ++dst;
-        }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-int SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
-{
-    const int flags = data->flags;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
-    Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB, srcA;
-    Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
-    int srcy, srcx;
-    int posy, posx;
-    int incy, incx;
-
-    srcy = 0;
-    posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
-
-    while (data->dst_h--) {
-        Uint32 *src;
-        Uint32 *dst = (Uint32 *)data->dst;
-        int n = data->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
-        while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
-            }
-            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; dstA = 0xFF;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
-                srcR = (srcR * modulateR) / 255;
-                srcG = (srcG * modulateG) / 255;
-                srcB = (srcB * modulateB) / 255;
-            }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
-                srcA = (srcA * modulateA) / 255;
-            }
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_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_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
-            case SDL_RENDERCOPY_BLEND:
-                dstR = srcR + ((255 - srcA) * dstR) / 255;
-                dstG = srcG + ((255 - srcA) * dstG) / 255;
-                dstB = srcB + ((255 - srcA) * dstB) / 255;
-                break;
-            case SDL_RENDERCOPY_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_RENDERCOPY_MOD:
-                dstR = (srcR * dstR) / 255;
-                dstG = (srcG * dstG) / 255;
-                dstB = (srcB * dstB) / 255;
-                break;
-            }
-            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
-            *dst = dstpixel;
-            posx += incx;
-            ++dst;
-        }
-        posy += incy;
-        data->dst += data->dst_pitch;
-    }
-    return 0;
-}
-
-/* *INDENT-ON* */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_rendercopy.h	Fri Aug 17 03:22:03 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2006 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* *INDENT-OFF* */
-
-#define SDL_RENDERCOPY_MODULATE_COLOR   0x0001
-#define SDL_RENDERCOPY_MODULATE_ALPHA   0x0002
-#define SDL_RENDERCOPY_MASK             0x0010
-#define SDL_RENDERCOPY_BLEND            0x0020
-#define SDL_RENDERCOPY_ADD              0x0040
-#define SDL_RENDERCOPY_MOD              0x0080
-#define SDL_RENDERCOPY_NEAREST          0x0100
-
-typedef struct {
-    Uint8 *src;
-    int src_w, src_h;
-    int src_pitch;
-    Uint8 *dst;
-    int dst_w, dst_h;
-    int dst_pitch;
-    void *aux_data;
-    int flags;
-    Uint8 r, g, b, a;
-} SDL_RenderCopyData;
-
-typedef int (SDLCALL * SDL_RenderCopyFunc)(SDL_RenderCopyData *data);
-
-extern SDL_RenderCopyFunc SDLCALL SDL_GetRenderCopyFunc(Uint32 src_format, Uint32 dst_format, int modMode, int blendMode, int scaleMode);
-
-extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
-extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
-
-/* *INDENT-ON* */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_sw.c	Fri Aug 17 03:22:03 2007 +0000
+++ b/src/video/SDL_renderer_sw.c	Fri Aug 17 06:21:58 2007 +0000
@@ -667,7 +667,8 @@
             if (texture->scaleMode) {
                 copydata.flags |= SDL_RENDERCOPY_NEAREST;
             }
-            status = copyfunc(&copydata);
+            copyfunc(&copydata);
+            status = 0;
         } else {
             SDL_Rect real_srcrect = *srcrect;
             SDL_Rect real_dstrect;
--- a/src/video/dummy/SDL_nullrender.c	Fri Aug 17 03:22:03 2007 +0000
+++ b/src/video/dummy/SDL_nullrender.c	Fri Aug 17 06:21:58 2007 +0000
@@ -200,7 +200,8 @@
             if (texture->scaleMode) {
                 copydata.flags |= SDL_RENDERCOPY_NEAREST;
             }
-            return copyfunc(&copydata);
+            copyfunc(&copydata);
+            return 0;
         } else {
             SDL_Rect real_srcrect = *srcrect;
             SDL_Rect real_dstrect = *dstrect;
--- a/src/video/sdlgenblit.pl	Fri Aug 17 03:22:03 2007 +0000
+++ b/src/video/sdlgenblit.pl	Fri Aug 17 06:21:58 2007 +0000
@@ -123,30 +123,7 @@
 sub output_copydefs
 {
     print FILE <<__EOF__;
-#define SDL_RENDERCOPY_MODULATE_COLOR   0x0001
-#define SDL_RENDERCOPY_MODULATE_ALPHA   0x0002
-#define SDL_RENDERCOPY_MASK             0x0010
-#define SDL_RENDERCOPY_BLEND            0x0020
-#define SDL_RENDERCOPY_ADD              0x0040
-#define SDL_RENDERCOPY_MOD              0x0080
-#define SDL_RENDERCOPY_NEAREST          0x0100
-
-typedef struct {
-    void *src;
-    int src_w, src_h;
-    int src_pitch;
-    void *dst;
-    int dst_w, dst_h;
-    int dst_pitch;
-    void *aux_data;
-    int flags;
-    Uint8 r, g, b, a;
-} SDL_RenderCopyData;
-
-typedef int (*SDL_RenderCopyFunc)(SDL_RenderCopyData *data);
-
-extern SDL_RenderCopyFunc SDLCALL SDL_GetRenderCopyFunc(Uint32 src_format, Uint32 dst_format, int modMode, int blendMode, int scaleMode);
-
+extern SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable;
 __EOF__
 }
 
@@ -161,7 +138,7 @@
     my $args = shift;
     my $suffix = shift;
 
-    print FILE "$prefix SDL_RenderCopy_${src}_${dst}";
+    print FILE "$prefix SDL_Blit_${src}_${dst}";
     if ( $modulate ) {
         print FILE "_Modulate";
     }
@@ -172,7 +149,7 @@
         print FILE "_Scale";
     }
     if ( $args ) {
-        print FILE "(SDL_RenderCopyData *data)";
+        print FILE "(SDL_BlitInfo *info)";
     }
     print FILE "$suffix";
 }
@@ -225,7 +202,7 @@
 __EOF__
         return;
     }
-        
+
     if ( $blend ) {
         get_rgba("src", $src);
         get_rgba("dst", $dst);
@@ -237,19 +214,19 @@
 
     if ( $modulate ) {
         print FILE <<__EOF__;
-            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
+            if (flags & SDL_COPY_MODULATE_COLOR) {
                 ${s}R = (${s}R * modulateR) / 255;
                 ${s}G = (${s}G * modulateG) / 255;
                 ${s}B = (${s}B * modulateB) / 255;
             }
-            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
                 ${s}A = (${s}A * modulateA) / 255;
             }
 __EOF__
     }
     if ( $blend ) {
         print FILE <<__EOF__;
-            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
                 /* This goes away if we ever use premultiplied alpha */
                 if (${s}A < 255) {
                     ${s}R = (${s}R * ${s}A) / 255;
@@ -257,25 +234,25 @@
                     ${s}B = (${s}B * ${s}A) / 255;
                 }
             }
-            switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
-            case SDL_RENDERCOPY_MASK:
+            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+            case SDL_COPY_MASK:
                 if (${s}A) {
                     ${d}R = ${s}R;
                     ${d}G = ${s}G;
                     ${d}B = ${s}B;
                 }
                 break;
-            case SDL_RENDERCOPY_BLEND:
+            case SDL_COPY_BLEND:
                 ${d}R = ${s}R + ((255 - ${s}A) * ${d}R) / 255;
                 ${d}G = ${s}G + ((255 - ${s}A) * ${d}G) / 255;
                 ${d}B = ${s}B + ((255 - ${s}A) * ${d}B) / 255;
                 break;
-            case SDL_RENDERCOPY_ADD:
+            case SDL_COPY_ADD:
                 ${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;
                 break;
-            case SDL_RENDERCOPY_MOD:
+            case SDL_COPY_MOD:
                 ${d}R = (${s}R * ${d}R) / 255;
                 ${d}G = (${s}G * ${d}G) / 255;
                 ${d}B = (${s}B * ${d}B) / 255;
@@ -298,17 +275,17 @@
     my $blend = shift;
     my $scale = shift;
 
-    output_copyfuncname("int", $src, $dst, $modulate, $blend, $scale, 1, "\n");
+    output_copyfuncname("void", $src, $dst, $modulate, $blend, $scale, 1, "\n");
     print FILE <<__EOF__;
 {
-    const int flags = data->flags;
+    const int flags = info->flags;
 __EOF__
     if ( $modulate ) {
         print FILE <<__EOF__;
-    const Uint32 modulateR = data->r;
-    const Uint32 modulateG = data->g;
-    const Uint32 modulateB = data->b;
-    const Uint32 modulateA = data->a;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
 __EOF__
     }
     if ( $blend ) {
@@ -332,13 +309,13 @@
 
     srcy = 0;
     posy = 0;
-    incy = (data->src_h << 16) / data->dst_h;
-    incx = (data->src_w << 16) / data->dst_w;
+    incy = (info->src_h << 16) / info->dst_h;
+    incx = (info->src_w << 16) / info->dst_w;
 
-    while (data->dst_h--) {
+    while (info->dst_h--) {
         $format_type{$src} *src;
-        $format_type{$dst} *dst = ($format_type{$dst} *)data->dst;
-        int n = data->dst_w;
+        $format_type{$dst} *dst = ($format_type{$dst} *)info->dst;
+        int n = info->dst_w;
         srcx = -1;
         posx = 0x10000L;
         while (posy >= 0x10000L) {
@@ -351,7 +328,7 @@
                     ++srcx;
                     posx -= 0x10000L;
                 }
-                src = ($format_type{$src} *)(data->src + (srcy * data->src_pitch) + (srcx * $format_size{$src}));
+                src = ($format_type{$src} *)(info->src + (srcy * info->src_pitch) + (srcx * $format_size{$src}));
 __EOF__
         print FILE <<__EOF__;
             }
@@ -362,16 +339,16 @@
             ++dst;
         }
         posy += incy;
-        data->dst += data->dst_pitch;
+        info->dst += info->dst_pitch;
     }
 __EOF__
     } else {
         print FILE <<__EOF__;
 
-    while (data->dst_h--) {
-        $format_type{$src} *src = ($format_type{$src} *)data->src;
-        $format_type{$dst} *dst = ($format_type{$dst} *)data->dst;
-        int n = data->dst_w;
+    while (info->dst_h--) {
+        $format_type{$src} *src = ($format_type{$src} *)info->src;
+        $format_type{$dst} *dst = ($format_type{$dst} *)info->dst;
+        int n = info->dst_w;
         while (n--) {
 __EOF__
         output_copycore($src, $dst, $modulate, $blend);
@@ -379,13 +356,12 @@
             ++src;
             ++dst;
         }
-        data->src += data->src_pitch;
-        data->dst += data->dst_pitch;
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
     }
 __EOF__
     }
     print FILE <<__EOF__;
-    return 0;
 }
 
 __EOF__
@@ -393,24 +369,14 @@
 
 sub output_copyfunc_h
 {
-    my $src = shift;
-    my $dst = shift;
-    for (my $modulate = 0; $modulate <= 1; ++$modulate) {
-        for (my $blend = 0; $blend <= 1; ++$blend) {
-            for (my $scale = 0; $scale <= 1; ++$scale) {
-                if ( $modulate || $blend || $scale ) {
-                    output_copyfuncname("extern int SDLCALL", $src, $dst, $modulate, $blend, $scale, 1, ";\n");
-                }
-            }
-        }
-    }
 }
 
 sub output_copyinc
 {
     print FILE <<__EOF__;
 #include "SDL_video.h"
-#include "SDL_rendercopy.h"
+#include "SDL_blit.h"
+#include "SDL_blit_auto.h"
 
 __EOF__
 }
@@ -418,14 +384,7 @@
 sub output_copyfunctable
 {
     print FILE <<__EOF__;
-static struct {
-    Uint32 src_format;
-    Uint32 dst_format;
-    int modMode;
-    int blendMode;
-    int scaleMode;
-    SDL_RenderCopyFunc func;
-} SDL_RenderCopyFuncTable[] = {
+static SDL_BlitFuncEntry _SDL_GeneratedBlitFuncTable[] = {
 __EOF__
     for (my $i = 0; $i <= $#src_formats; ++$i) {
         my $src = $src_formats[$i];
@@ -436,21 +395,36 @@
                     for (my $scale = 0; $scale <= 1; ++$scale) {
                         if ( $modulate || $blend || $scale ) {
                             print FILE "    { SDL_PIXELFORMAT_$src, SDL_PIXELFORMAT_$dst, ";
+                            my $flags = "";
+                            my $flag = "";
                             if ( $modulate ) {
-                                print FILE "(SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), ";
-                            } else {
-                                print FILE "0, ";
+                                $flag = "SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA";
+                                if ( $flags eq "" ) {
+                                    $flags = $flag;
+                                } else {
+                                    $flags = "$flags | $flag";
+                                }
                             }
                             if ( $blend ) {
-                                print FILE "(SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), ";
-                            } else {
-                                print FILE "0, ";
+                                $flag = "SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD";
+                                if ( $flags eq "" ) {
+                                    $flags = $flag;
+                                } else {
+                                    $flags = "$flags | $flag";
+                                }
                             }
                             if ( $scale ) {
-                                print FILE "SDL_TEXTURESCALEMODE_FAST, ";
-                            } else {
-                                print FILE "0, ";
+                                $flag = "SDL_COPY_NEAREST";
+                                if ( $flags eq "" ) {
+                                    $flags = $flag;
+                                } else {
+                                    $flags = "$flags | $flag";
+                                }
                             }
+                            if ( $flags eq "" ) {
+                                $flags = "0";
+                            }
+                            print FILE "($flags), SDL_CPU_ANY,";
                             output_copyfuncname("", $src_formats[$i], $dst_formats[$j], $modulate, $blend, $scale, 0, " },\n");
                         }
                     }
@@ -459,32 +433,10 @@
         }
     }
     print FILE <<__EOF__;
+    { 0, 0, 0, 0, NULL }
 };
 
-SDL_RenderCopyFunc SDL_GetRenderCopyFunc(Uint32 src_format, Uint32 dst_format, int modMode, int blendMode, int scaleMode)
-{
-    int i;
-
-    for (i = 0; i < SDL_arraysize(SDL_RenderCopyFuncTable); ++i) {
-        if (src_format != SDL_RenderCopyFuncTable[i].src_format) {
-            continue;
-        }
-        if (dst_format != SDL_RenderCopyFuncTable[i].dst_format) {
-            continue;
-        }
-        if ((modMode & SDL_RenderCopyFuncTable[i].modMode) != modMode) {
-            continue;
-        }
-        if ((blendMode & SDL_RenderCopyFuncTable[i].blendMode) != blendMode) {
-            continue;
-        }
-        if ((scaleMode & SDL_RenderCopyFuncTable[i].scaleMode) != scaleMode) {
-            continue;
-        }
-        return SDL_RenderCopyFuncTable[i].func;
-    }
-    return NULL;
-}
+SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable = _SDL_GeneratedBlitFuncTable;
 
 __EOF__
 }
@@ -505,7 +457,7 @@
     }
 }
 
-open_file("SDL_rendercopy.h");
+open_file("SDL_blit_auto.h");
 output_copydefs();
 for (my $i = 0; $i <= $#src_formats; ++$i) {
     for (my $j = 0; $j <= $#dst_formats; ++$j) {
@@ -513,9 +465,9 @@
     }
 }
 print FILE "\n";
-close_file("SDL_rendercopy.h");
+close_file("SDL_blit_auto.h");
 
-open_file("SDL_rendercopy.c");
+open_file("SDL_blit_auto.c");
 output_copyinc();
 output_copyfunctable();
 for (my $i = 0; $i <= $#src_formats; ++$i) {
@@ -523,4 +475,4 @@
         output_copyfunc_c($src_formats[$i], $dst_formats[$j]);
     }
 }
-close_file("SDL_rendercopy.c");
+close_file("SDL_blit_auto.c");