More work in progress, still doesn't compile...
authorSam Lantinga <slouken@libsdl.org>
Fri, 17 Aug 2007 06:40:12 +0000
changeset 2263900c35d8e8fd
parent 2262 bee005ace1bf
child 2264 f7f80b822c1f
More work in progress, still doesn't compile...
src/video/SDL_blit.c
src/video/SDL_blit.h
src/video/SDL_blit_auto.c
src/video/SDL_blit_auto.h
src/video/sdlgenblit.pl
     1.1 --- a/src/video/SDL_blit.c	Fri Aug 17 06:21:58 2007 +0000
     1.2 +++ b/src/video/SDL_blit.c	Fri Aug 17 06:40:12 2007 +0000
     1.3 @@ -24,6 +24,7 @@
     1.4  #include "SDL_video.h"
     1.5  #include "SDL_sysvideo.h"
     1.6  #include "SDL_blit.h"
     1.7 +#include "SDL_blit_auto.h"
     1.8  #include "SDL_blit_copy.h"
     1.9  #include "SDL_RLEaccel_c.h"
    1.10  #include "SDL_pixels_c.h"
    1.11 @@ -61,19 +62,20 @@
    1.12  
    1.13      /* Set up source and destination buffer pointers, and BLIT! */
    1.14      if (okay && srcrect->w && srcrect->h) {
    1.15 +        SDL_BlitFunc RunBlit;
    1.16          SDL_BlitInfo *info = &src->map->info;
    1.17  
    1.18          /* Set up the blit information */
    1.19          info->src = (Uint8 *) src->pixels +
    1.20              (Uint16) srcrect->y * src->pitch +
    1.21              (Uint16) srcrect->x * info->src_fmt->BytesPerPixel;
    1.22 -        info.src_w = srcrect->w;
    1.23 -        info.src_h = srcrect->h;
    1.24 -        info.dst = (Uint8 *) dst->pixels +
    1.25 +        info->src_w = srcrect->w;
    1.26 +        info->src_h = srcrect->h;
    1.27 +        info->dst = (Uint8 *) dst->pixels +
    1.28              (Uint16) dstrect->y * dst->pitch +
    1.29              (Uint16) dstrect->x * info->dst_fmt->BytesPerPixel;
    1.30 -        info.dst_w = dstrect->w;
    1.31 -        info.dst_h = dstrect->h;
    1.32 +        info->dst_w = dstrect->w;
    1.33 +        info->dst_h = dstrect->h;
    1.34          RunBlit = (SDL_BlitFunc) src->map->data;
    1.35  
    1.36          /* Run the actual software blit */
    1.37 @@ -117,7 +119,7 @@
    1.38  #endif /* __MACOSX__ */
    1.39  
    1.40  static SDL_BlitFunc
    1.41 -SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitEntry * entries)
    1.42 +SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries)
    1.43  {
    1.44      int i;
    1.45      static Uint32 features = 0xffffffff;
    1.46 @@ -154,7 +156,7 @@
    1.47          }
    1.48      }
    1.49  
    1.50 -    for (i = 0; entries[i].blit; ++i) {
    1.51 +    for (i = 0; entries[i].func; ++i) {
    1.52          if (src_format != entries[i].src_format) {
    1.53              continue;
    1.54          }
    1.55 @@ -177,44 +179,43 @@
    1.56  SDL_CalculateBlit(SDL_Surface * surface)
    1.57  {
    1.58      SDL_BlitFunc blit = NULL;
    1.59 -    int blit_index;
    1.60 +    SDL_Surface *dst = surface->map->dst;
    1.61 +    Uint32 src_format;
    1.62 +    Uint32 dst_format;
    1.63  
    1.64      /* Clean everything out to start */
    1.65      if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
    1.66          SDL_UnRLESurface(surface, 1);
    1.67      }
    1.68      surface->map->blit = NULL;
    1.69 +    surface->map->info.src_fmt = surface->format;
    1.70 +    surface->map->info.src_pitch = surface->pitch;
    1.71 +    surface->map->info.dst_fmt = dst->format;
    1.72 +    surface->map->info.dst_pitch = dst->pitch;
    1.73  
    1.74 -    /* Get the blit function index, based on surface mode */
    1.75 -    /* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */
    1.76 -    blit_index = 0;
    1.77 -    blit_index |= (!!(surface->flags & SDL_SRCCOLORKEY)) << 0;
    1.78 -    if (surface->flags & SDL_SRCALPHA
    1.79 -        && ((surface->map->cmod >> 24) != SDL_ALPHA_OPAQUE
    1.80 -            || surface->format->Amask)) {
    1.81 -        blit_index |= 2;
    1.82 -    }
    1.83 +    src_format = SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask);
    1.84 +    dst_format = SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel, dst->format->Rmask, dst->format->Gmask, dst->format->Bmask, dst->format->Amask);
    1.85  
    1.86      /* Check for special "identity" case -- copy blit */
    1.87 -    if (surface->map->identity && blit_index == 0) {
    1.88 +    if (surface->map->identity && !surface->map->info.flags) {
    1.89          /* Handle overlapping blits on the same surface */
    1.90 -        if (surface == surface->map->dst) {
    1.91 +        if (surface == dst) {
    1.92              blit = SDL_BlitCopyOverlap;
    1.93          } else {
    1.94              blit = SDL_BlitCopy;
    1.95          }
    1.96      } else {
    1.97          if (surface->format->BitsPerPixel < 8) {
    1.98 -            blit = SDL_CalculateBlit0(surface, blit_index);
    1.99 +            blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTable0);
   1.100          } else {
   1.101              switch (surface->format->BytesPerPixel) {
   1.102              case 1:
   1.103 -                blit = SDL_CalculateBlit1(surface, blit_index);
   1.104 +                blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTable1);
   1.105                  break;
   1.106              case 2:
   1.107              case 3:
   1.108              case 4:
   1.109 -                blit = SDL_CalculateBlitN(surface, blit_index);
   1.110 +                blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTableN);
   1.111                  break;
   1.112              }
   1.113          }
     2.1 --- a/src/video/SDL_blit.h	Fri Aug 17 06:21:58 2007 +0000
     2.2 +++ b/src/video/SDL_blit.h	Fri Aug 17 06:40:12 2007 +0000
     2.3 @@ -101,6 +101,11 @@
     2.4  /* Functions found in SDL_blit.c */
     2.5  extern int SDL_CalculateBlit(SDL_Surface * surface);
     2.6  
     2.7 +/* Blit function tables in SDL_blit_*.c */
     2.8 +extern SDL_BlitFuncEntry SDL_BlitFuncTable0[];
     2.9 +extern SDL_BlitFuncEntry SDL_BlitFuncTable1[];
    2.10 +extern SDL_BlitFuncEntry SDL_BlitFuncTableN[];
    2.11 +
    2.12  /*
    2.13   * Useful macros for blitting routines
    2.14   */
     3.1 --- a/src/video/SDL_blit_auto.c	Fri Aug 17 06:21:58 2007 +0000
     3.2 +++ b/src/video/SDL_blit_auto.c	Fri Aug 17 06:40:12 2007 +0000
     3.3 @@ -28,7 +28,5241 @@
     3.4  #include "SDL_blit.h"
     3.5  #include "SDL_blit_auto.h"
     3.6  
     3.7 -static SDL_BlitFuncEntry _SDL_GeneratedBlitFuncTable[] = {
     3.8 +static void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info)
     3.9 +{
    3.10 +    const int flags = info->flags;
    3.11 +    int srcy, srcx;
    3.12 +    int posy, posx;
    3.13 +    int incy, incx;
    3.14 +
    3.15 +    srcy = 0;
    3.16 +    posy = 0;
    3.17 +    incy = (info->src_h << 16) / info->dst_h;
    3.18 +    incx = (info->src_w << 16) / info->dst_w;
    3.19 +
    3.20 +    while (info->dst_h--) {
    3.21 +        Uint32 *src;
    3.22 +        Uint32 *dst = (Uint32 *)info->dst;
    3.23 +        int n = info->dst_w;
    3.24 +        srcx = -1;
    3.25 +        posx = 0x10000L;
    3.26 +        while (posy >= 0x10000L) {
    3.27 +            ++srcy;
    3.28 +            posy -= 0x10000L;
    3.29 +        }
    3.30 +        while (n--) {
    3.31 +            if (posx >= 0x10000L) {
    3.32 +                while (posx >= 0x10000L) {
    3.33 +                    ++srcx;
    3.34 +                    posx -= 0x10000L;
    3.35 +                }
    3.36 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
    3.37 +            }
    3.38 +            *dst = *src;
    3.39 +            posx += incx;
    3.40 +            ++dst;
    3.41 +        }
    3.42 +        posy += incy;
    3.43 +        info->dst += info->dst_pitch;
    3.44 +    }
    3.45 +}
    3.46 +
    3.47 +static void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info)
    3.48 +{
    3.49 +    const int flags = info->flags;
    3.50 +    Uint32 srcpixel;
    3.51 +    Uint32 srcR, srcG, srcB, srcA;
    3.52 +    Uint32 dstpixel;
    3.53 +    Uint32 dstR, dstG, dstB, dstA;
    3.54 +
    3.55 +    while (info->dst_h--) {
    3.56 +        Uint32 *src = (Uint32 *)info->src;
    3.57 +        Uint32 *dst = (Uint32 *)info->dst;
    3.58 +        int n = info->dst_w;
    3.59 +        while (n--) {
    3.60 +            srcpixel = *src;
    3.61 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
    3.62 +            dstpixel = *dst;
    3.63 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
    3.64 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
    3.65 +                /* This goes away if we ever use premultiplied alpha */
    3.66 +                if (srcA < 255) {
    3.67 +                    srcR = (srcR * srcA) / 255;
    3.68 +                    srcG = (srcG * srcA) / 255;
    3.69 +                    srcB = (srcB * srcA) / 255;
    3.70 +                }
    3.71 +            }
    3.72 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
    3.73 +            case SDL_COPY_MASK:
    3.74 +                if (srcA) {
    3.75 +                    dstR = srcR;
    3.76 +                    dstG = srcG;
    3.77 +                    dstB = srcB;
    3.78 +                }
    3.79 +                break;
    3.80 +            case SDL_COPY_BLEND:
    3.81 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
    3.82 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
    3.83 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
    3.84 +                break;
    3.85 +            case SDL_COPY_ADD:
    3.86 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
    3.87 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
    3.88 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
    3.89 +                break;
    3.90 +            case SDL_COPY_MOD:
    3.91 +                dstR = (srcR * dstR) / 255;
    3.92 +                dstG = (srcG * dstG) / 255;
    3.93 +                dstB = (srcB * dstB) / 255;
    3.94 +                break;
    3.95 +            }
    3.96 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
    3.97 +            *dst = dstpixel;
    3.98 +            ++src;
    3.99 +            ++dst;
   3.100 +        }
   3.101 +        info->src += info->src_pitch;
   3.102 +        info->dst += info->dst_pitch;
   3.103 +    }
   3.104 +}
   3.105 +
   3.106 +static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
   3.107 +{
   3.108 +    const int flags = info->flags;
   3.109 +    Uint32 srcpixel;
   3.110 +    Uint32 srcR, srcG, srcB, srcA;
   3.111 +    Uint32 dstpixel;
   3.112 +    Uint32 dstR, dstG, dstB, dstA;
   3.113 +    int srcy, srcx;
   3.114 +    int posy, posx;
   3.115 +    int incy, incx;
   3.116 +
   3.117 +    srcy = 0;
   3.118 +    posy = 0;
   3.119 +    incy = (info->src_h << 16) / info->dst_h;
   3.120 +    incx = (info->src_w << 16) / info->dst_w;
   3.121 +
   3.122 +    while (info->dst_h--) {
   3.123 +        Uint32 *src;
   3.124 +        Uint32 *dst = (Uint32 *)info->dst;
   3.125 +        int n = info->dst_w;
   3.126 +        srcx = -1;
   3.127 +        posx = 0x10000L;
   3.128 +        while (posy >= 0x10000L) {
   3.129 +            ++srcy;
   3.130 +            posy -= 0x10000L;
   3.131 +        }
   3.132 +        while (n--) {
   3.133 +            if (posx >= 0x10000L) {
   3.134 +                while (posx >= 0x10000L) {
   3.135 +                    ++srcx;
   3.136 +                    posx -= 0x10000L;
   3.137 +                }
   3.138 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   3.139 +            }
   3.140 +            srcpixel = *src;
   3.141 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
   3.142 +            dstpixel = *dst;
   3.143 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   3.144 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   3.145 +                /* This goes away if we ever use premultiplied alpha */
   3.146 +                if (srcA < 255) {
   3.147 +                    srcR = (srcR * srcA) / 255;
   3.148 +                    srcG = (srcG * srcA) / 255;
   3.149 +                    srcB = (srcB * srcA) / 255;
   3.150 +                }
   3.151 +            }
   3.152 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
   3.153 +            case SDL_COPY_MASK:
   3.154 +                if (srcA) {
   3.155 +                    dstR = srcR;
   3.156 +                    dstG = srcG;
   3.157 +                    dstB = srcB;
   3.158 +                }
   3.159 +                break;
   3.160 +            case SDL_COPY_BLEND:
   3.161 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
   3.162 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
   3.163 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
   3.164 +                break;
   3.165 +            case SDL_COPY_ADD:
   3.166 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
   3.167 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
   3.168 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
   3.169 +                break;
   3.170 +            case SDL_COPY_MOD:
   3.171 +                dstR = (srcR * dstR) / 255;
   3.172 +                dstG = (srcG * dstG) / 255;
   3.173 +                dstB = (srcB * dstB) / 255;
   3.174 +                break;
   3.175 +            }
   3.176 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   3.177 +            *dst = dstpixel;
   3.178 +            posx += incx;
   3.179 +            ++dst;
   3.180 +        }
   3.181 +        posy += incy;
   3.182 +        info->dst += info->dst_pitch;
   3.183 +    }
   3.184 +}
   3.185 +
   3.186 +static void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info)
   3.187 +{
   3.188 +    const int flags = info->flags;
   3.189 +    const Uint32 modulateR = info->r;
   3.190 +    const Uint32 modulateG = info->g;
   3.191 +    const Uint32 modulateB = info->b;
   3.192 +    const Uint32 modulateA = info->a;
   3.193 +    Uint32 pixel;
   3.194 +    Uint32 R, G, B, A;
   3.195 +
   3.196 +    while (info->dst_h--) {
   3.197 +        Uint32 *src = (Uint32 *)info->src;
   3.198 +        Uint32 *dst = (Uint32 *)info->dst;
   3.199 +        int n = info->dst_w;
   3.200 +        while (n--) {
   3.201 +            pixel = *src;
   3.202 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
   3.203 +            if (flags & SDL_COPY_MODULATE_COLOR) {
   3.204 +                R = (R * modulateR) / 255;
   3.205 +                G = (G * modulateG) / 255;
   3.206 +                B = (B * modulateB) / 255;
   3.207 +            }
   3.208 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
   3.209 +                A = (A * modulateA) / 255;
   3.210 +            }
   3.211 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   3.212 +            *dst = pixel;
   3.213 +            ++src;
   3.214 +            ++dst;
   3.215 +        }
   3.216 +        info->src += info->src_pitch;
   3.217 +        info->dst += info->dst_pitch;
   3.218 +    }
   3.219 +}
   3.220 +
   3.221 +static void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
   3.222 +{
   3.223 +    const int flags = info->flags;
   3.224 +    const Uint32 modulateR = info->r;
   3.225 +    const Uint32 modulateG = info->g;
   3.226 +    const Uint32 modulateB = info->b;
   3.227 +    const Uint32 modulateA = info->a;
   3.228 +    Uint32 pixel;
   3.229 +    Uint32 R, G, B, A;
   3.230 +    int srcy, srcx;
   3.231 +    int posy, posx;
   3.232 +    int incy, incx;
   3.233 +
   3.234 +    srcy = 0;
   3.235 +    posy = 0;
   3.236 +    incy = (info->src_h << 16) / info->dst_h;
   3.237 +    incx = (info->src_w << 16) / info->dst_w;
   3.238 +
   3.239 +    while (info->dst_h--) {
   3.240 +        Uint32 *src;
   3.241 +        Uint32 *dst = (Uint32 *)info->dst;
   3.242 +        int n = info->dst_w;
   3.243 +        srcx = -1;
   3.244 +        posx = 0x10000L;
   3.245 +        while (posy >= 0x10000L) {
   3.246 +            ++srcy;
   3.247 +            posy -= 0x10000L;
   3.248 +        }
   3.249 +        while (n--) {
   3.250 +            if (posx >= 0x10000L) {
   3.251 +                while (posx >= 0x10000L) {
   3.252 +                    ++srcx;
   3.253 +                    posx -= 0x10000L;
   3.254 +                }
   3.255 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   3.256 +            }
   3.257 +            pixel = *src;
   3.258 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
   3.259 +            if (flags & SDL_COPY_MODULATE_COLOR) {
   3.260 +                R = (R * modulateR) / 255;
   3.261 +                G = (G * modulateG) / 255;
   3.262 +                B = (B * modulateB) / 255;
   3.263 +            }
   3.264 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
   3.265 +                A = (A * modulateA) / 255;
   3.266 +            }
   3.267 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   3.268 +            *dst = pixel;
   3.269 +            posx += incx;
   3.270 +            ++dst;
   3.271 +        }
   3.272 +        posy += incy;
   3.273 +        info->dst += info->dst_pitch;
   3.274 +    }
   3.275 +}
   3.276 +
   3.277 +static void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
   3.278 +{
   3.279 +    const int flags = info->flags;
   3.280 +    const Uint32 modulateR = info->r;
   3.281 +    const Uint32 modulateG = info->g;
   3.282 +    const Uint32 modulateB = info->b;
   3.283 +    const Uint32 modulateA = info->a;
   3.284 +    Uint32 srcpixel;
   3.285 +    Uint32 srcR, srcG, srcB, srcA;
   3.286 +    Uint32 dstpixel;
   3.287 +    Uint32 dstR, dstG, dstB, dstA;
   3.288 +
   3.289 +    while (info->dst_h--) {
   3.290 +        Uint32 *src = (Uint32 *)info->src;
   3.291 +        Uint32 *dst = (Uint32 *)info->dst;
   3.292 +        int n = info->dst_w;
   3.293 +        while (n--) {
   3.294 +            srcpixel = *src;
   3.295 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
   3.296 +            dstpixel = *dst;
   3.297 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   3.298 +            if (flags & SDL_COPY_MODULATE_COLOR) {
   3.299 +                srcR = (srcR * modulateR) / 255;
   3.300 +                srcG = (srcG * modulateG) / 255;
   3.301 +                srcB = (srcB * modulateB) / 255;
   3.302 +            }
   3.303 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
   3.304 +                srcA = (srcA * modulateA) / 255;
   3.305 +            }
   3.306 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   3.307 +                /* This goes away if we ever use premultiplied alpha */
   3.308 +                if (srcA < 255) {
   3.309 +                    srcR = (srcR * srcA) / 255;
   3.310 +                    srcG = (srcG * srcA) / 255;
   3.311 +                    srcB = (srcB * srcA) / 255;
   3.312 +                }
   3.313 +            }
   3.314 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
   3.315 +            case SDL_COPY_MASK:
   3.316 +                if (srcA) {
   3.317 +                    dstR = srcR;
   3.318 +                    dstG = srcG;
   3.319 +                    dstB = srcB;
   3.320 +                }
   3.321 +                break;
   3.322 +            case SDL_COPY_BLEND:
   3.323 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
   3.324 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
   3.325 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
   3.326 +                break;
   3.327 +            case SDL_COPY_ADD:
   3.328 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
   3.329 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
   3.330 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
   3.331 +                break;
   3.332 +            case SDL_COPY_MOD:
   3.333 +                dstR = (srcR * dstR) / 255;
   3.334 +                dstG = (srcG * dstG) / 255;
   3.335 +                dstB = (srcB * dstB) / 255;
   3.336 +                break;
   3.337 +            }
   3.338 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   3.339 +            *dst = dstpixel;
   3.340 +            ++src;
   3.341 +            ++dst;
   3.342 +        }
   3.343 +        info->src += info->src_pitch;
   3.344 +        info->dst += info->dst_pitch;
   3.345 +    }
   3.346 +}
   3.347 +
   3.348 +static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   3.349 +{
   3.350 +    const int flags = info->flags;
   3.351 +    const Uint32 modulateR = info->r;
   3.352 +    const Uint32 modulateG = info->g;
   3.353 +    const Uint32 modulateB = info->b;
   3.354 +    const Uint32 modulateA = info->a;
   3.355 +    Uint32 srcpixel;
   3.356 +    Uint32 srcR, srcG, srcB, srcA;
   3.357 +    Uint32 dstpixel;
   3.358 +    Uint32 dstR, dstG, dstB, dstA;
   3.359 +    int srcy, srcx;
   3.360 +    int posy, posx;
   3.361 +    int incy, incx;
   3.362 +
   3.363 +    srcy = 0;
   3.364 +    posy = 0;
   3.365 +    incy = (info->src_h << 16) / info->dst_h;
   3.366 +    incx = (info->src_w << 16) / info->dst_w;
   3.367 +
   3.368 +    while (info->dst_h--) {
   3.369 +        Uint32 *src;
   3.370 +        Uint32 *dst = (Uint32 *)info->dst;
   3.371 +        int n = info->dst_w;
   3.372 +        srcx = -1;
   3.373 +        posx = 0x10000L;
   3.374 +        while (posy >= 0x10000L) {
   3.375 +            ++srcy;
   3.376 +            posy -= 0x10000L;
   3.377 +        }
   3.378 +        while (n--) {
   3.379 +            if (posx >= 0x10000L) {
   3.380 +                while (posx >= 0x10000L) {
   3.381 +                    ++srcx;
   3.382 +                    posx -= 0x10000L;
   3.383 +                }
   3.384 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   3.385 +            }
   3.386 +            srcpixel = *src;
   3.387 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
   3.388 +            dstpixel = *dst;
   3.389 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   3.390 +            if (flags & SDL_COPY_MODULATE_COLOR) {
   3.391 +                srcR = (srcR * modulateR) / 255;
   3.392 +                srcG = (srcG * modulateG) / 255;
   3.393 +                srcB = (srcB * modulateB) / 255;
   3.394 +            }
   3.395 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
   3.396 +                srcA = (srcA * modulateA) / 255;
   3.397 +            }
   3.398 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   3.399 +                /* This goes away if we ever use premultiplied alpha */
   3.400 +                if (srcA < 255) {
   3.401 +                    srcR = (srcR * srcA) / 255;
   3.402 +                    srcG = (srcG * srcA) / 255;
   3.403 +                    srcB = (srcB * srcA) / 255;
   3.404 +                }
   3.405 +            }
   3.406 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
   3.407 +            case SDL_COPY_MASK:
   3.408 +                if (srcA) {
   3.409 +                    dstR = srcR;
   3.410 +                    dstG = srcG;
   3.411 +                    dstB = srcB;
   3.412 +                }
   3.413 +                break;
   3.414 +            case SDL_COPY_BLEND:
   3.415 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
   3.416 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
   3.417 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
   3.418 +                break;
   3.419 +            case SDL_COPY_ADD:
   3.420 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
   3.421 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
   3.422 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
   3.423 +                break;
   3.424 +            case SDL_COPY_MOD:
   3.425 +                dstR = (srcR * dstR) / 255;
   3.426 +                dstG = (srcG * dstG) / 255;
   3.427 +                dstB = (srcB * dstB) / 255;
   3.428 +                break;
   3.429 +            }
   3.430 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   3.431 +            *dst = dstpixel;
   3.432 +            posx += incx;
   3.433 +            ++dst;
   3.434 +        }
   3.435 +        posy += incy;
   3.436 +        info->dst += info->dst_pitch;
   3.437 +    }
   3.438 +}
   3.439 +
   3.440 +static void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info)
   3.441 +{
   3.442 +    const int flags = info->flags;
   3.443 +    Uint32 pixel;
   3.444 +    Uint32 R, G, B, A;
   3.445 +    int srcy, srcx;
   3.446 +    int posy, posx;
   3.447 +    int incy, incx;
   3.448 +
   3.449 +    srcy = 0;
   3.450 +    posy = 0;
   3.451 +    incy = (info->src_h << 16) / info->dst_h;
   3.452 +    incx = (info->src_w << 16) / info->dst_w;
   3.453 +
   3.454 +    while (info->dst_h--) {
   3.455 +        Uint32 *src;
   3.456 +        Uint32 *dst = (Uint32 *)info->dst;
   3.457 +        int n = info->dst_w;
   3.458 +        srcx = -1;
   3.459 +        posx = 0x10000L;
   3.460 +        while (posy >= 0x10000L) {
   3.461 +            ++srcy;
   3.462 +            posy -= 0x10000L;
   3.463 +        }
   3.464 +        while (n--) {
   3.465 +            if (posx >= 0x10000L) {
   3.466 +                while (posx >= 0x10000L) {
   3.467 +                    ++srcx;
   3.468 +                    posx -= 0x10000L;
   3.469 +                }
   3.470 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   3.471 +            }
   3.472 +            pixel = *src;
   3.473 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
   3.474 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
   3.475 +            *dst = pixel;
   3.476 +            posx += incx;
   3.477 +            ++dst;
   3.478 +        }
   3.479 +        posy += incy;
   3.480 +        info->dst += info->dst_pitch;
   3.481 +    }
   3.482 +}
   3.483 +
   3.484 +static void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info)
   3.485 +{
   3.486 +    const int flags = info->flags;
   3.487 +    Uint32 srcpixel;
   3.488 +    Uint32 srcR, srcG, srcB, srcA;
   3.489 +    Uint32 dstpixel;
   3.490 +    Uint32 dstR, dstG, dstB, dstA;
   3.491 +
   3.492 +    while (info->dst_h--) {
   3.493 +        Uint32 *src = (Uint32 *)info->src;
   3.494 +        Uint32 *dst = (Uint32 *)info->dst;
   3.495 +        int n = info->dst_w;
   3.496 +        while (n--) {
   3.497 +            srcpixel = *src;
   3.498 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
   3.499 +            dstpixel = *dst;
   3.500 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   3.501 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   3.502 +                /* This goes away if we ever use premultiplied alpha */
   3.503 +                if (srcA < 255) {
   3.504 +                    srcR = (srcR * srcA) / 255;
   3.505 +                    srcG = (srcG * srcA) / 255;
   3.506 +                    srcB = (srcB * srcA) / 255;
   3.507 +                }
   3.508 +            }
   3.509 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
   3.510 +            case SDL_COPY_MASK:
   3.511 +                if (srcA) {
   3.512 +                    dstR = srcR;
   3.513 +                    dstG = srcG;
   3.514 +                    dstB = srcB;
   3.515 +                }
   3.516 +                break;
   3.517 +            case SDL_COPY_BLEND:
   3.518 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
   3.519 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
   3.520 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
   3.521 +                break;
   3.522 +            case SDL_COPY_ADD:
   3.523 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
   3.524 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
   3.525 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
   3.526 +                break;
   3.527 +            case SDL_COPY_MOD:
   3.528 +                dstR = (srcR * dstR) / 255;
   3.529 +                dstG = (srcG * dstG) / 255;
   3.530 +                dstB = (srcB * dstB) / 255;
   3.531 +                break;
   3.532 +            }
   3.533 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   3.534 +            *dst = dstpixel;
   3.535 +            ++src;
   3.536 +            ++dst;
   3.537 +        }
   3.538 +        info->src += info->src_pitch;
   3.539 +        info->dst += info->dst_pitch;
   3.540 +    }
   3.541 +}
   3.542 +
   3.543 +static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
   3.544 +{
   3.545 +    const int flags = info->flags;
   3.546 +    Uint32 srcpixel;
   3.547 +    Uint32 srcR, srcG, srcB, srcA;
   3.548 +    Uint32 dstpixel;
   3.549 +    Uint32 dstR, dstG, dstB, dstA;
   3.550 +    int srcy, srcx;
   3.551 +    int posy, posx;
   3.552 +    int incy, incx;
   3.553 +
   3.554 +    srcy = 0;
   3.555 +    posy = 0;
   3.556 +    incy = (info->src_h << 16) / info->dst_h;
   3.557 +    incx = (info->src_w << 16) / info->dst_w;
   3.558 +
   3.559 +    while (info->dst_h--) {
   3.560 +        Uint32 *src;
   3.561 +        Uint32 *dst = (Uint32 *)info->dst;
   3.562 +        int n = info->dst_w;
   3.563 +        srcx = -1;
   3.564 +        posx = 0x10000L;
   3.565 +        while (posy >= 0x10000L) {
   3.566 +            ++srcy;
   3.567 +            posy -= 0x10000L;
   3.568 +        }
   3.569 +        while (n--) {
   3.570 +            if (posx >= 0x10000L) {
   3.571 +                while (posx >= 0x10000L) {
   3.572 +                    ++srcx;
   3.573 +                    posx -= 0x10000L;
   3.574 +                }
   3.575 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   3.576 +            }
   3.577 +            srcpixel = *src;
   3.578 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
   3.579 +            dstpixel = *dst;
   3.580 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   3.581 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   3.582 +                /* This goes away if we ever use premultiplied alpha */
   3.583 +                if (srcA < 255) {
   3.584 +                    srcR = (srcR * srcA) / 255;
   3.585 +                    srcG = (srcG * srcA) / 255;
   3.586 +                    srcB = (srcB * srcA) / 255;
   3.587 +                }
   3.588 +            }
   3.589 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
   3.590 +            case SDL_COPY_MASK:
   3.591 +                if (srcA) {
   3.592 +                    dstR = srcR;
   3.593 +                    dstG = srcG;
   3.594 +                    dstB = srcB;
   3.595 +                }
   3.596 +                break;
   3.597 +            case SDL_COPY_BLEND:
   3.598 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
   3.599 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
   3.600 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
   3.601 +                break;
   3.602 +            case SDL_COPY_ADD:
   3.603 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
   3.604 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
   3.605 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
   3.606 +                break;
   3.607 +            case SDL_COPY_MOD:
   3.608 +                dstR = (srcR * dstR) / 255;
   3.609 +                dstG = (srcG * dstG) / 255;
   3.610 +                dstB = (srcB * dstB) / 255;
   3.611 +                break;
   3.612 +            }
   3.613 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   3.614 +            *dst = dstpixel;
   3.615 +            posx += incx;
   3.616 +            ++dst;
   3.617 +        }
   3.618 +        posy += incy;
   3.619 +        info->dst += info->dst_pitch;
   3.620 +    }
   3.621 +}
   3.622 +
   3.623 +static void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info)
   3.624 +{
   3.625 +    const int flags = info->flags;
   3.626 +    const Uint32 modulateR = info->r;
   3.627 +    const Uint32 modulateG = info->g;
   3.628 +    const Uint32 modulateB = info->b;
   3.629 +    const Uint32 modulateA = info->a;
   3.630 +    Uint32 pixel;
   3.631 +    Uint32 R, G, B, A;
   3.632 +
   3.633 +    while (info->dst_h--) {
   3.634 +        Uint32 *src = (Uint32 *)info->src;
   3.635 +        Uint32 *dst = (Uint32 *)info->dst;
   3.636 +        int n = info->dst_w;
   3.637 +        while (n--) {
   3.638 +            pixel = *src;
   3.639 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
   3.640 +            if (flags & SDL_COPY_MODULATE_COLOR) {
   3.641 +                R = (R * modulateR) / 255;
   3.642 +                G = (G * modulateG) / 255;
   3.643 +                B = (B * modulateB) / 255;
   3.644 +            }
   3.645 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
   3.646 +                A = (A * modulateA) / 255;
   3.647 +            }
   3.648 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
   3.649 +            *dst = pixel;
   3.650 +            ++src;
   3.651 +            ++dst;
   3.652 +        }
   3.653 +        info->src += info->src_pitch;
   3.654 +        info->dst += info->dst_pitch;
   3.655 +    }
   3.656 +}
   3.657 +
   3.658 +static void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
   3.659 +{
   3.660 +    const int flags = info->flags;
   3.661 +    const Uint32 modulateR = info->r;
   3.662 +    const Uint32 modulateG = info->g;
   3.663 +    const Uint32 modulateB = info->b;
   3.664 +    const Uint32 modulateA = info->a;
   3.665 +    Uint32 pixel;
   3.666 +    Uint32 R, G, B, A;
   3.667 +    int srcy, srcx;
   3.668 +    int posy, posx;
   3.669 +    int incy, incx;
   3.670 +
   3.671 +    srcy = 0;
   3.672 +    posy = 0;
   3.673 +    incy = (info->src_h << 16) / info->dst_h;
   3.674 +    incx = (info->src_w << 16) / info->dst_w;
   3.675 +
   3.676 +    while (info->dst_h--) {
   3.677 +        Uint32 *src;
   3.678 +        Uint32 *dst = (Uint32 *)info->dst;
   3.679 +        int n = info->dst_w;
   3.680 +        srcx = -1;
   3.681 +        posx = 0x10000L;
   3.682 +        while (posy >= 0x10000L) {
   3.683 +            ++srcy;
   3.684 +            posy -= 0x10000L;
   3.685 +        }
   3.686 +        while (n--) {
   3.687 +            if (posx >= 0x10000L) {
   3.688 +                while (posx >= 0x10000L) {
   3.689 +                    ++srcx;
   3.690 +                    posx -= 0x10000L;
   3.691 +                }
   3.692 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   3.693 +            }
   3.694 +            pixel = *src;
   3.695 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
   3.696 +            if (flags & SDL_COPY_MODULATE_COLOR) {
   3.697 +                R = (R * modulateR) / 255;
   3.698 +                G = (G * modulateG) / 255;
   3.699 +                B = (B * modulateB) / 255;
   3.700 +            }
   3.701 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
   3.702 +                A = (A * modulateA) / 255;
   3.703 +            }
   3.704 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
   3.705 +            *dst = pixel;
   3.706 +            posx += incx;
   3.707 +            ++dst;
   3.708 +        }
   3.709 +        posy += incy;
   3.710 +        info->dst += info->dst_pitch;
   3.711 +    }
   3.712 +}
   3.713 +
   3.714 +static void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
   3.715 +{
   3.716 +    const int flags = info->flags;
   3.717 +    const Uint32 modulateR = info->r;
   3.718 +    const Uint32 modulateG = info->g;
   3.719 +    const Uint32 modulateB = info->b;
   3.720 +    const Uint32 modulateA = info->a;
   3.721 +    Uint32 srcpixel;
   3.722 +    Uint32 srcR, srcG, srcB, srcA;
   3.723 +    Uint32 dstpixel;
   3.724 +    Uint32 dstR, dstG, dstB, dstA;
   3.725 +
   3.726 +    while (info->dst_h--) {
   3.727 +        Uint32 *src = (Uint32 *)info->src;
   3.728 +        Uint32 *dst = (Uint32 *)info->dst;
   3.729 +        int n = info->dst_w;
   3.730 +        while (n--) {
   3.731 +            srcpixel = *src;
   3.732 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
   3.733 +            dstpixel = *dst;
   3.734 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   3.735 +            if (flags & SDL_COPY_MODULATE_COLOR) {
   3.736 +                srcR = (srcR * modulateR) / 255;
   3.737 +                srcG = (srcG * modulateG) / 255;
   3.738 +                srcB = (srcB * modulateB) / 255;
   3.739 +            }
   3.740 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
   3.741 +                srcA = (srcA * modulateA) / 255;
   3.742 +            }
   3.743 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   3.744 +                /* This goes away if we ever use premultiplied alpha */
   3.745 +                if (srcA < 255) {
   3.746 +                    srcR = (srcR * srcA) / 255;
   3.747 +                    srcG = (srcG * srcA) / 255;
   3.748 +                    srcB = (srcB * srcA) / 255;
   3.749 +                }
   3.750 +            }
   3.751 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
   3.752 +            case SDL_COPY_MASK:
   3.753 +                if (srcA) {
   3.754 +                    dstR = srcR;
   3.755 +                    dstG = srcG;
   3.756 +                    dstB = srcB;
   3.757 +                }
   3.758 +                break;
   3.759 +            case SDL_COPY_BLEND:
   3.760 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
   3.761 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
   3.762 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
   3.763 +                break;
   3.764 +            case SDL_COPY_ADD:
   3.765 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
   3.766 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
   3.767 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
   3.768 +                break;
   3.769 +            case SDL_COPY_MOD:
   3.770 +                dstR = (srcR * dstR) / 255;
   3.771 +                dstG = (srcG * dstG) / 255;
   3.772 +                dstB = (srcB * dstB) / 255;
   3.773 +                break;
   3.774 +            }
   3.775 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   3.776 +            *dst = dstpixel;
   3.777 +            ++src;
   3.778 +            ++dst;
   3.779 +        }
   3.780 +        info->src += info->src_pitch;
   3.781 +        info->dst += info->dst_pitch;
   3.782 +    }
   3.783 +}
   3.784 +
   3.785 +static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   3.786 +{
   3.787 +    const int flags = info->flags;
   3.788 +    const Uint32 modulateR = info->r;
   3.789 +    const Uint32 modulateG = info->g;
   3.790 +    const Uint32 modulateB = info->b;
   3.791 +    const Uint32 modulateA = info->a;
   3.792 +    Uint32 srcpixel;
   3.793 +    Uint32 srcR, srcG, srcB, srcA;
   3.794 +    Uint32 dstpixel;
   3.795 +    Uint32 dstR, dstG, dstB, dstA;
   3.796 +    int srcy, srcx;
   3.797 +    int posy, posx;
   3.798 +    int incy, incx;
   3.799 +
   3.800 +    srcy = 0;
   3.801 +    posy = 0;
   3.802 +    incy = (info->src_h << 16) / info->dst_h;
   3.803 +    incx = (info->src_w << 16) / info->dst_w;
   3.804 +
   3.805 +    while (info->dst_h--) {
   3.806 +        Uint32 *src;
   3.807 +        Uint32 *dst = (Uint32 *)info->dst;
   3.808 +        int n = info->dst_w;
   3.809 +        srcx = -1;
   3.810 +        posx = 0x10000L;
   3.811 +        while (posy >= 0x10000L) {
   3.812 +            ++srcy;
   3.813 +            posy -= 0x10000L;
   3.814 +        }
   3.815 +        while (n--) {
   3.816 +            if (posx >= 0x10000L) {
   3.817 +                while (posx >= 0x10000L) {
   3.818 +                    ++srcx;
   3.819 +                    posx -= 0x10000L;
   3.820 +                }
   3.821 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   3.822 +            }
   3.823 +            srcpixel = *src;
   3.824 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
   3.825 +            dstpixel = *dst;
   3.826 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   3.827 +            if (flags & SDL_COPY_MODULATE_COLOR) {
   3.828 +                srcR = (srcR * modulateR) / 255;
   3.829 +                srcG = (srcG * modulateG) / 255;
   3.830 +                srcB = (srcB * modulateB) / 255;
   3.831 +            }
   3.832 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
   3.833 +                srcA = (srcA * modulateA) / 255;
   3.834 +            }
   3.835 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   3.836 +                /* This goes away if we ever use premultiplied alpha */
   3.837 +                if (srcA < 255) {
   3.838 +                    srcR = (srcR * srcA) / 255;
   3.839 +                    srcG = (srcG * srcA) / 255;
   3.840 +                    srcB = (srcB * srcA) / 255;
   3.841 +                }
   3.842 +            }
   3.843 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
   3.844 +            case SDL_COPY_MASK:
   3.845 +                if (srcA) {
   3.846 +                    dstR = srcR;
   3.847 +                    dstG = srcG;
   3.848 +                    dstB = srcB;
   3.849 +                }
   3.850 +                break;
   3.851 +            case SDL_COPY_BLEND:
   3.852 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
   3.853 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
   3.854 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
   3.855 +                break;
   3.856 +            case SDL_COPY_ADD:
   3.857 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
   3.858 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
   3.859 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
   3.860 +                break;
   3.861 +            case SDL_COPY_MOD:
   3.862 +                dstR = (srcR * dstR) / 255;
   3.863 +                dstG = (srcG * dstG) / 255;
   3.864 +                dstB = (srcB * dstB) / 255;
   3.865 +                break;
   3.866 +            }
   3.867 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   3.868 +            *dst = dstpixel;
   3.869 +            posx += incx;
   3.870 +            ++dst;
   3.871 +        }
   3.872 +        posy += incy;
   3.873 +        info->dst += info->dst_pitch;
   3.874 +    }
   3.875 +}
   3.876 +
   3.877 +static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info)
   3.878 +{
   3.879 +    const int flags = info->flags;
   3.880 +    Uint32 pixel;
   3.881 +    Uint32 R, G, B, A;
   3.882 +    int srcy, srcx;
   3.883 +    int posy, posx;
   3.884 +    int incy, incx;
   3.885 +
   3.886 +    srcy = 0;
   3.887 +    posy = 0;
   3.888 +    incy = (info->src_h << 16) / info->dst_h;
   3.889 +    incx = (info->src_w << 16) / info->dst_w;
   3.890 +
   3.891 +    while (info->dst_h--) {
   3.892 +        Uint32 *src;
   3.893 +        Uint32 *dst = (Uint32 *)info->dst;
   3.894 +        int n = info->dst_w;
   3.895 +        srcx = -1;
   3.896 +        posx = 0x10000L;
   3.897 +        while (posy >= 0x10000L) {
   3.898 +            ++srcy;
   3.899 +            posy -= 0x10000L;
   3.900 +        }
   3.901 +        while (n--) {
   3.902 +            if (posx >= 0x10000L) {
   3.903 +                while (posx >= 0x10000L) {
   3.904 +                    ++srcx;
   3.905 +                    posx -= 0x10000L;
   3.906 +                }
   3.907 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   3.908 +            }
   3.909 +            pixel = *src;
   3.910 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
   3.911 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   3.912 +            *dst = pixel;
   3.913 +            posx += incx;
   3.914 +            ++dst;
   3.915 +        }
   3.916 +        posy += incy;
   3.917 +        info->dst += info->dst_pitch;
   3.918 +    }
   3.919 +}
   3.920 +
   3.921 +static void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
   3.922 +{
   3.923 +    const int flags = info->flags;
   3.924 +    Uint32 srcpixel;
   3.925 +    Uint32 srcR, srcG, srcB, srcA;
   3.926 +    Uint32 dstpixel;
   3.927 +    Uint32 dstR, dstG, dstB, dstA;
   3.928 +
   3.929 +    while (info->dst_h--) {
   3.930 +        Uint32 *src = (Uint32 *)info->src;
   3.931 +        Uint32 *dst = (Uint32 *)info->dst;
   3.932 +        int n = info->dst_w;
   3.933 +        while (n--) {
   3.934 +            srcpixel = *src;
   3.935 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   3.936 +            dstpixel = *dst;
   3.937 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   3.938 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   3.939 +                /* This goes away if we ever use premultiplied alpha */
   3.940 +                if (srcA < 255) {
   3.941 +                    srcR = (srcR * srcA) / 255;
   3.942 +                    srcG = (srcG * srcA) / 255;
   3.943 +                    srcB = (srcB * srcA) / 255;
   3.944 +                }
   3.945 +            }
   3.946 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
   3.947 +            case SDL_COPY_MASK:
   3.948 +                if (srcA) {
   3.949 +                    dstR = srcR;
   3.950 +                    dstG = srcG;
   3.951 +                    dstB = srcB;
   3.952 +                }
   3.953 +                break;
   3.954 +            case SDL_COPY_BLEND:
   3.955 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
   3.956 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
   3.957 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
   3.958 +                break;
   3.959 +            case SDL_COPY_ADD:
   3.960 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
   3.961 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
   3.962 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
   3.963 +                break;
   3.964 +            case SDL_COPY_MOD:
   3.965 +                dstR = (srcR * dstR) / 255;
   3.966 +                dstG = (srcG * dstG) / 255;
   3.967 +                dstB = (srcB * dstB) / 255;
   3.968 +                break;
   3.969 +            }
   3.970 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   3.971 +            *dst = dstpixel;
   3.972 +            ++src;
   3.973 +            ++dst;
   3.974 +        }
   3.975 +        info->src += info->src_pitch;
   3.976 +        info->dst += info->dst_pitch;
   3.977 +    }
   3.978 +}
   3.979 +
   3.980 +static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
   3.981 +{
   3.982 +    const int flags = info->flags;
   3.983 +    Uint32 srcpixel;
   3.984 +    Uint32 srcR, srcG, srcB, srcA;
   3.985 +    Uint32 dstpixel;
   3.986 +    Uint32 dstR, dstG, dstB, dstA;
   3.987 +    int srcy, srcx;
   3.988 +    int posy, posx;
   3.989 +    int incy, incx;
   3.990 +
   3.991 +    srcy = 0;
   3.992 +    posy = 0;
   3.993 +    incy = (info->src_h << 16) / info->dst_h;
   3.994 +    incx = (info->src_w << 16) / info->dst_w;
   3.995 +
   3.996 +    while (info->dst_h--) {
   3.997 +        Uint32 *src;
   3.998 +        Uint32 *dst = (Uint32 *)info->dst;
   3.999 +        int n = info->dst_w;
  3.1000 +        srcx = -1;
  3.1001 +        posx = 0x10000L;
  3.1002 +        while (posy >= 0x10000L) {
  3.1003 +            ++srcy;
  3.1004 +            posy -= 0x10000L;
  3.1005 +        }
  3.1006 +        while (n--) {
  3.1007 +            if (posx >= 0x10000L) {
  3.1008 +                while (posx >= 0x10000L) {
  3.1009 +                    ++srcx;
  3.1010 +                    posx -= 0x10000L;
  3.1011 +                }
  3.1012 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.1013 +            }
  3.1014 +            srcpixel = *src;
  3.1015 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.1016 +            dstpixel = *dst;
  3.1017 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.1018 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.1019 +                /* This goes away if we ever use premultiplied alpha */
  3.1020 +                if (srcA < 255) {
  3.1021 +                    srcR = (srcR * srcA) / 255;
  3.1022 +                    srcG = (srcG * srcA) / 255;
  3.1023 +                    srcB = (srcB * srcA) / 255;
  3.1024 +                }
  3.1025 +            }
  3.1026 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.1027 +            case SDL_COPY_MASK:
  3.1028 +                if (srcA) {
  3.1029 +                    dstR = srcR;
  3.1030 +                    dstG = srcG;
  3.1031 +                    dstB = srcB;
  3.1032 +                }
  3.1033 +                break;
  3.1034 +            case SDL_COPY_BLEND:
  3.1035 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.1036 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.1037 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.1038 +                break;
  3.1039 +            case SDL_COPY_ADD:
  3.1040 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.1041 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.1042 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.1043 +                break;
  3.1044 +            case SDL_COPY_MOD:
  3.1045 +                dstR = (srcR * dstR) / 255;
  3.1046 +                dstG = (srcG * dstG) / 255;
  3.1047 +                dstB = (srcB * dstB) / 255;
  3.1048 +                break;
  3.1049 +            }
  3.1050 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.1051 +            *dst = dstpixel;
  3.1052 +            posx += incx;
  3.1053 +            ++dst;
  3.1054 +        }
  3.1055 +        posy += incy;
  3.1056 +        info->dst += info->dst_pitch;
  3.1057 +    }
  3.1058 +}
  3.1059 +
  3.1060 +static void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info)
  3.1061 +{
  3.1062 +    const int flags = info->flags;
  3.1063 +    const Uint32 modulateR = info->r;
  3.1064 +    const Uint32 modulateG = info->g;
  3.1065 +    const Uint32 modulateB = info->b;
  3.1066 +    const Uint32 modulateA = info->a;
  3.1067 +    Uint32 pixel;
  3.1068 +    Uint32 R, G, B, A;
  3.1069 +
  3.1070 +    while (info->dst_h--) {
  3.1071 +        Uint32 *src = (Uint32 *)info->src;
  3.1072 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1073 +        int n = info->dst_w;
  3.1074 +        while (n--) {
  3.1075 +            pixel = *src;
  3.1076 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  3.1077 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.1078 +                R = (R * modulateR) / 255;
  3.1079 +                G = (G * modulateG) / 255;
  3.1080 +                B = (B * modulateB) / 255;
  3.1081 +            }
  3.1082 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.1083 +                A = (A * modulateA) / 255;
  3.1084 +            }
  3.1085 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.1086 +            *dst = pixel;
  3.1087 +            ++src;
  3.1088 +            ++dst;
  3.1089 +        }
  3.1090 +        info->src += info->src_pitch;
  3.1091 +        info->dst += info->dst_pitch;
  3.1092 +    }
  3.1093 +}
  3.1094 +
  3.1095 +static void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  3.1096 +{
  3.1097 +    const int flags = info->flags;
  3.1098 +    const Uint32 modulateR = info->r;
  3.1099 +    const Uint32 modulateG = info->g;
  3.1100 +    const Uint32 modulateB = info->b;
  3.1101 +    const Uint32 modulateA = info->a;
  3.1102 +    Uint32 pixel;
  3.1103 +    Uint32 R, G, B, A;
  3.1104 +    int srcy, srcx;
  3.1105 +    int posy, posx;
  3.1106 +    int incy, incx;
  3.1107 +
  3.1108 +    srcy = 0;
  3.1109 +    posy = 0;
  3.1110 +    incy = (info->src_h << 16) / info->dst_h;
  3.1111 +    incx = (info->src_w << 16) / info->dst_w;
  3.1112 +
  3.1113 +    while (info->dst_h--) {
  3.1114 +        Uint32 *src;
  3.1115 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1116 +        int n = info->dst_w;
  3.1117 +        srcx = -1;
  3.1118 +        posx = 0x10000L;
  3.1119 +        while (posy >= 0x10000L) {
  3.1120 +            ++srcy;
  3.1121 +            posy -= 0x10000L;
  3.1122 +        }
  3.1123 +        while (n--) {
  3.1124 +            if (posx >= 0x10000L) {
  3.1125 +                while (posx >= 0x10000L) {
  3.1126 +                    ++srcx;
  3.1127 +                    posx -= 0x10000L;
  3.1128 +                }
  3.1129 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.1130 +            }
  3.1131 +            pixel = *src;
  3.1132 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  3.1133 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.1134 +                R = (R * modulateR) / 255;
  3.1135 +                G = (G * modulateG) / 255;
  3.1136 +                B = (B * modulateB) / 255;
  3.1137 +            }
  3.1138 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.1139 +                A = (A * modulateA) / 255;
  3.1140 +            }
  3.1141 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.1142 +            *dst = pixel;
  3.1143 +            posx += incx;
  3.1144 +            ++dst;
  3.1145 +        }
  3.1146 +        posy += incy;
  3.1147 +        info->dst += info->dst_pitch;
  3.1148 +    }
  3.1149 +}
  3.1150 +
  3.1151 +static void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  3.1152 +{
  3.1153 +    const int flags = info->flags;
  3.1154 +    const Uint32 modulateR = info->r;
  3.1155 +    const Uint32 modulateG = info->g;
  3.1156 +    const Uint32 modulateB = info->b;
  3.1157 +    const Uint32 modulateA = info->a;
  3.1158 +    Uint32 srcpixel;
  3.1159 +    Uint32 srcR, srcG, srcB, srcA;
  3.1160 +    Uint32 dstpixel;
  3.1161 +    Uint32 dstR, dstG, dstB, dstA;
  3.1162 +
  3.1163 +    while (info->dst_h--) {
  3.1164 +        Uint32 *src = (Uint32 *)info->src;
  3.1165 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1166 +        int n = info->dst_w;
  3.1167 +        while (n--) {
  3.1168 +            srcpixel = *src;
  3.1169 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.1170 +            dstpixel = *dst;
  3.1171 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.1172 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.1173 +                srcR = (srcR * modulateR) / 255;
  3.1174 +                srcG = (srcG * modulateG) / 255;
  3.1175 +                srcB = (srcB * modulateB) / 255;
  3.1176 +            }
  3.1177 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.1178 +                srcA = (srcA * modulateA) / 255;
  3.1179 +            }
  3.1180 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.1181 +                /* This goes away if we ever use premultiplied alpha */
  3.1182 +                if (srcA < 255) {
  3.1183 +                    srcR = (srcR * srcA) / 255;
  3.1184 +                    srcG = (srcG * srcA) / 255;
  3.1185 +                    srcB = (srcB * srcA) / 255;
  3.1186 +                }
  3.1187 +            }
  3.1188 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.1189 +            case SDL_COPY_MASK:
  3.1190 +                if (srcA) {
  3.1191 +                    dstR = srcR;
  3.1192 +                    dstG = srcG;
  3.1193 +                    dstB = srcB;
  3.1194 +                }
  3.1195 +                break;
  3.1196 +            case SDL_COPY_BLEND:
  3.1197 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.1198 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.1199 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.1200 +                break;
  3.1201 +            case SDL_COPY_ADD:
  3.1202 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.1203 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.1204 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.1205 +                break;
  3.1206 +            case SDL_COPY_MOD:
  3.1207 +                dstR = (srcR * dstR) / 255;
  3.1208 +                dstG = (srcG * dstG) / 255;
  3.1209 +                dstB = (srcB * dstB) / 255;
  3.1210 +                break;
  3.1211 +            }
  3.1212 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.1213 +            *dst = dstpixel;
  3.1214 +            ++src;
  3.1215 +            ++dst;
  3.1216 +        }
  3.1217 +        info->src += info->src_pitch;
  3.1218 +        info->dst += info->dst_pitch;
  3.1219 +    }
  3.1220 +}
  3.1221 +
  3.1222 +static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.1223 +{
  3.1224 +    const int flags = info->flags;
  3.1225 +    const Uint32 modulateR = info->r;
  3.1226 +    const Uint32 modulateG = info->g;
  3.1227 +    const Uint32 modulateB = info->b;
  3.1228 +    const Uint32 modulateA = info->a;
  3.1229 +    Uint32 srcpixel;
  3.1230 +    Uint32 srcR, srcG, srcB, srcA;
  3.1231 +    Uint32 dstpixel;
  3.1232 +    Uint32 dstR, dstG, dstB, dstA;
  3.1233 +    int srcy, srcx;
  3.1234 +    int posy, posx;
  3.1235 +    int incy, incx;
  3.1236 +
  3.1237 +    srcy = 0;
  3.1238 +    posy = 0;
  3.1239 +    incy = (info->src_h << 16) / info->dst_h;
  3.1240 +    incx = (info->src_w << 16) / info->dst_w;
  3.1241 +
  3.1242 +    while (info->dst_h--) {
  3.1243 +        Uint32 *src;
  3.1244 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1245 +        int n = info->dst_w;
  3.1246 +        srcx = -1;
  3.1247 +        posx = 0x10000L;
  3.1248 +        while (posy >= 0x10000L) {
  3.1249 +            ++srcy;
  3.1250 +            posy -= 0x10000L;
  3.1251 +        }
  3.1252 +        while (n--) {
  3.1253 +            if (posx >= 0x10000L) {
  3.1254 +                while (posx >= 0x10000L) {
  3.1255 +                    ++srcx;
  3.1256 +                    posx -= 0x10000L;
  3.1257 +                }
  3.1258 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.1259 +            }
  3.1260 +            srcpixel = *src;
  3.1261 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.1262 +            dstpixel = *dst;
  3.1263 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.1264 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.1265 +                srcR = (srcR * modulateR) / 255;
  3.1266 +                srcG = (srcG * modulateG) / 255;
  3.1267 +                srcB = (srcB * modulateB) / 255;
  3.1268 +            }
  3.1269 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.1270 +                srcA = (srcA * modulateA) / 255;
  3.1271 +            }
  3.1272 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.1273 +                /* This goes away if we ever use premultiplied alpha */
  3.1274 +                if (srcA < 255) {
  3.1275 +                    srcR = (srcR * srcA) / 255;
  3.1276 +                    srcG = (srcG * srcA) / 255;
  3.1277 +                    srcB = (srcB * srcA) / 255;
  3.1278 +                }
  3.1279 +            }
  3.1280 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.1281 +            case SDL_COPY_MASK:
  3.1282 +                if (srcA) {
  3.1283 +                    dstR = srcR;
  3.1284 +                    dstG = srcG;
  3.1285 +                    dstB = srcB;
  3.1286 +                }
  3.1287 +                break;
  3.1288 +            case SDL_COPY_BLEND:
  3.1289 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.1290 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.1291 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.1292 +                break;
  3.1293 +            case SDL_COPY_ADD:
  3.1294 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.1295 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.1296 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.1297 +                break;
  3.1298 +            case SDL_COPY_MOD:
  3.1299 +                dstR = (srcR * dstR) / 255;
  3.1300 +                dstG = (srcG * dstG) / 255;
  3.1301 +                dstB = (srcB * dstB) / 255;
  3.1302 +                break;
  3.1303 +            }
  3.1304 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.1305 +            *dst = dstpixel;
  3.1306 +            posx += incx;
  3.1307 +            ++dst;
  3.1308 +        }
  3.1309 +        posy += incy;
  3.1310 +        info->dst += info->dst_pitch;
  3.1311 +    }
  3.1312 +}
  3.1313 +
  3.1314 +static void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info)
  3.1315 +{
  3.1316 +    const int flags = info->flags;
  3.1317 +    int srcy, srcx;
  3.1318 +    int posy, posx;
  3.1319 +    int incy, incx;
  3.1320 +
  3.1321 +    srcy = 0;
  3.1322 +    posy = 0;
  3.1323 +    incy = (info->src_h << 16) / info->dst_h;
  3.1324 +    incx = (info->src_w << 16) / info->dst_w;
  3.1325 +
  3.1326 +    while (info->dst_h--) {
  3.1327 +        Uint32 *src;
  3.1328 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1329 +        int n = info->dst_w;
  3.1330 +        srcx = -1;
  3.1331 +        posx = 0x10000L;
  3.1332 +        while (posy >= 0x10000L) {
  3.1333 +            ++srcy;
  3.1334 +            posy -= 0x10000L;
  3.1335 +        }
  3.1336 +        while (n--) {
  3.1337 +            if (posx >= 0x10000L) {
  3.1338 +                while (posx >= 0x10000L) {
  3.1339 +                    ++srcx;
  3.1340 +                    posx -= 0x10000L;
  3.1341 +                }
  3.1342 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.1343 +            }
  3.1344 +            *dst = *src;
  3.1345 +            posx += incx;
  3.1346 +            ++dst;
  3.1347 +        }
  3.1348 +        posy += incy;
  3.1349 +        info->dst += info->dst_pitch;
  3.1350 +    }
  3.1351 +}
  3.1352 +
  3.1353 +static void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info)
  3.1354 +{
  3.1355 +    const int flags = info->flags;
  3.1356 +    Uint32 srcpixel;
  3.1357 +    Uint32 srcR, srcG, srcB, srcA;
  3.1358 +    Uint32 dstpixel;
  3.1359 +    Uint32 dstR, dstG, dstB, dstA;
  3.1360 +
  3.1361 +    while (info->dst_h--) {
  3.1362 +        Uint32 *src = (Uint32 *)info->src;
  3.1363 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1364 +        int n = info->dst_w;
  3.1365 +        while (n--) {
  3.1366 +            srcpixel = *src;
  3.1367 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.1368 +            dstpixel = *dst;
  3.1369 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.1370 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.1371 +                /* This goes away if we ever use premultiplied alpha */
  3.1372 +                if (srcA < 255) {
  3.1373 +                    srcR = (srcR * srcA) / 255;
  3.1374 +                    srcG = (srcG * srcA) / 255;
  3.1375 +                    srcB = (srcB * srcA) / 255;
  3.1376 +                }
  3.1377 +            }
  3.1378 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.1379 +            case SDL_COPY_MASK:
  3.1380 +                if (srcA) {
  3.1381 +                    dstR = srcR;
  3.1382 +                    dstG = srcG;
  3.1383 +                    dstB = srcB;
  3.1384 +                }
  3.1385 +                break;
  3.1386 +            case SDL_COPY_BLEND:
  3.1387 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.1388 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.1389 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.1390 +                break;
  3.1391 +            case SDL_COPY_ADD:
  3.1392 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.1393 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.1394 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.1395 +                break;
  3.1396 +            case SDL_COPY_MOD:
  3.1397 +                dstR = (srcR * dstR) / 255;
  3.1398 +                dstG = (srcG * dstG) / 255;
  3.1399 +                dstB = (srcB * dstB) / 255;
  3.1400 +                break;
  3.1401 +            }
  3.1402 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.1403 +            *dst = dstpixel;
  3.1404 +            ++src;
  3.1405 +            ++dst;
  3.1406 +        }
  3.1407 +        info->src += info->src_pitch;
  3.1408 +        info->dst += info->dst_pitch;
  3.1409 +    }
  3.1410 +}
  3.1411 +
  3.1412 +static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  3.1413 +{
  3.1414 +    const int flags = info->flags;
  3.1415 +    Uint32 srcpixel;
  3.1416 +    Uint32 srcR, srcG, srcB, srcA;
  3.1417 +    Uint32 dstpixel;
  3.1418 +    Uint32 dstR, dstG, dstB, dstA;
  3.1419 +    int srcy, srcx;
  3.1420 +    int posy, posx;
  3.1421 +    int incy, incx;
  3.1422 +
  3.1423 +    srcy = 0;
  3.1424 +    posy = 0;
  3.1425 +    incy = (info->src_h << 16) / info->dst_h;
  3.1426 +    incx = (info->src_w << 16) / info->dst_w;
  3.1427 +
  3.1428 +    while (info->dst_h--) {
  3.1429 +        Uint32 *src;
  3.1430 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1431 +        int n = info->dst_w;
  3.1432 +        srcx = -1;
  3.1433 +        posx = 0x10000L;
  3.1434 +        while (posy >= 0x10000L) {
  3.1435 +            ++srcy;
  3.1436 +            posy -= 0x10000L;
  3.1437 +        }
  3.1438 +        while (n--) {
  3.1439 +            if (posx >= 0x10000L) {
  3.1440 +                while (posx >= 0x10000L) {
  3.1441 +                    ++srcx;
  3.1442 +                    posx -= 0x10000L;
  3.1443 +                }
  3.1444 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.1445 +            }
  3.1446 +            srcpixel = *src;
  3.1447 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.1448 +            dstpixel = *dst;
  3.1449 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.1450 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.1451 +                /* This goes away if we ever use premultiplied alpha */
  3.1452 +                if (srcA < 255) {
  3.1453 +                    srcR = (srcR * srcA) / 255;
  3.1454 +                    srcG = (srcG * srcA) / 255;
  3.1455 +                    srcB = (srcB * srcA) / 255;
  3.1456 +                }
  3.1457 +            }
  3.1458 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.1459 +            case SDL_COPY_MASK:
  3.1460 +                if (srcA) {
  3.1461 +                    dstR = srcR;
  3.1462 +                    dstG = srcG;
  3.1463 +                    dstB = srcB;
  3.1464 +                }
  3.1465 +                break;
  3.1466 +            case SDL_COPY_BLEND:
  3.1467 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.1468 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.1469 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.1470 +                break;
  3.1471 +            case SDL_COPY_ADD:
  3.1472 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.1473 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.1474 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.1475 +                break;
  3.1476 +            case SDL_COPY_MOD:
  3.1477 +                dstR = (srcR * dstR) / 255;
  3.1478 +                dstG = (srcG * dstG) / 255;
  3.1479 +                dstB = (srcB * dstB) / 255;
  3.1480 +                break;
  3.1481 +            }
  3.1482 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.1483 +            *dst = dstpixel;
  3.1484 +            posx += incx;
  3.1485 +            ++dst;
  3.1486 +        }
  3.1487 +        posy += incy;
  3.1488 +        info->dst += info->dst_pitch;
  3.1489 +    }
  3.1490 +}
  3.1491 +
  3.1492 +static void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info)
  3.1493 +{
  3.1494 +    const int flags = info->flags;
  3.1495 +    const Uint32 modulateR = info->r;
  3.1496 +    const Uint32 modulateG = info->g;
  3.1497 +    const Uint32 modulateB = info->b;
  3.1498 +    const Uint32 modulateA = info->a;
  3.1499 +    Uint32 pixel;
  3.1500 +    Uint32 R, G, B, A;
  3.1501 +
  3.1502 +    while (info->dst_h--) {
  3.1503 +        Uint32 *src = (Uint32 *)info->src;
  3.1504 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1505 +        int n = info->dst_w;
  3.1506 +        while (n--) {
  3.1507 +            pixel = *src;
  3.1508 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  3.1509 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.1510 +                R = (R * modulateR) / 255;
  3.1511 +                G = (G * modulateG) / 255;
  3.1512 +                B = (B * modulateB) / 255;
  3.1513 +            }
  3.1514 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.1515 +                A = (A * modulateA) / 255;
  3.1516 +            }
  3.1517 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.1518 +            *dst = pixel;
  3.1519 +            ++src;
  3.1520 +            ++dst;
  3.1521 +        }
  3.1522 +        info->src += info->src_pitch;
  3.1523 +        info->dst += info->dst_pitch;
  3.1524 +    }
  3.1525 +}
  3.1526 +
  3.1527 +static void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  3.1528 +{
  3.1529 +    const int flags = info->flags;
  3.1530 +    const Uint32 modulateR = info->r;
  3.1531 +    const Uint32 modulateG = info->g;
  3.1532 +    const Uint32 modulateB = info->b;
  3.1533 +    const Uint32 modulateA = info->a;
  3.1534 +    Uint32 pixel;
  3.1535 +    Uint32 R, G, B, A;
  3.1536 +    int srcy, srcx;
  3.1537 +    int posy, posx;
  3.1538 +    int incy, incx;
  3.1539 +
  3.1540 +    srcy = 0;
  3.1541 +    posy = 0;
  3.1542 +    incy = (info->src_h << 16) / info->dst_h;
  3.1543 +    incx = (info->src_w << 16) / info->dst_w;
  3.1544 +
  3.1545 +    while (info->dst_h--) {
  3.1546 +        Uint32 *src;
  3.1547 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1548 +        int n = info->dst_w;
  3.1549 +        srcx = -1;
  3.1550 +        posx = 0x10000L;
  3.1551 +        while (posy >= 0x10000L) {
  3.1552 +            ++srcy;
  3.1553 +            posy -= 0x10000L;
  3.1554 +        }
  3.1555 +        while (n--) {
  3.1556 +            if (posx >= 0x10000L) {
  3.1557 +                while (posx >= 0x10000L) {
  3.1558 +                    ++srcx;
  3.1559 +                    posx -= 0x10000L;
  3.1560 +                }
  3.1561 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.1562 +            }
  3.1563 +            pixel = *src;
  3.1564 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  3.1565 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.1566 +                R = (R * modulateR) / 255;
  3.1567 +                G = (G * modulateG) / 255;
  3.1568 +                B = (B * modulateB) / 255;
  3.1569 +            }
  3.1570 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.1571 +                A = (A * modulateA) / 255;
  3.1572 +            }
  3.1573 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.1574 +            *dst = pixel;
  3.1575 +            posx += incx;
  3.1576 +            ++dst;
  3.1577 +        }
  3.1578 +        posy += incy;
  3.1579 +        info->dst += info->dst_pitch;
  3.1580 +    }
  3.1581 +}
  3.1582 +
  3.1583 +static void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  3.1584 +{
  3.1585 +    const int flags = info->flags;
  3.1586 +    const Uint32 modulateR = info->r;
  3.1587 +    const Uint32 modulateG = info->g;
  3.1588 +    const Uint32 modulateB = info->b;
  3.1589 +    const Uint32 modulateA = info->a;
  3.1590 +    Uint32 srcpixel;
  3.1591 +    Uint32 srcR, srcG, srcB, srcA;
  3.1592 +    Uint32 dstpixel;
  3.1593 +    Uint32 dstR, dstG, dstB, dstA;
  3.1594 +
  3.1595 +    while (info->dst_h--) {
  3.1596 +        Uint32 *src = (Uint32 *)info->src;
  3.1597 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1598 +        int n = info->dst_w;
  3.1599 +        while (n--) {
  3.1600 +            srcpixel = *src;
  3.1601 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.1602 +            dstpixel = *dst;
  3.1603 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.1604 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.1605 +                srcR = (srcR * modulateR) / 255;
  3.1606 +                srcG = (srcG * modulateG) / 255;
  3.1607 +                srcB = (srcB * modulateB) / 255;
  3.1608 +            }
  3.1609 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.1610 +                srcA = (srcA * modulateA) / 255;
  3.1611 +            }
  3.1612 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.1613 +                /* This goes away if we ever use premultiplied alpha */
  3.1614 +                if (srcA < 255) {
  3.1615 +                    srcR = (srcR * srcA) / 255;
  3.1616 +                    srcG = (srcG * srcA) / 255;
  3.1617 +                    srcB = (srcB * srcA) / 255;
  3.1618 +                }
  3.1619 +            }
  3.1620 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.1621 +            case SDL_COPY_MASK:
  3.1622 +                if (srcA) {
  3.1623 +                    dstR = srcR;
  3.1624 +                    dstG = srcG;
  3.1625 +                    dstB = srcB;
  3.1626 +                }
  3.1627 +                break;
  3.1628 +            case SDL_COPY_BLEND:
  3.1629 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.1630 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.1631 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.1632 +                break;
  3.1633 +            case SDL_COPY_ADD:
  3.1634 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.1635 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.1636 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.1637 +                break;
  3.1638 +            case SDL_COPY_MOD:
  3.1639 +                dstR = (srcR * dstR) / 255;
  3.1640 +                dstG = (srcG * dstG) / 255;
  3.1641 +                dstB = (srcB * dstB) / 255;
  3.1642 +                break;
  3.1643 +            }
  3.1644 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.1645 +            *dst = dstpixel;
  3.1646 +            ++src;
  3.1647 +            ++dst;
  3.1648 +        }
  3.1649 +        info->src += info->src_pitch;
  3.1650 +        info->dst += info->dst_pitch;
  3.1651 +    }
  3.1652 +}
  3.1653 +
  3.1654 +static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.1655 +{
  3.1656 +    const int flags = info->flags;
  3.1657 +    const Uint32 modulateR = info->r;
  3.1658 +    const Uint32 modulateG = info->g;
  3.1659 +    const Uint32 modulateB = info->b;
  3.1660 +    const Uint32 modulateA = info->a;
  3.1661 +    Uint32 srcpixel;
  3.1662 +    Uint32 srcR, srcG, srcB, srcA;
  3.1663 +    Uint32 dstpixel;
  3.1664 +    Uint32 dstR, dstG, dstB, dstA;
  3.1665 +    int srcy, srcx;
  3.1666 +    int posy, posx;
  3.1667 +    int incy, incx;
  3.1668 +
  3.1669 +    srcy = 0;
  3.1670 +    posy = 0;
  3.1671 +    incy = (info->src_h << 16) / info->dst_h;
  3.1672 +    incx = (info->src_w << 16) / info->dst_w;
  3.1673 +
  3.1674 +    while (info->dst_h--) {
  3.1675 +        Uint32 *src;
  3.1676 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1677 +        int n = info->dst_w;
  3.1678 +        srcx = -1;
  3.1679 +        posx = 0x10000L;
  3.1680 +        while (posy >= 0x10000L) {
  3.1681 +            ++srcy;
  3.1682 +            posy -= 0x10000L;
  3.1683 +        }
  3.1684 +        while (n--) {
  3.1685 +            if (posx >= 0x10000L) {
  3.1686 +                while (posx >= 0x10000L) {
  3.1687 +                    ++srcx;
  3.1688 +                    posx -= 0x10000L;
  3.1689 +                }
  3.1690 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.1691 +            }
  3.1692 +            srcpixel = *src;
  3.1693 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.1694 +            dstpixel = *dst;
  3.1695 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.1696 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.1697 +                srcR = (srcR * modulateR) / 255;
  3.1698 +                srcG = (srcG * modulateG) / 255;
  3.1699 +                srcB = (srcB * modulateB) / 255;
  3.1700 +            }
  3.1701 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.1702 +                srcA = (srcA * modulateA) / 255;
  3.1703 +            }
  3.1704 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.1705 +                /* This goes away if we ever use premultiplied alpha */
  3.1706 +                if (srcA < 255) {
  3.1707 +                    srcR = (srcR * srcA) / 255;
  3.1708 +                    srcG = (srcG * srcA) / 255;
  3.1709 +                    srcB = (srcB * srcA) / 255;
  3.1710 +                }
  3.1711 +            }
  3.1712 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.1713 +            case SDL_COPY_MASK:
  3.1714 +                if (srcA) {
  3.1715 +                    dstR = srcR;
  3.1716 +                    dstG = srcG;
  3.1717 +                    dstB = srcB;
  3.1718 +                }
  3.1719 +                break;
  3.1720 +            case SDL_COPY_BLEND:
  3.1721 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.1722 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.1723 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.1724 +                break;
  3.1725 +            case SDL_COPY_ADD:
  3.1726 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.1727 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.1728 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.1729 +                break;
  3.1730 +            case SDL_COPY_MOD:
  3.1731 +                dstR = (srcR * dstR) / 255;
  3.1732 +                dstG = (srcG * dstG) / 255;
  3.1733 +                dstB = (srcB * dstB) / 255;
  3.1734 +                break;
  3.1735 +            }
  3.1736 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.1737 +            *dst = dstpixel;
  3.1738 +            posx += incx;
  3.1739 +            ++dst;
  3.1740 +        }
  3.1741 +        posy += incy;
  3.1742 +        info->dst += info->dst_pitch;
  3.1743 +    }
  3.1744 +}
  3.1745 +
  3.1746 +static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
  3.1747 +{
  3.1748 +    const int flags = info->flags;
  3.1749 +    Uint32 pixel;
  3.1750 +    Uint32 R, G, B, A;
  3.1751 +    int srcy, srcx;
  3.1752 +    int posy, posx;
  3.1753 +    int incy, incx;
  3.1754 +
  3.1755 +    srcy = 0;
  3.1756 +    posy = 0;
  3.1757 +    incy = (info->src_h << 16) / info->dst_h;
  3.1758 +    incx = (info->src_w << 16) / info->dst_w;
  3.1759 +
  3.1760 +    while (info->dst_h--) {
  3.1761 +        Uint32 *src;
  3.1762 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1763 +        int n = info->dst_w;
  3.1764 +        srcx = -1;
  3.1765 +        posx = 0x10000L;
  3.1766 +        while (posy >= 0x10000L) {
  3.1767 +            ++srcy;
  3.1768 +            posy -= 0x10000L;
  3.1769 +        }
  3.1770 +        while (n--) {
  3.1771 +            if (posx >= 0x10000L) {
  3.1772 +                while (posx >= 0x10000L) {
  3.1773 +                    ++srcx;
  3.1774 +                    posx -= 0x10000L;
  3.1775 +                }
  3.1776 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.1777 +            }
  3.1778 +            pixel = *src;
  3.1779 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.1780 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.1781 +            *dst = pixel;
  3.1782 +            posx += incx;
  3.1783 +            ++dst;
  3.1784 +        }
  3.1785 +        posy += incy;
  3.1786 +        info->dst += info->dst_pitch;
  3.1787 +    }
  3.1788 +}
  3.1789 +
  3.1790 +static void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info)
  3.1791 +{
  3.1792 +    const int flags = info->flags;
  3.1793 +    Uint32 srcpixel;
  3.1794 +    Uint32 srcR, srcG, srcB, srcA;
  3.1795 +    Uint32 dstpixel;
  3.1796 +    Uint32 dstR, dstG, dstB, dstA;
  3.1797 +
  3.1798 +    while (info->dst_h--) {
  3.1799 +        Uint32 *src = (Uint32 *)info->src;
  3.1800 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1801 +        int n = info->dst_w;
  3.1802 +        while (n--) {
  3.1803 +            srcpixel = *src;
  3.1804 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.1805 +            dstpixel = *dst;
  3.1806 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.1807 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.1808 +                /* This goes away if we ever use premultiplied alpha */
  3.1809 +                if (srcA < 255) {
  3.1810 +                    srcR = (srcR * srcA) / 255;
  3.1811 +                    srcG = (srcG * srcA) / 255;
  3.1812 +                    srcB = (srcB * srcA) / 255;
  3.1813 +                }
  3.1814 +            }
  3.1815 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.1816 +            case SDL_COPY_MASK:
  3.1817 +                if (srcA) {
  3.1818 +                    dstR = srcR;
  3.1819 +                    dstG = srcG;
  3.1820 +                    dstB = srcB;
  3.1821 +                }
  3.1822 +                break;
  3.1823 +            case SDL_COPY_BLEND:
  3.1824 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.1825 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.1826 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.1827 +                break;
  3.1828 +            case SDL_COPY_ADD:
  3.1829 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.1830 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.1831 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.1832 +                break;
  3.1833 +            case SDL_COPY_MOD:
  3.1834 +                dstR = (srcR * dstR) / 255;
  3.1835 +                dstG = (srcG * dstG) / 255;
  3.1836 +                dstB = (srcB * dstB) / 255;
  3.1837 +                break;
  3.1838 +            }
  3.1839 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.1840 +            *dst = dstpixel;
  3.1841 +            ++src;
  3.1842 +            ++dst;
  3.1843 +        }
  3.1844 +        info->src += info->src_pitch;
  3.1845 +        info->dst += info->dst_pitch;
  3.1846 +    }
  3.1847 +}
  3.1848 +
  3.1849 +static void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  3.1850 +{
  3.1851 +    const int flags = info->flags;
  3.1852 +    Uint32 srcpixel;
  3.1853 +    Uint32 srcR, srcG, srcB, srcA;
  3.1854 +    Uint32 dstpixel;
  3.1855 +    Uint32 dstR, dstG, dstB, dstA;
  3.1856 +    int srcy, srcx;
  3.1857 +    int posy, posx;
  3.1858 +    int incy, incx;
  3.1859 +
  3.1860 +    srcy = 0;
  3.1861 +    posy = 0;
  3.1862 +    incy = (info->src_h << 16) / info->dst_h;
  3.1863 +    incx = (info->src_w << 16) / info->dst_w;
  3.1864 +
  3.1865 +    while (info->dst_h--) {
  3.1866 +        Uint32 *src;
  3.1867 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1868 +        int n = info->dst_w;
  3.1869 +        srcx = -1;
  3.1870 +        posx = 0x10000L;
  3.1871 +        while (posy >= 0x10000L) {
  3.1872 +            ++srcy;
  3.1873 +            posy -= 0x10000L;
  3.1874 +        }
  3.1875 +        while (n--) {
  3.1876 +            if (posx >= 0x10000L) {
  3.1877 +                while (posx >= 0x10000L) {
  3.1878 +                    ++srcx;
  3.1879 +                    posx -= 0x10000L;
  3.1880 +                }
  3.1881 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.1882 +            }
  3.1883 +            srcpixel = *src;
  3.1884 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.1885 +            dstpixel = *dst;
  3.1886 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.1887 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.1888 +                /* This goes away if we ever use premultiplied alpha */
  3.1889 +                if (srcA < 255) {
  3.1890 +                    srcR = (srcR * srcA) / 255;
  3.1891 +                    srcG = (srcG * srcA) / 255;
  3.1892 +                    srcB = (srcB * srcA) / 255;
  3.1893 +                }
  3.1894 +            }
  3.1895 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.1896 +            case SDL_COPY_MASK:
  3.1897 +                if (srcA) {
  3.1898 +                    dstR = srcR;
  3.1899 +                    dstG = srcG;
  3.1900 +                    dstB = srcB;
  3.1901 +                }
  3.1902 +                break;
  3.1903 +            case SDL_COPY_BLEND:
  3.1904 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.1905 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.1906 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.1907 +                break;
  3.1908 +            case SDL_COPY_ADD:
  3.1909 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.1910 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.1911 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.1912 +                break;
  3.1913 +            case SDL_COPY_MOD:
  3.1914 +                dstR = (srcR * dstR) / 255;
  3.1915 +                dstG = (srcG * dstG) / 255;
  3.1916 +                dstB = (srcB * dstB) / 255;
  3.1917 +                break;
  3.1918 +            }
  3.1919 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.1920 +            *dst = dstpixel;
  3.1921 +            posx += incx;
  3.1922 +            ++dst;
  3.1923 +        }
  3.1924 +        posy += incy;
  3.1925 +        info->dst += info->dst_pitch;
  3.1926 +    }
  3.1927 +}
  3.1928 +
  3.1929 +static void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info)
  3.1930 +{
  3.1931 +    const int flags = info->flags;
  3.1932 +    const Uint32 modulateR = info->r;
  3.1933 +    const Uint32 modulateG = info->g;
  3.1934 +    const Uint32 modulateB = info->b;
  3.1935 +    const Uint32 modulateA = info->a;
  3.1936 +    Uint32 pixel;
  3.1937 +    Uint32 R, G, B, A;
  3.1938 +
  3.1939 +    while (info->dst_h--) {
  3.1940 +        Uint32 *src = (Uint32 *)info->src;
  3.1941 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1942 +        int n = info->dst_w;
  3.1943 +        while (n--) {
  3.1944 +            pixel = *src;
  3.1945 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.1946 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.1947 +                R = (R * modulateR) / 255;
  3.1948 +                G = (G * modulateG) / 255;
  3.1949 +                B = (B * modulateB) / 255;
  3.1950 +            }
  3.1951 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.1952 +                A = (A * modulateA) / 255;
  3.1953 +            }
  3.1954 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.1955 +            *dst = pixel;
  3.1956 +            ++src;
  3.1957 +            ++dst;
  3.1958 +        }
  3.1959 +        info->src += info->src_pitch;
  3.1960 +        info->dst += info->dst_pitch;
  3.1961 +    }
  3.1962 +}
  3.1963 +
  3.1964 +static void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  3.1965 +{
  3.1966 +    const int flags = info->flags;
  3.1967 +    const Uint32 modulateR = info->r;
  3.1968 +    const Uint32 modulateG = info->g;
  3.1969 +    const Uint32 modulateB = info->b;
  3.1970 +    const Uint32 modulateA = info->a;
  3.1971 +    Uint32 pixel;
  3.1972 +    Uint32 R, G, B, A;
  3.1973 +    int srcy, srcx;
  3.1974 +    int posy, posx;
  3.1975 +    int incy, incx;
  3.1976 +
  3.1977 +    srcy = 0;
  3.1978 +    posy = 0;
  3.1979 +    incy = (info->src_h << 16) / info->dst_h;
  3.1980 +    incx = (info->src_w << 16) / info->dst_w;
  3.1981 +
  3.1982 +    while (info->dst_h--) {
  3.1983 +        Uint32 *src;
  3.1984 +        Uint32 *dst = (Uint32 *)info->dst;
  3.1985 +        int n = info->dst_w;
  3.1986 +        srcx = -1;
  3.1987 +        posx = 0x10000L;
  3.1988 +        while (posy >= 0x10000L) {
  3.1989 +            ++srcy;
  3.1990 +            posy -= 0x10000L;
  3.1991 +        }
  3.1992 +        while (n--) {
  3.1993 +            if (posx >= 0x10000L) {
  3.1994 +                while (posx >= 0x10000L) {
  3.1995 +                    ++srcx;
  3.1996 +                    posx -= 0x10000L;
  3.1997 +                }
  3.1998 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.1999 +            }
  3.2000 +            pixel = *src;
  3.2001 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.2002 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.2003 +                R = (R * modulateR) / 255;
  3.2004 +                G = (G * modulateG) / 255;
  3.2005 +                B = (B * modulateB) / 255;
  3.2006 +            }
  3.2007 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.2008 +                A = (A * modulateA) / 255;
  3.2009 +            }
  3.2010 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.2011 +            *dst = pixel;
  3.2012 +            posx += incx;
  3.2013 +            ++dst;
  3.2014 +        }
  3.2015 +        posy += incy;
  3.2016 +        info->dst += info->dst_pitch;
  3.2017 +    }
  3.2018 +}
  3.2019 +
  3.2020 +static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  3.2021 +{
  3.2022 +    const int flags = info->flags;
  3.2023 +    const Uint32 modulateR = info->r;
  3.2024 +    const Uint32 modulateG = info->g;
  3.2025 +    const Uint32 modulateB = info->b;
  3.2026 +    const Uint32 modulateA = info->a;
  3.2027 +    Uint32 srcpixel;
  3.2028 +    Uint32 srcR, srcG, srcB, srcA;
  3.2029 +    Uint32 dstpixel;
  3.2030 +    Uint32 dstR, dstG, dstB, dstA;
  3.2031 +
  3.2032 +    while (info->dst_h--) {
  3.2033 +        Uint32 *src = (Uint32 *)info->src;
  3.2034 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2035 +        int n = info->dst_w;
  3.2036 +        while (n--) {
  3.2037 +            srcpixel = *src;
  3.2038 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.2039 +            dstpixel = *dst;
  3.2040 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.2041 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.2042 +                srcR = (srcR * modulateR) / 255;
  3.2043 +                srcG = (srcG * modulateG) / 255;
  3.2044 +                srcB = (srcB * modulateB) / 255;
  3.2045 +            }
  3.2046 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.2047 +                srcA = (srcA * modulateA) / 255;
  3.2048 +            }
  3.2049 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.2050 +                /* This goes away if we ever use premultiplied alpha */
  3.2051 +                if (srcA < 255) {
  3.2052 +                    srcR = (srcR * srcA) / 255;
  3.2053 +                    srcG = (srcG * srcA) / 255;
  3.2054 +                    srcB = (srcB * srcA) / 255;
  3.2055 +                }
  3.2056 +            }
  3.2057 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.2058 +            case SDL_COPY_MASK:
  3.2059 +                if (srcA) {
  3.2060 +                    dstR = srcR;
  3.2061 +                    dstG = srcG;
  3.2062 +                    dstB = srcB;
  3.2063 +                }
  3.2064 +                break;
  3.2065 +            case SDL_COPY_BLEND:
  3.2066 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.2067 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.2068 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.2069 +                break;
  3.2070 +            case SDL_COPY_ADD:
  3.2071 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.2072 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.2073 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.2074 +                break;
  3.2075 +            case SDL_COPY_MOD:
  3.2076 +                dstR = (srcR * dstR) / 255;
  3.2077 +                dstG = (srcG * dstG) / 255;
  3.2078 +                dstB = (srcB * dstB) / 255;
  3.2079 +                break;
  3.2080 +            }
  3.2081 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.2082 +            *dst = dstpixel;
  3.2083 +            ++src;
  3.2084 +            ++dst;
  3.2085 +        }
  3.2086 +        info->src += info->src_pitch;
  3.2087 +        info->dst += info->dst_pitch;
  3.2088 +    }
  3.2089 +}
  3.2090 +
  3.2091 +static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.2092 +{
  3.2093 +    const int flags = info->flags;
  3.2094 +    const Uint32 modulateR = info->r;
  3.2095 +    const Uint32 modulateG = info->g;
  3.2096 +    const Uint32 modulateB = info->b;
  3.2097 +    const Uint32 modulateA = info->a;
  3.2098 +    Uint32 srcpixel;
  3.2099 +    Uint32 srcR, srcG, srcB, srcA;
  3.2100 +    Uint32 dstpixel;
  3.2101 +    Uint32 dstR, dstG, dstB, dstA;
  3.2102 +    int srcy, srcx;
  3.2103 +    int posy, posx;
  3.2104 +    int incy, incx;
  3.2105 +
  3.2106 +    srcy = 0;
  3.2107 +    posy = 0;
  3.2108 +    incy = (info->src_h << 16) / info->dst_h;
  3.2109 +    incx = (info->src_w << 16) / info->dst_w;
  3.2110 +
  3.2111 +    while (info->dst_h--) {
  3.2112 +        Uint32 *src;
  3.2113 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2114 +        int n = info->dst_w;
  3.2115 +        srcx = -1;
  3.2116 +        posx = 0x10000L;
  3.2117 +        while (posy >= 0x10000L) {
  3.2118 +            ++srcy;
  3.2119 +            posy -= 0x10000L;
  3.2120 +        }
  3.2121 +        while (n--) {
  3.2122 +            if (posx >= 0x10000L) {
  3.2123 +                while (posx >= 0x10000L) {
  3.2124 +                    ++srcx;
  3.2125 +                    posx -= 0x10000L;
  3.2126 +                }
  3.2127 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.2128 +            }
  3.2129 +            srcpixel = *src;
  3.2130 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.2131 +            dstpixel = *dst;
  3.2132 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.2133 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.2134 +                srcR = (srcR * modulateR) / 255;
  3.2135 +                srcG = (srcG * modulateG) / 255;
  3.2136 +                srcB = (srcB * modulateB) / 255;
  3.2137 +            }
  3.2138 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.2139 +                srcA = (srcA * modulateA) / 255;
  3.2140 +            }
  3.2141 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.2142 +                /* This goes away if we ever use premultiplied alpha */
  3.2143 +                if (srcA < 255) {
  3.2144 +                    srcR = (srcR * srcA) / 255;
  3.2145 +                    srcG = (srcG * srcA) / 255;
  3.2146 +                    srcB = (srcB * srcA) / 255;
  3.2147 +                }
  3.2148 +            }
  3.2149 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.2150 +            case SDL_COPY_MASK:
  3.2151 +                if (srcA) {
  3.2152 +                    dstR = srcR;
  3.2153 +                    dstG = srcG;
  3.2154 +                    dstB = srcB;
  3.2155 +                }
  3.2156 +                break;
  3.2157 +            case SDL_COPY_BLEND:
  3.2158 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.2159 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.2160 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.2161 +                break;
  3.2162 +            case SDL_COPY_ADD:
  3.2163 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.2164 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.2165 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.2166 +                break;
  3.2167 +            case SDL_COPY_MOD:
  3.2168 +                dstR = (srcR * dstR) / 255;
  3.2169 +                dstG = (srcG * dstG) / 255;
  3.2170 +                dstB = (srcB * dstB) / 255;
  3.2171 +                break;
  3.2172 +            }
  3.2173 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.2174 +            *dst = dstpixel;
  3.2175 +            posx += incx;
  3.2176 +            ++dst;
  3.2177 +        }
  3.2178 +        posy += incy;
  3.2179 +        info->dst += info->dst_pitch;
  3.2180 +    }
  3.2181 +}
  3.2182 +
  3.2183 +static void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info)
  3.2184 +{
  3.2185 +    const int flags = info->flags;
  3.2186 +    Uint32 pixel;
  3.2187 +    Uint32 R, G, B, A;
  3.2188 +    int srcy, srcx;
  3.2189 +    int posy, posx;
  3.2190 +    int incy, incx;
  3.2191 +
  3.2192 +    srcy = 0;
  3.2193 +    posy = 0;
  3.2194 +    incy = (info->src_h << 16) / info->dst_h;
  3.2195 +    incx = (info->src_w << 16) / info->dst_w;
  3.2196 +
  3.2197 +    while (info->dst_h--) {
  3.2198 +        Uint32 *src;
  3.2199 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2200 +        int n = info->dst_w;
  3.2201 +        srcx = -1;
  3.2202 +        posx = 0x10000L;
  3.2203 +        while (posy >= 0x10000L) {
  3.2204 +            ++srcy;
  3.2205 +            posy -= 0x10000L;
  3.2206 +        }
  3.2207 +        while (n--) {
  3.2208 +            if (posx >= 0x10000L) {
  3.2209 +                while (posx >= 0x10000L) {
  3.2210 +                    ++srcx;
  3.2211 +                    posx -= 0x10000L;
  3.2212 +                }
  3.2213 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.2214 +            }
  3.2215 +            pixel = *src;
  3.2216 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.2217 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.2218 +            *dst = pixel;
  3.2219 +            posx += incx;
  3.2220 +            ++dst;
  3.2221 +        }
  3.2222 +        posy += incy;
  3.2223 +        info->dst += info->dst_pitch;
  3.2224 +    }
  3.2225 +}
  3.2226 +
  3.2227 +static void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info)
  3.2228 +{
  3.2229 +    const int flags = info->flags;
  3.2230 +    Uint32 srcpixel;
  3.2231 +    Uint32 srcR, srcG, srcB, srcA;
  3.2232 +    Uint32 dstpixel;
  3.2233 +    Uint32 dstR, dstG, dstB, dstA;
  3.2234 +
  3.2235 +    while (info->dst_h--) {
  3.2236 +        Uint32 *src = (Uint32 *)info->src;
  3.2237 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2238 +        int n = info->dst_w;
  3.2239 +        while (n--) {
  3.2240 +            srcpixel = *src;
  3.2241 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.2242 +            dstpixel = *dst;
  3.2243 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.2244 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.2245 +                /* This goes away if we ever use premultiplied alpha */
  3.2246 +                if (srcA < 255) {
  3.2247 +                    srcR = (srcR * srcA) / 255;
  3.2248 +                    srcG = (srcG * srcA) / 255;
  3.2249 +                    srcB = (srcB * srcA) / 255;
  3.2250 +                }
  3.2251 +            }
  3.2252 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.2253 +            case SDL_COPY_MASK:
  3.2254 +                if (srcA) {
  3.2255 +                    dstR = srcR;
  3.2256 +                    dstG = srcG;
  3.2257 +                    dstB = srcB;
  3.2258 +                }
  3.2259 +                break;
  3.2260 +            case SDL_COPY_BLEND:
  3.2261 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.2262 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.2263 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.2264 +                break;
  3.2265 +            case SDL_COPY_ADD:
  3.2266 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.2267 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.2268 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.2269 +                break;
  3.2270 +            case SDL_COPY_MOD:
  3.2271 +                dstR = (srcR * dstR) / 255;
  3.2272 +                dstG = (srcG * dstG) / 255;
  3.2273 +                dstB = (srcB * dstB) / 255;
  3.2274 +                break;
  3.2275 +            }
  3.2276 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.2277 +            *dst = dstpixel;
  3.2278 +            ++src;
  3.2279 +            ++dst;
  3.2280 +        }
  3.2281 +        info->src += info->src_pitch;
  3.2282 +        info->dst += info->dst_pitch;
  3.2283 +    }
  3.2284 +}
  3.2285 +
  3.2286 +static void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  3.2287 +{
  3.2288 +    const int flags = info->flags;
  3.2289 +    Uint32 srcpixel;
  3.2290 +    Uint32 srcR, srcG, srcB, srcA;
  3.2291 +    Uint32 dstpixel;
  3.2292 +    Uint32 dstR, dstG, dstB, dstA;
  3.2293 +    int srcy, srcx;
  3.2294 +    int posy, posx;
  3.2295 +    int incy, incx;
  3.2296 +
  3.2297 +    srcy = 0;
  3.2298 +    posy = 0;
  3.2299 +    incy = (info->src_h << 16) / info->dst_h;
  3.2300 +    incx = (info->src_w << 16) / info->dst_w;
  3.2301 +
  3.2302 +    while (info->dst_h--) {
  3.2303 +        Uint32 *src;
  3.2304 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2305 +        int n = info->dst_w;
  3.2306 +        srcx = -1;
  3.2307 +        posx = 0x10000L;
  3.2308 +        while (posy >= 0x10000L) {
  3.2309 +            ++srcy;
  3.2310 +            posy -= 0x10000L;
  3.2311 +        }
  3.2312 +        while (n--) {
  3.2313 +            if (posx >= 0x10000L) {
  3.2314 +                while (posx >= 0x10000L) {
  3.2315 +                    ++srcx;
  3.2316 +                    posx -= 0x10000L;
  3.2317 +                }
  3.2318 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.2319 +            }
  3.2320 +            srcpixel = *src;
  3.2321 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.2322 +            dstpixel = *dst;
  3.2323 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.2324 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.2325 +                /* This goes away if we ever use premultiplied alpha */
  3.2326 +                if (srcA < 255) {
  3.2327 +                    srcR = (srcR * srcA) / 255;
  3.2328 +                    srcG = (srcG * srcA) / 255;
  3.2329 +                    srcB = (srcB * srcA) / 255;
  3.2330 +                }
  3.2331 +            }
  3.2332 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.2333 +            case SDL_COPY_MASK:
  3.2334 +                if (srcA) {
  3.2335 +                    dstR = srcR;
  3.2336 +                    dstG = srcG;
  3.2337 +                    dstB = srcB;
  3.2338 +                }
  3.2339 +                break;
  3.2340 +            case SDL_COPY_BLEND:
  3.2341 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.2342 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.2343 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.2344 +                break;
  3.2345 +            case SDL_COPY_ADD:
  3.2346 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.2347 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.2348 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.2349 +                break;
  3.2350 +            case SDL_COPY_MOD:
  3.2351 +                dstR = (srcR * dstR) / 255;
  3.2352 +                dstG = (srcG * dstG) / 255;
  3.2353 +                dstB = (srcB * dstB) / 255;
  3.2354 +                break;
  3.2355 +            }
  3.2356 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.2357 +            *dst = dstpixel;
  3.2358 +            posx += incx;
  3.2359 +            ++dst;
  3.2360 +        }
  3.2361 +        posy += incy;
  3.2362 +        info->dst += info->dst_pitch;
  3.2363 +    }
  3.2364 +}
  3.2365 +
  3.2366 +static void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info)
  3.2367 +{
  3.2368 +    const int flags = info->flags;
  3.2369 +    const Uint32 modulateR = info->r;
  3.2370 +    const Uint32 modulateG = info->g;
  3.2371 +    const Uint32 modulateB = info->b;
  3.2372 +    const Uint32 modulateA = info->a;
  3.2373 +    Uint32 pixel;
  3.2374 +    Uint32 R, G, B, A;
  3.2375 +
  3.2376 +    while (info->dst_h--) {
  3.2377 +        Uint32 *src = (Uint32 *)info->src;
  3.2378 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2379 +        int n = info->dst_w;
  3.2380 +        while (n--) {
  3.2381 +            pixel = *src;
  3.2382 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.2383 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.2384 +                R = (R * modulateR) / 255;
  3.2385 +                G = (G * modulateG) / 255;
  3.2386 +                B = (B * modulateB) / 255;
  3.2387 +            }
  3.2388 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.2389 +                A = (A * modulateA) / 255;
  3.2390 +            }
  3.2391 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.2392 +            *dst = pixel;
  3.2393 +            ++src;
  3.2394 +            ++dst;
  3.2395 +        }
  3.2396 +        info->src += info->src_pitch;
  3.2397 +        info->dst += info->dst_pitch;
  3.2398 +    }
  3.2399 +}
  3.2400 +
  3.2401 +static void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  3.2402 +{
  3.2403 +    const int flags = info->flags;
  3.2404 +    const Uint32 modulateR = info->r;
  3.2405 +    const Uint32 modulateG = info->g;
  3.2406 +    const Uint32 modulateB = info->b;
  3.2407 +    const Uint32 modulateA = info->a;
  3.2408 +    Uint32 pixel;
  3.2409 +    Uint32 R, G, B, A;
  3.2410 +    int srcy, srcx;
  3.2411 +    int posy, posx;
  3.2412 +    int incy, incx;
  3.2413 +
  3.2414 +    srcy = 0;
  3.2415 +    posy = 0;
  3.2416 +    incy = (info->src_h << 16) / info->dst_h;
  3.2417 +    incx = (info->src_w << 16) / info->dst_w;
  3.2418 +
  3.2419 +    while (info->dst_h--) {
  3.2420 +        Uint32 *src;
  3.2421 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2422 +        int n = info->dst_w;
  3.2423 +        srcx = -1;
  3.2424 +        posx = 0x10000L;
  3.2425 +        while (posy >= 0x10000L) {
  3.2426 +            ++srcy;
  3.2427 +            posy -= 0x10000L;
  3.2428 +        }
  3.2429 +        while (n--) {
  3.2430 +            if (posx >= 0x10000L) {
  3.2431 +                while (posx >= 0x10000L) {
  3.2432 +                    ++srcx;
  3.2433 +                    posx -= 0x10000L;
  3.2434 +                }
  3.2435 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.2436 +            }
  3.2437 +            pixel = *src;
  3.2438 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.2439 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.2440 +                R = (R * modulateR) / 255;
  3.2441 +                G = (G * modulateG) / 255;
  3.2442 +                B = (B * modulateB) / 255;
  3.2443 +            }
  3.2444 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.2445 +                A = (A * modulateA) / 255;
  3.2446 +            }
  3.2447 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.2448 +            *dst = pixel;
  3.2449 +            posx += incx;
  3.2450 +            ++dst;
  3.2451 +        }
  3.2452 +        posy += incy;
  3.2453 +        info->dst += info->dst_pitch;
  3.2454 +    }
  3.2455 +}
  3.2456 +
  3.2457 +static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  3.2458 +{
  3.2459 +    const int flags = info->flags;
  3.2460 +    const Uint32 modulateR = info->r;
  3.2461 +    const Uint32 modulateG = info->g;
  3.2462 +    const Uint32 modulateB = info->b;
  3.2463 +    const Uint32 modulateA = info->a;
  3.2464 +    Uint32 srcpixel;
  3.2465 +    Uint32 srcR, srcG, srcB, srcA;
  3.2466 +    Uint32 dstpixel;
  3.2467 +    Uint32 dstR, dstG, dstB, dstA;
  3.2468 +
  3.2469 +    while (info->dst_h--) {
  3.2470 +        Uint32 *src = (Uint32 *)info->src;
  3.2471 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2472 +        int n = info->dst_w;
  3.2473 +        while (n--) {
  3.2474 +            srcpixel = *src;
  3.2475 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.2476 +            dstpixel = *dst;
  3.2477 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.2478 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.2479 +                srcR = (srcR * modulateR) / 255;
  3.2480 +                srcG = (srcG * modulateG) / 255;
  3.2481 +                srcB = (srcB * modulateB) / 255;
  3.2482 +            }
  3.2483 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.2484 +                srcA = (srcA * modulateA) / 255;
  3.2485 +            }
  3.2486 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.2487 +                /* This goes away if we ever use premultiplied alpha */
  3.2488 +                if (srcA < 255) {
  3.2489 +                    srcR = (srcR * srcA) / 255;
  3.2490 +                    srcG = (srcG * srcA) / 255;
  3.2491 +                    srcB = (srcB * srcA) / 255;
  3.2492 +                }
  3.2493 +            }
  3.2494 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.2495 +            case SDL_COPY_MASK:
  3.2496 +                if (srcA) {
  3.2497 +                    dstR = srcR;
  3.2498 +                    dstG = srcG;
  3.2499 +                    dstB = srcB;
  3.2500 +                }
  3.2501 +                break;
  3.2502 +            case SDL_COPY_BLEND:
  3.2503 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.2504 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.2505 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.2506 +                break;
  3.2507 +            case SDL_COPY_ADD:
  3.2508 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.2509 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.2510 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.2511 +                break;
  3.2512 +            case SDL_COPY_MOD:
  3.2513 +                dstR = (srcR * dstR) / 255;
  3.2514 +                dstG = (srcG * dstG) / 255;
  3.2515 +                dstB = (srcB * dstB) / 255;
  3.2516 +                break;
  3.2517 +            }
  3.2518 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.2519 +            *dst = dstpixel;
  3.2520 +            ++src;
  3.2521 +            ++dst;
  3.2522 +        }
  3.2523 +        info->src += info->src_pitch;
  3.2524 +        info->dst += info->dst_pitch;
  3.2525 +    }
  3.2526 +}
  3.2527 +
  3.2528 +static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.2529 +{
  3.2530 +    const int flags = info->flags;
  3.2531 +    const Uint32 modulateR = info->r;
  3.2532 +    const Uint32 modulateG = info->g;
  3.2533 +    const Uint32 modulateB = info->b;
  3.2534 +    const Uint32 modulateA = info->a;
  3.2535 +    Uint32 srcpixel;
  3.2536 +    Uint32 srcR, srcG, srcB, srcA;
  3.2537 +    Uint32 dstpixel;
  3.2538 +    Uint32 dstR, dstG, dstB, dstA;
  3.2539 +    int srcy, srcx;
  3.2540 +    int posy, posx;
  3.2541 +    int incy, incx;
  3.2542 +
  3.2543 +    srcy = 0;
  3.2544 +    posy = 0;
  3.2545 +    incy = (info->src_h << 16) / info->dst_h;
  3.2546 +    incx = (info->src_w << 16) / info->dst_w;
  3.2547 +
  3.2548 +    while (info->dst_h--) {
  3.2549 +        Uint32 *src;
  3.2550 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2551 +        int n = info->dst_w;
  3.2552 +        srcx = -1;
  3.2553 +        posx = 0x10000L;
  3.2554 +        while (posy >= 0x10000L) {
  3.2555 +            ++srcy;
  3.2556 +            posy -= 0x10000L;
  3.2557 +        }
  3.2558 +        while (n--) {
  3.2559 +            if (posx >= 0x10000L) {
  3.2560 +                while (posx >= 0x10000L) {
  3.2561 +                    ++srcx;
  3.2562 +                    posx -= 0x10000L;
  3.2563 +                }
  3.2564 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.2565 +            }
  3.2566 +            srcpixel = *src;
  3.2567 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.2568 +            dstpixel = *dst;
  3.2569 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.2570 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.2571 +                srcR = (srcR * modulateR) / 255;
  3.2572 +                srcG = (srcG * modulateG) / 255;
  3.2573 +                srcB = (srcB * modulateB) / 255;
  3.2574 +            }
  3.2575 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.2576 +                srcA = (srcA * modulateA) / 255;
  3.2577 +            }
  3.2578 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.2579 +                /* This goes away if we ever use premultiplied alpha */
  3.2580 +                if (srcA < 255) {
  3.2581 +                    srcR = (srcR * srcA) / 255;
  3.2582 +                    srcG = (srcG * srcA) / 255;
  3.2583 +                    srcB = (srcB * srcA) / 255;
  3.2584 +                }
  3.2585 +            }
  3.2586 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.2587 +            case SDL_COPY_MASK:
  3.2588 +                if (srcA) {
  3.2589 +                    dstR = srcR;
  3.2590 +                    dstG = srcG;
  3.2591 +                    dstB = srcB;
  3.2592 +                }
  3.2593 +                break;
  3.2594 +            case SDL_COPY_BLEND:
  3.2595 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.2596 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.2597 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.2598 +                break;
  3.2599 +            case SDL_COPY_ADD:
  3.2600 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.2601 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.2602 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.2603 +                break;
  3.2604 +            case SDL_COPY_MOD:
  3.2605 +                dstR = (srcR * dstR) / 255;
  3.2606 +                dstG = (srcG * dstG) / 255;
  3.2607 +                dstB = (srcB * dstB) / 255;
  3.2608 +                break;
  3.2609 +            }
  3.2610 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.2611 +            *dst = dstpixel;
  3.2612 +            posx += incx;
  3.2613 +            ++dst;
  3.2614 +        }
  3.2615 +        posy += incy;
  3.2616 +        info->dst += info->dst_pitch;
  3.2617 +    }
  3.2618 +}
  3.2619 +
  3.2620 +static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info)
  3.2621 +{
  3.2622 +    const int flags = info->flags;
  3.2623 +    Uint32 pixel;
  3.2624 +    Uint32 R, G, B, A;
  3.2625 +    int srcy, srcx;
  3.2626 +    int posy, posx;
  3.2627 +    int incy, incx;
  3.2628 +
  3.2629 +    srcy = 0;
  3.2630 +    posy = 0;
  3.2631 +    incy = (info->src_h << 16) / info->dst_h;
  3.2632 +    incx = (info->src_w << 16) / info->dst_w;
  3.2633 +
  3.2634 +    while (info->dst_h--) {
  3.2635 +        Uint32 *src;
  3.2636 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2637 +        int n = info->dst_w;
  3.2638 +        srcx = -1;
  3.2639 +        posx = 0x10000L;
  3.2640 +        while (posy >= 0x10000L) {
  3.2641 +            ++srcy;
  3.2642 +            posy -= 0x10000L;
  3.2643 +        }
  3.2644 +        while (n--) {
  3.2645 +            if (posx >= 0x10000L) {
  3.2646 +                while (posx >= 0x10000L) {
  3.2647 +                    ++srcx;
  3.2648 +                    posx -= 0x10000L;
  3.2649 +                }
  3.2650 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.2651 +            }
  3.2652 +            pixel = *src;
  3.2653 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.2654 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.2655 +            *dst = pixel;
  3.2656 +            posx += incx;
  3.2657 +            ++dst;
  3.2658 +        }
  3.2659 +        posy += incy;
  3.2660 +        info->dst += info->dst_pitch;
  3.2661 +    }
  3.2662 +}
  3.2663 +
  3.2664 +static void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info)
  3.2665 +{
  3.2666 +    const int flags = info->flags;
  3.2667 +    Uint32 srcpixel;
  3.2668 +    Uint32 srcR, srcG, srcB, srcA;
  3.2669 +    Uint32 dstpixel;
  3.2670 +    Uint32 dstR, dstG, dstB, dstA;
  3.2671 +
  3.2672 +    while (info->dst_h--) {
  3.2673 +        Uint32 *src = (Uint32 *)info->src;
  3.2674 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2675 +        int n = info->dst_w;
  3.2676 +        while (n--) {
  3.2677 +            srcpixel = *src;
  3.2678 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.2679 +            dstpixel = *dst;
  3.2680 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.2681 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.2682 +                /* This goes away if we ever use premultiplied alpha */
  3.2683 +                if (srcA < 255) {
  3.2684 +                    srcR = (srcR * srcA) / 255;
  3.2685 +                    srcG = (srcG * srcA) / 255;
  3.2686 +                    srcB = (srcB * srcA) / 255;
  3.2687 +                }
  3.2688 +            }
  3.2689 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.2690 +            case SDL_COPY_MASK:
  3.2691 +                if (srcA) {
  3.2692 +                    dstR = srcR;
  3.2693 +                    dstG = srcG;
  3.2694 +                    dstB = srcB;
  3.2695 +                }
  3.2696 +                break;
  3.2697 +            case SDL_COPY_BLEND:
  3.2698 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.2699 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.2700 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.2701 +                break;
  3.2702 +            case SDL_COPY_ADD:
  3.2703 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.2704 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.2705 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.2706 +                break;
  3.2707 +            case SDL_COPY_MOD:
  3.2708 +                dstR = (srcR * dstR) / 255;
  3.2709 +                dstG = (srcG * dstG) / 255;
  3.2710 +                dstB = (srcB * dstB) / 255;
  3.2711 +                break;
  3.2712 +            }
  3.2713 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.2714 +            *dst = dstpixel;
  3.2715 +            ++src;
  3.2716 +            ++dst;
  3.2717 +        }
  3.2718 +        info->src += info->src_pitch;
  3.2719 +        info->dst += info->dst_pitch;
  3.2720 +    }
  3.2721 +}
  3.2722 +
  3.2723 +static void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  3.2724 +{
  3.2725 +    const int flags = info->flags;
  3.2726 +    Uint32 srcpixel;
  3.2727 +    Uint32 srcR, srcG, srcB, srcA;
  3.2728 +    Uint32 dstpixel;
  3.2729 +    Uint32 dstR, dstG, dstB, dstA;
  3.2730 +    int srcy, srcx;
  3.2731 +    int posy, posx;
  3.2732 +    int incy, incx;
  3.2733 +
  3.2734 +    srcy = 0;
  3.2735 +    posy = 0;
  3.2736 +    incy = (info->src_h << 16) / info->dst_h;
  3.2737 +    incx = (info->src_w << 16) / info->dst_w;
  3.2738 +
  3.2739 +    while (info->dst_h--) {
  3.2740 +        Uint32 *src;
  3.2741 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2742 +        int n = info->dst_w;
  3.2743 +        srcx = -1;
  3.2744 +        posx = 0x10000L;
  3.2745 +        while (posy >= 0x10000L) {
  3.2746 +            ++srcy;
  3.2747 +            posy -= 0x10000L;
  3.2748 +        }
  3.2749 +        while (n--) {
  3.2750 +            if (posx >= 0x10000L) {
  3.2751 +                while (posx >= 0x10000L) {
  3.2752 +                    ++srcx;
  3.2753 +                    posx -= 0x10000L;
  3.2754 +                }
  3.2755 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.2756 +            }
  3.2757 +            srcpixel = *src;
  3.2758 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.2759 +            dstpixel = *dst;
  3.2760 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.2761 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.2762 +                /* This goes away if we ever use premultiplied alpha */
  3.2763 +                if (srcA < 255) {
  3.2764 +                    srcR = (srcR * srcA) / 255;
  3.2765 +                    srcG = (srcG * srcA) / 255;
  3.2766 +                    srcB = (srcB * srcA) / 255;
  3.2767 +                }
  3.2768 +            }
  3.2769 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.2770 +            case SDL_COPY_MASK:
  3.2771 +                if (srcA) {
  3.2772 +                    dstR = srcR;
  3.2773 +                    dstG = srcG;
  3.2774 +                    dstB = srcB;
  3.2775 +                }
  3.2776 +                break;
  3.2777 +            case SDL_COPY_BLEND:
  3.2778 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.2779 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.2780 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.2781 +                break;
  3.2782 +            case SDL_COPY_ADD:
  3.2783 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.2784 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.2785 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.2786 +                break;
  3.2787 +            case SDL_COPY_MOD:
  3.2788 +                dstR = (srcR * dstR) / 255;
  3.2789 +                dstG = (srcG * dstG) / 255;
  3.2790 +                dstB = (srcB * dstB) / 255;
  3.2791 +                break;
  3.2792 +            }
  3.2793 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.2794 +            *dst = dstpixel;
  3.2795 +            posx += incx;
  3.2796 +            ++dst;
  3.2797 +        }
  3.2798 +        posy += incy;
  3.2799 +        info->dst += info->dst_pitch;
  3.2800 +    }
  3.2801 +}
  3.2802 +
  3.2803 +static void SDL_Blit_RGBA8888_RGB888_Modulate(SDL_BlitInfo *info)
  3.2804 +{
  3.2805 +    const int flags = info->flags;
  3.2806 +    const Uint32 modulateR = info->r;
  3.2807 +    const Uint32 modulateG = info->g;
  3.2808 +    const Uint32 modulateB = info->b;
  3.2809 +    const Uint32 modulateA = info->a;
  3.2810 +    Uint32 pixel;
  3.2811 +    Uint32 R, G, B, A;
  3.2812 +
  3.2813 +    while (info->dst_h--) {
  3.2814 +        Uint32 *src = (Uint32 *)info->src;
  3.2815 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2816 +        int n = info->dst_w;
  3.2817 +        while (n--) {
  3.2818 +            pixel = *src;
  3.2819 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.2820 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.2821 +                R = (R * modulateR) / 255;
  3.2822 +                G = (G * modulateG) / 255;
  3.2823 +                B = (B * modulateB) / 255;
  3.2824 +            }
  3.2825 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.2826 +                A = (A * modulateA) / 255;
  3.2827 +            }
  3.2828 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.2829 +            *dst = pixel;
  3.2830 +            ++src;
  3.2831 +            ++dst;
  3.2832 +        }
  3.2833 +        info->src += info->src_pitch;
  3.2834 +        info->dst += info->dst_pitch;
  3.2835 +    }
  3.2836 +}
  3.2837 +
  3.2838 +static void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  3.2839 +{
  3.2840 +    const int flags = info->flags;
  3.2841 +    const Uint32 modulateR = info->r;
  3.2842 +    const Uint32 modulateG = info->g;
  3.2843 +    const Uint32 modulateB = info->b;
  3.2844 +    const Uint32 modulateA = info->a;
  3.2845 +    Uint32 pixel;
  3.2846 +    Uint32 R, G, B, A;
  3.2847 +    int srcy, srcx;
  3.2848 +    int posy, posx;
  3.2849 +    int incy, incx;
  3.2850 +
  3.2851 +    srcy = 0;
  3.2852 +    posy = 0;
  3.2853 +    incy = (info->src_h << 16) / info->dst_h;
  3.2854 +    incx = (info->src_w << 16) / info->dst_w;
  3.2855 +
  3.2856 +    while (info->dst_h--) {
  3.2857 +        Uint32 *src;
  3.2858 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2859 +        int n = info->dst_w;
  3.2860 +        srcx = -1;
  3.2861 +        posx = 0x10000L;
  3.2862 +        while (posy >= 0x10000L) {
  3.2863 +            ++srcy;
  3.2864 +            posy -= 0x10000L;
  3.2865 +        }
  3.2866 +        while (n--) {
  3.2867 +            if (posx >= 0x10000L) {
  3.2868 +                while (posx >= 0x10000L) {
  3.2869 +                    ++srcx;
  3.2870 +                    posx -= 0x10000L;
  3.2871 +                }
  3.2872 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.2873 +            }
  3.2874 +            pixel = *src;
  3.2875 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.2876 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.2877 +                R = (R * modulateR) / 255;
  3.2878 +                G = (G * modulateG) / 255;
  3.2879 +                B = (B * modulateB) / 255;
  3.2880 +            }
  3.2881 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.2882 +                A = (A * modulateA) / 255;
  3.2883 +            }
  3.2884 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.2885 +            *dst = pixel;
  3.2886 +            posx += incx;
  3.2887 +            ++dst;
  3.2888 +        }
  3.2889 +        posy += incy;
  3.2890 +        info->dst += info->dst_pitch;
  3.2891 +    }
  3.2892 +}
  3.2893 +
  3.2894 +static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  3.2895 +{
  3.2896 +    const int flags = info->flags;
  3.2897 +    const Uint32 modulateR = info->r;
  3.2898 +    const Uint32 modulateG = info->g;
  3.2899 +    const Uint32 modulateB = info->b;
  3.2900 +    const Uint32 modulateA = info->a;
  3.2901 +    Uint32 srcpixel;
  3.2902 +    Uint32 srcR, srcG, srcB, srcA;
  3.2903 +    Uint32 dstpixel;
  3.2904 +    Uint32 dstR, dstG, dstB, dstA;
  3.2905 +
  3.2906 +    while (info->dst_h--) {
  3.2907 +        Uint32 *src = (Uint32 *)info->src;
  3.2908 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2909 +        int n = info->dst_w;
  3.2910 +        while (n--) {
  3.2911 +            srcpixel = *src;
  3.2912 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.2913 +            dstpixel = *dst;
  3.2914 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.2915 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.2916 +                srcR = (srcR * modulateR) / 255;
  3.2917 +                srcG = (srcG * modulateG) / 255;
  3.2918 +                srcB = (srcB * modulateB) / 255;
  3.2919 +            }
  3.2920 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.2921 +                srcA = (srcA * modulateA) / 255;
  3.2922 +            }
  3.2923 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.2924 +                /* This goes away if we ever use premultiplied alpha */
  3.2925 +                if (srcA < 255) {
  3.2926 +                    srcR = (srcR * srcA) / 255;
  3.2927 +                    srcG = (srcG * srcA) / 255;
  3.2928 +                    srcB = (srcB * srcA) / 255;
  3.2929 +                }
  3.2930 +            }
  3.2931 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.2932 +            case SDL_COPY_MASK:
  3.2933 +                if (srcA) {
  3.2934 +                    dstR = srcR;
  3.2935 +                    dstG = srcG;
  3.2936 +                    dstB = srcB;
  3.2937 +                }
  3.2938 +                break;
  3.2939 +            case SDL_COPY_BLEND:
  3.2940 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.2941 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.2942 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.2943 +                break;
  3.2944 +            case SDL_COPY_ADD:
  3.2945 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.2946 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.2947 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.2948 +                break;
  3.2949 +            case SDL_COPY_MOD:
  3.2950 +                dstR = (srcR * dstR) / 255;
  3.2951 +                dstG = (srcG * dstG) / 255;
  3.2952 +                dstB = (srcB * dstB) / 255;
  3.2953 +                break;
  3.2954 +            }
  3.2955 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.2956 +            *dst = dstpixel;
  3.2957 +            ++src;
  3.2958 +            ++dst;
  3.2959 +        }
  3.2960 +        info->src += info->src_pitch;
  3.2961 +        info->dst += info->dst_pitch;
  3.2962 +    }
  3.2963 +}
  3.2964 +
  3.2965 +static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.2966 +{
  3.2967 +    const int flags = info->flags;
  3.2968 +    const Uint32 modulateR = info->r;
  3.2969 +    const Uint32 modulateG = info->g;
  3.2970 +    const Uint32 modulateB = info->b;
  3.2971 +    const Uint32 modulateA = info->a;
  3.2972 +    Uint32 srcpixel;
  3.2973 +    Uint32 srcR, srcG, srcB, srcA;
  3.2974 +    Uint32 dstpixel;
  3.2975 +    Uint32 dstR, dstG, dstB, dstA;
  3.2976 +    int srcy, srcx;
  3.2977 +    int posy, posx;
  3.2978 +    int incy, incx;
  3.2979 +
  3.2980 +    srcy = 0;
  3.2981 +    posy = 0;
  3.2982 +    incy = (info->src_h << 16) / info->dst_h;
  3.2983 +    incx = (info->src_w << 16) / info->dst_w;
  3.2984 +
  3.2985 +    while (info->dst_h--) {
  3.2986 +        Uint32 *src;
  3.2987 +        Uint32 *dst = (Uint32 *)info->dst;
  3.2988 +        int n = info->dst_w;
  3.2989 +        srcx = -1;
  3.2990 +        posx = 0x10000L;
  3.2991 +        while (posy >= 0x10000L) {
  3.2992 +            ++srcy;
  3.2993 +            posy -= 0x10000L;
  3.2994 +        }
  3.2995 +        while (n--) {
  3.2996 +            if (posx >= 0x10000L) {
  3.2997 +                while (posx >= 0x10000L) {
  3.2998 +                    ++srcx;
  3.2999 +                    posx -= 0x10000L;
  3.3000 +                }
  3.3001 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.3002 +            }
  3.3003 +            srcpixel = *src;
  3.3004 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.3005 +            dstpixel = *dst;
  3.3006 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.3007 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.3008 +                srcR = (srcR * modulateR) / 255;
  3.3009 +                srcG = (srcG * modulateG) / 255;
  3.3010 +                srcB = (srcB * modulateB) / 255;
  3.3011 +            }
  3.3012 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.3013 +                srcA = (srcA * modulateA) / 255;
  3.3014 +            }
  3.3015 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.3016 +                /* This goes away if we ever use premultiplied alpha */
  3.3017 +                if (srcA < 255) {
  3.3018 +                    srcR = (srcR * srcA) / 255;
  3.3019 +                    srcG = (srcG * srcA) / 255;
  3.3020 +                    srcB = (srcB * srcA) / 255;
  3.3021 +                }
  3.3022 +            }
  3.3023 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.3024 +            case SDL_COPY_MASK:
  3.3025 +                if (srcA) {
  3.3026 +                    dstR = srcR;
  3.3027 +                    dstG = srcG;
  3.3028 +                    dstB = srcB;
  3.3029 +                }
  3.3030 +                break;
  3.3031 +            case SDL_COPY_BLEND:
  3.3032 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.3033 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.3034 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.3035 +                break;
  3.3036 +            case SDL_COPY_ADD:
  3.3037 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.3038 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.3039 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.3040 +                break;
  3.3041 +            case SDL_COPY_MOD:
  3.3042 +                dstR = (srcR * dstR) / 255;
  3.3043 +                dstG = (srcG * dstG) / 255;
  3.3044 +                dstB = (srcB * dstB) / 255;
  3.3045 +                break;
  3.3046 +            }
  3.3047 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.3048 +            *dst = dstpixel;
  3.3049 +            posx += incx;
  3.3050 +            ++dst;
  3.3051 +        }
  3.3052 +        posy += incy;
  3.3053 +        info->dst += info->dst_pitch;
  3.3054 +    }
  3.3055 +}
  3.3056 +
  3.3057 +static void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info)
  3.3058 +{
  3.3059 +    const int flags = info->flags;
  3.3060 +    Uint32 pixel;
  3.3061 +    Uint32 R, G, B, A;
  3.3062 +    int srcy, srcx;
  3.3063 +    int posy, posx;
  3.3064 +    int incy, incx;
  3.3065 +
  3.3066 +    srcy = 0;
  3.3067 +    posy = 0;
  3.3068 +    incy = (info->src_h << 16) / info->dst_h;
  3.3069 +    incx = (info->src_w << 16) / info->dst_w;
  3.3070 +
  3.3071 +    while (info->dst_h--) {
  3.3072 +        Uint32 *src;
  3.3073 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3074 +        int n = info->dst_w;
  3.3075 +        srcx = -1;
  3.3076 +        posx = 0x10000L;
  3.3077 +        while (posy >= 0x10000L) {
  3.3078 +            ++srcy;
  3.3079 +            posy -= 0x10000L;
  3.3080 +        }
  3.3081 +        while (n--) {
  3.3082 +            if (posx >= 0x10000L) {
  3.3083 +                while (posx >= 0x10000L) {
  3.3084 +                    ++srcx;
  3.3085 +                    posx -= 0x10000L;
  3.3086 +                }
  3.3087 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.3088 +            }
  3.3089 +            pixel = *src;
  3.3090 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.3091 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.3092 +            *dst = pixel;
  3.3093 +            posx += incx;
  3.3094 +            ++dst;
  3.3095 +        }
  3.3096 +        posy += incy;
  3.3097 +        info->dst += info->dst_pitch;
  3.3098 +    }
  3.3099 +}
  3.3100 +
  3.3101 +static void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info)
  3.3102 +{
  3.3103 +    const int flags = info->flags;
  3.3104 +    Uint32 srcpixel;
  3.3105 +    Uint32 srcR, srcG, srcB, srcA;
  3.3106 +    Uint32 dstpixel;
  3.3107 +    Uint32 dstR, dstG, dstB, dstA;
  3.3108 +
  3.3109 +    while (info->dst_h--) {
  3.3110 +        Uint32 *src = (Uint32 *)info->src;
  3.3111 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3112 +        int n = info->dst_w;
  3.3113 +        while (n--) {
  3.3114 +            srcpixel = *src;
  3.3115 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.3116 +            dstpixel = *dst;
  3.3117 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.3118 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.3119 +                /* This goes away if we ever use premultiplied alpha */
  3.3120 +                if (srcA < 255) {
  3.3121 +                    srcR = (srcR * srcA) / 255;
  3.3122 +                    srcG = (srcG * srcA) / 255;
  3.3123 +                    srcB = (srcB * srcA) / 255;
  3.3124 +                }
  3.3125 +            }
  3.3126 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.3127 +            case SDL_COPY_MASK:
  3.3128 +                if (srcA) {
  3.3129 +                    dstR = srcR;
  3.3130 +                    dstG = srcG;
  3.3131 +                    dstB = srcB;
  3.3132 +                }
  3.3133 +                break;
  3.3134 +            case SDL_COPY_BLEND:
  3.3135 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.3136 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.3137 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.3138 +                break;
  3.3139 +            case SDL_COPY_ADD:
  3.3140 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.3141 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.3142 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.3143 +                break;
  3.3144 +            case SDL_COPY_MOD:
  3.3145 +                dstR = (srcR * dstR) / 255;
  3.3146 +                dstG = (srcG * dstG) / 255;
  3.3147 +                dstB = (srcB * dstB) / 255;
  3.3148 +                break;
  3.3149 +            }
  3.3150 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.3151 +            *dst = dstpixel;
  3.3152 +            ++src;
  3.3153 +            ++dst;
  3.3154 +        }
  3.3155 +        info->src += info->src_pitch;
  3.3156 +        info->dst += info->dst_pitch;
  3.3157 +    }
  3.3158 +}
  3.3159 +
  3.3160 +static void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  3.3161 +{
  3.3162 +    const int flags = info->flags;
  3.3163 +    Uint32 srcpixel;
  3.3164 +    Uint32 srcR, srcG, srcB, srcA;
  3.3165 +    Uint32 dstpixel;
  3.3166 +    Uint32 dstR, dstG, dstB, dstA;
  3.3167 +    int srcy, srcx;
  3.3168 +    int posy, posx;
  3.3169 +    int incy, incx;
  3.3170 +
  3.3171 +    srcy = 0;
  3.3172 +    posy = 0;
  3.3173 +    incy = (info->src_h << 16) / info->dst_h;
  3.3174 +    incx = (info->src_w << 16) / info->dst_w;
  3.3175 +
  3.3176 +    while (info->dst_h--) {
  3.3177 +        Uint32 *src;
  3.3178 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3179 +        int n = info->dst_w;
  3.3180 +        srcx = -1;
  3.3181 +        posx = 0x10000L;
  3.3182 +        while (posy >= 0x10000L) {
  3.3183 +            ++srcy;
  3.3184 +            posy -= 0x10000L;
  3.3185 +        }
  3.3186 +        while (n--) {
  3.3187 +            if (posx >= 0x10000L) {
  3.3188 +                while (posx >= 0x10000L) {
  3.3189 +                    ++srcx;
  3.3190 +                    posx -= 0x10000L;
  3.3191 +                }
  3.3192 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.3193 +            }
  3.3194 +            srcpixel = *src;
  3.3195 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.3196 +            dstpixel = *dst;
  3.3197 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.3198 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.3199 +                /* This goes away if we ever use premultiplied alpha */
  3.3200 +                if (srcA < 255) {
  3.3201 +                    srcR = (srcR * srcA) / 255;
  3.3202 +                    srcG = (srcG * srcA) / 255;
  3.3203 +                    srcB = (srcB * srcA) / 255;
  3.3204 +                }
  3.3205 +            }
  3.3206 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.3207 +            case SDL_COPY_MASK:
  3.3208 +                if (srcA) {
  3.3209 +                    dstR = srcR;
  3.3210 +                    dstG = srcG;
  3.3211 +                    dstB = srcB;
  3.3212 +                }
  3.3213 +                break;
  3.3214 +            case SDL_COPY_BLEND:
  3.3215 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.3216 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.3217 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.3218 +                break;
  3.3219 +            case SDL_COPY_ADD:
  3.3220 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.3221 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.3222 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.3223 +                break;
  3.3224 +            case SDL_COPY_MOD:
  3.3225 +                dstR = (srcR * dstR) / 255;
  3.3226 +                dstG = (srcG * dstG) / 255;
  3.3227 +                dstB = (srcB * dstB) / 255;
  3.3228 +                break;
  3.3229 +            }
  3.3230 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.3231 +            *dst = dstpixel;
  3.3232 +            posx += incx;
  3.3233 +            ++dst;
  3.3234 +        }
  3.3235 +        posy += incy;
  3.3236 +        info->dst += info->dst_pitch;
  3.3237 +    }
  3.3238 +}
  3.3239 +
  3.3240 +static void SDL_Blit_RGBA8888_BGR888_Modulate(SDL_BlitInfo *info)
  3.3241 +{
  3.3242 +    const int flags = info->flags;
  3.3243 +    const Uint32 modulateR = info->r;
  3.3244 +    const Uint32 modulateG = info->g;
  3.3245 +    const Uint32 modulateB = info->b;
  3.3246 +    const Uint32 modulateA = info->a;
  3.3247 +    Uint32 pixel;
  3.3248 +    Uint32 R, G, B, A;
  3.3249 +
  3.3250 +    while (info->dst_h--) {
  3.3251 +        Uint32 *src = (Uint32 *)info->src;
  3.3252 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3253 +        int n = info->dst_w;
  3.3254 +        while (n--) {
  3.3255 +            pixel = *src;
  3.3256 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.3257 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.3258 +                R = (R * modulateR) / 255;
  3.3259 +                G = (G * modulateG) / 255;
  3.3260 +                B = (B * modulateB) / 255;
  3.3261 +            }
  3.3262 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.3263 +                A = (A * modulateA) / 255;
  3.3264 +            }
  3.3265 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.3266 +            *dst = pixel;
  3.3267 +            ++src;
  3.3268 +            ++dst;
  3.3269 +        }
  3.3270 +        info->src += info->src_pitch;
  3.3271 +        info->dst += info->dst_pitch;
  3.3272 +    }
  3.3273 +}
  3.3274 +
  3.3275 +static void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  3.3276 +{
  3.3277 +    const int flags = info->flags;
  3.3278 +    const Uint32 modulateR = info->r;
  3.3279 +    const Uint32 modulateG = info->g;
  3.3280 +    const Uint32 modulateB = info->b;
  3.3281 +    const Uint32 modulateA = info->a;
  3.3282 +    Uint32 pixel;
  3.3283 +    Uint32 R, G, B, A;
  3.3284 +    int srcy, srcx;
  3.3285 +    int posy, posx;
  3.3286 +    int incy, incx;
  3.3287 +
  3.3288 +    srcy = 0;
  3.3289 +    posy = 0;
  3.3290 +    incy = (info->src_h << 16) / info->dst_h;
  3.3291 +    incx = (info->src_w << 16) / info->dst_w;
  3.3292 +
  3.3293 +    while (info->dst_h--) {
  3.3294 +        Uint32 *src;
  3.3295 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3296 +        int n = info->dst_w;
  3.3297 +        srcx = -1;
  3.3298 +        posx = 0x10000L;
  3.3299 +        while (posy >= 0x10000L) {
  3.3300 +            ++srcy;
  3.3301 +            posy -= 0x10000L;
  3.3302 +        }
  3.3303 +        while (n--) {
  3.3304 +            if (posx >= 0x10000L) {
  3.3305 +                while (posx >= 0x10000L) {
  3.3306 +                    ++srcx;
  3.3307 +                    posx -= 0x10000L;
  3.3308 +                }
  3.3309 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.3310 +            }
  3.3311 +            pixel = *src;
  3.3312 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.3313 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.3314 +                R = (R * modulateR) / 255;
  3.3315 +                G = (G * modulateG) / 255;
  3.3316 +                B = (B * modulateB) / 255;
  3.3317 +            }
  3.3318 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.3319 +                A = (A * modulateA) / 255;
  3.3320 +            }
  3.3321 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.3322 +            *dst = pixel;
  3.3323 +            posx += incx;
  3.3324 +            ++dst;
  3.3325 +        }
  3.3326 +        posy += incy;
  3.3327 +        info->dst += info->dst_pitch;
  3.3328 +    }
  3.3329 +}
  3.3330 +
  3.3331 +static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  3.3332 +{
  3.3333 +    const int flags = info->flags;
  3.3334 +    const Uint32 modulateR = info->r;
  3.3335 +    const Uint32 modulateG = info->g;
  3.3336 +    const Uint32 modulateB = info->b;
  3.3337 +    const Uint32 modulateA = info->a;
  3.3338 +    Uint32 srcpixel;
  3.3339 +    Uint32 srcR, srcG, srcB, srcA;
  3.3340 +    Uint32 dstpixel;
  3.3341 +    Uint32 dstR, dstG, dstB, dstA;
  3.3342 +
  3.3343 +    while (info->dst_h--) {
  3.3344 +        Uint32 *src = (Uint32 *)info->src;
  3.3345 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3346 +        int n = info->dst_w;
  3.3347 +        while (n--) {
  3.3348 +            srcpixel = *src;
  3.3349 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.3350 +            dstpixel = *dst;
  3.3351 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.3352 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.3353 +                srcR = (srcR * modulateR) / 255;
  3.3354 +                srcG = (srcG * modulateG) / 255;
  3.3355 +                srcB = (srcB * modulateB) / 255;
  3.3356 +            }
  3.3357 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.3358 +                srcA = (srcA * modulateA) / 255;
  3.3359 +            }
  3.3360 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.3361 +                /* This goes away if we ever use premultiplied alpha */
  3.3362 +                if (srcA < 255) {
  3.3363 +                    srcR = (srcR * srcA) / 255;
  3.3364 +                    srcG = (srcG * srcA) / 255;
  3.3365 +                    srcB = (srcB * srcA) / 255;
  3.3366 +                }
  3.3367 +            }
  3.3368 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.3369 +            case SDL_COPY_MASK:
  3.3370 +                if (srcA) {
  3.3371 +                    dstR = srcR;
  3.3372 +                    dstG = srcG;
  3.3373 +                    dstB = srcB;
  3.3374 +                }
  3.3375 +                break;
  3.3376 +            case SDL_COPY_BLEND:
  3.3377 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.3378 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.3379 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.3380 +                break;
  3.3381 +            case SDL_COPY_ADD:
  3.3382 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.3383 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.3384 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.3385 +                break;
  3.3386 +            case SDL_COPY_MOD:
  3.3387 +                dstR = (srcR * dstR) / 255;
  3.3388 +                dstG = (srcG * dstG) / 255;
  3.3389 +                dstB = (srcB * dstB) / 255;
  3.3390 +                break;
  3.3391 +            }
  3.3392 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.3393 +            *dst = dstpixel;
  3.3394 +            ++src;
  3.3395 +            ++dst;
  3.3396 +        }
  3.3397 +        info->src += info->src_pitch;
  3.3398 +        info->dst += info->dst_pitch;
  3.3399 +    }
  3.3400 +}
  3.3401 +
  3.3402 +static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.3403 +{
  3.3404 +    const int flags = info->flags;
  3.3405 +    const Uint32 modulateR = info->r;
  3.3406 +    const Uint32 modulateG = info->g;
  3.3407 +    const Uint32 modulateB = info->b;
  3.3408 +    const Uint32 modulateA = info->a;
  3.3409 +    Uint32 srcpixel;
  3.3410 +    Uint32 srcR, srcG, srcB, srcA;
  3.3411 +    Uint32 dstpixel;
  3.3412 +    Uint32 dstR, dstG, dstB, dstA;
  3.3413 +    int srcy, srcx;
  3.3414 +    int posy, posx;
  3.3415 +    int incy, incx;
  3.3416 +
  3.3417 +    srcy = 0;
  3.3418 +    posy = 0;
  3.3419 +    incy = (info->src_h << 16) / info->dst_h;
  3.3420 +    incx = (info->src_w << 16) / info->dst_w;
  3.3421 +
  3.3422 +    while (info->dst_h--) {
  3.3423 +        Uint32 *src;
  3.3424 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3425 +        int n = info->dst_w;
  3.3426 +        srcx = -1;
  3.3427 +        posx = 0x10000L;
  3.3428 +        while (posy >= 0x10000L) {
  3.3429 +            ++srcy;
  3.3430 +            posy -= 0x10000L;
  3.3431 +        }
  3.3432 +        while (n--) {
  3.3433 +            if (posx >= 0x10000L) {
  3.3434 +                while (posx >= 0x10000L) {
  3.3435 +                    ++srcx;
  3.3436 +                    posx -= 0x10000L;
  3.3437 +                }
  3.3438 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.3439 +            }
  3.3440 +            srcpixel = *src;
  3.3441 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.3442 +            dstpixel = *dst;
  3.3443 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.3444 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.3445 +                srcR = (srcR * modulateR) / 255;
  3.3446 +                srcG = (srcG * modulateG) / 255;
  3.3447 +                srcB = (srcB * modulateB) / 255;
  3.3448 +            }
  3.3449 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.3450 +                srcA = (srcA * modulateA) / 255;
  3.3451 +            }
  3.3452 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.3453 +                /* This goes away if we ever use premultiplied alpha */
  3.3454 +                if (srcA < 255) {
  3.3455 +                    srcR = (srcR * srcA) / 255;
  3.3456 +                    srcG = (srcG * srcA) / 255;
  3.3457 +                    srcB = (srcB * srcA) / 255;
  3.3458 +                }
  3.3459 +            }
  3.3460 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.3461 +            case SDL_COPY_MASK:
  3.3462 +                if (srcA) {
  3.3463 +                    dstR = srcR;
  3.3464 +                    dstG = srcG;
  3.3465 +                    dstB = srcB;
  3.3466 +                }
  3.3467 +                break;
  3.3468 +            case SDL_COPY_BLEND:
  3.3469 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.3470 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.3471 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.3472 +                break;
  3.3473 +            case SDL_COPY_ADD:
  3.3474 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.3475 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.3476 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.3477 +                break;
  3.3478 +            case SDL_COPY_MOD:
  3.3479 +                dstR = (srcR * dstR) / 255;
  3.3480 +                dstG = (srcG * dstG) / 255;
  3.3481 +                dstB = (srcB * dstB) / 255;
  3.3482 +                break;
  3.3483 +            }
  3.3484 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.3485 +            *dst = dstpixel;
  3.3486 +            posx += incx;
  3.3487 +            ++dst;
  3.3488 +        }
  3.3489 +        posy += incy;
  3.3490 +        info->dst += info->dst_pitch;
  3.3491 +    }
  3.3492 +}
  3.3493 +
  3.3494 +static void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info)
  3.3495 +{
  3.3496 +    const int flags = info->flags;
  3.3497 +    Uint32 pixel;
  3.3498 +    Uint32 R, G, B, A;
  3.3499 +    int srcy, srcx;
  3.3500 +    int posy, posx;
  3.3501 +    int incy, incx;
  3.3502 +
  3.3503 +    srcy = 0;
  3.3504 +    posy = 0;
  3.3505 +    incy = (info->src_h << 16) / info->dst_h;
  3.3506 +    incx = (info->src_w << 16) / info->dst_w;
  3.3507 +
  3.3508 +    while (info->dst_h--) {
  3.3509 +        Uint32 *src;
  3.3510 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3511 +        int n = info->dst_w;
  3.3512 +        srcx = -1;
  3.3513 +        posx = 0x10000L;
  3.3514 +        while (posy >= 0x10000L) {
  3.3515 +            ++srcy;
  3.3516 +            posy -= 0x10000L;
  3.3517 +        }
  3.3518 +        while (n--) {
  3.3519 +            if (posx >= 0x10000L) {
  3.3520 +                while (posx >= 0x10000L) {
  3.3521 +                    ++srcx;
  3.3522 +                    posx -= 0x10000L;
  3.3523 +                }
  3.3524 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.3525 +            }
  3.3526 +            pixel = *src;
  3.3527 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  3.3528 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.3529 +            *dst = pixel;
  3.3530 +            posx += incx;
  3.3531 +            ++dst;
  3.3532 +        }
  3.3533 +        posy += incy;
  3.3534 +        info->dst += info->dst_pitch;
  3.3535 +    }
  3.3536 +}
  3.3537 +
  3.3538 +static void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info)
  3.3539 +{
  3.3540 +    const int flags = info->flags;
  3.3541 +    Uint32 srcpixel;
  3.3542 +    Uint32 srcR, srcG, srcB, srcA;
  3.3543 +    Uint32 dstpixel;
  3.3544 +    Uint32 dstR, dstG, dstB, dstA;
  3.3545 +
  3.3546 +    while (info->dst_h--) {
  3.3547 +        Uint32 *src = (Uint32 *)info->src;
  3.3548 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3549 +        int n = info->dst_w;
  3.3550 +        while (n--) {
  3.3551 +            srcpixel = *src;
  3.3552 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3.3553 +            dstpixel = *dst;
  3.3554 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.3555 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.3556 +                /* This goes away if we ever use premultiplied alpha */
  3.3557 +                if (srcA < 255) {
  3.3558 +                    srcR = (srcR * srcA) / 255;
  3.3559 +                    srcG = (srcG * srcA) / 255;
  3.3560 +                    srcB = (srcB * srcA) / 255;
  3.3561 +                }
  3.3562 +            }
  3.3563 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.3564 +            case SDL_COPY_MASK:
  3.3565 +                if (srcA) {
  3.3566 +                    dstR = srcR;
  3.3567 +                    dstG = srcG;
  3.3568 +                    dstB = srcB;
  3.3569 +                }
  3.3570 +                break;
  3.3571 +            case SDL_COPY_BLEND:
  3.3572 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.3573 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.3574 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.3575 +                break;
  3.3576 +            case SDL_COPY_ADD:
  3.3577 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.3578 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.3579 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.3580 +                break;
  3.3581 +            case SDL_COPY_MOD:
  3.3582 +                dstR = (srcR * dstR) / 255;
  3.3583 +                dstG = (srcG * dstG) / 255;
  3.3584 +                dstB = (srcB * dstB) / 255;
  3.3585 +                break;
  3.3586 +            }
  3.3587 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.3588 +            *dst = dstpixel;
  3.3589 +            ++src;
  3.3590 +            ++dst;
  3.3591 +        }
  3.3592 +        info->src += info->src_pitch;
  3.3593 +        info->dst += info->dst_pitch;
  3.3594 +    }
  3.3595 +}
  3.3596 +
  3.3597 +static void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  3.3598 +{
  3.3599 +    const int flags = info->flags;
  3.3600 +    Uint32 srcpixel;
  3.3601 +    Uint32 srcR, srcG, srcB, srcA;
  3.3602 +    Uint32 dstpixel;
  3.3603 +    Uint32 dstR, dstG, dstB, dstA;
  3.3604 +    int srcy, srcx;
  3.3605 +    int posy, posx;
  3.3606 +    int incy, incx;
  3.3607 +
  3.3608 +    srcy = 0;
  3.3609 +    posy = 0;
  3.3610 +    incy = (info->src_h << 16) / info->dst_h;
  3.3611 +    incx = (info->src_w << 16) / info->dst_w;
  3.3612 +
  3.3613 +    while (info->dst_h--) {
  3.3614 +        Uint32 *src;
  3.3615 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3616 +        int n = info->dst_w;
  3.3617 +        srcx = -1;
  3.3618 +        posx = 0x10000L;
  3.3619 +        while (posy >= 0x10000L) {
  3.3620 +            ++srcy;
  3.3621 +            posy -= 0x10000L;
  3.3622 +        }
  3.3623 +        while (n--) {
  3.3624 +            if (posx >= 0x10000L) {
  3.3625 +                while (posx >= 0x10000L) {
  3.3626 +                    ++srcx;
  3.3627 +                    posx -= 0x10000L;
  3.3628 +                }
  3.3629 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.3630 +            }
  3.3631 +            srcpixel = *src;
  3.3632 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3.3633 +            dstpixel = *dst;
  3.3634 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.3635 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.3636 +                /* This goes away if we ever use premultiplied alpha */
  3.3637 +                if (srcA < 255) {
  3.3638 +                    srcR = (srcR * srcA) / 255;
  3.3639 +                    srcG = (srcG * srcA) / 255;
  3.3640 +                    srcB = (srcB * srcA) / 255;
  3.3641 +                }
  3.3642 +            }
  3.3643 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.3644 +            case SDL_COPY_MASK:
  3.3645 +                if (srcA) {
  3.3646 +                    dstR = srcR;
  3.3647 +                    dstG = srcG;
  3.3648 +                    dstB = srcB;
  3.3649 +                }
  3.3650 +                break;
  3.3651 +            case SDL_COPY_BLEND:
  3.3652 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.3653 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.3654 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.3655 +                break;
  3.3656 +            case SDL_COPY_ADD:
  3.3657 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.3658 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.3659 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.3660 +                break;
  3.3661 +            case SDL_COPY_MOD:
  3.3662 +                dstR = (srcR * dstR) / 255;
  3.3663 +                dstG = (srcG * dstG) / 255;
  3.3664 +                dstB = (srcB * dstB) / 255;
  3.3665 +                break;
  3.3666 +            }
  3.3667 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.3668 +            *dst = dstpixel;
  3.3669 +            posx += incx;
  3.3670 +            ++dst;
  3.3671 +        }
  3.3672 +        posy += incy;
  3.3673 +        info->dst += info->dst_pitch;
  3.3674 +    }
  3.3675 +}
  3.3676 +
  3.3677 +static void SDL_Blit_ABGR8888_RGB888_Modulate(SDL_BlitInfo *info)
  3.3678 +{
  3.3679 +    const int flags = info->flags;
  3.3680 +    const Uint32 modulateR = info->r;
  3.3681 +    const Uint32 modulateG = info->g;
  3.3682 +    const Uint32 modulateB = info->b;
  3.3683 +    const Uint32 modulateA = info->a;
  3.3684 +    Uint32 pixel;
  3.3685 +    Uint32 R, G, B, A;
  3.3686 +
  3.3687 +    while (info->dst_h--) {
  3.3688 +        Uint32 *src = (Uint32 *)info->src;
  3.3689 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3690 +        int n = info->dst_w;
  3.3691 +        while (n--) {
  3.3692 +            pixel = *src;
  3.3693 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  3.3694 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.3695 +                R = (R * modulateR) / 255;
  3.3696 +                G = (G * modulateG) / 255;
  3.3697 +                B = (B * modulateB) / 255;
  3.3698 +            }
  3.3699 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.3700 +                A = (A * modulateA) / 255;
  3.3701 +            }
  3.3702 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.3703 +            *dst = pixel;
  3.3704 +            ++src;
  3.3705 +            ++dst;
  3.3706 +        }
  3.3707 +        info->src += info->src_pitch;
  3.3708 +        info->dst += info->dst_pitch;
  3.3709 +    }
  3.3710 +}
  3.3711 +
  3.3712 +static void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  3.3713 +{
  3.3714 +    const int flags = info->flags;
  3.3715 +    const Uint32 modulateR = info->r;
  3.3716 +    const Uint32 modulateG = info->g;
  3.3717 +    const Uint32 modulateB = info->b;
  3.3718 +    const Uint32 modulateA = info->a;
  3.3719 +    Uint32 pixel;
  3.3720 +    Uint32 R, G, B, A;
  3.3721 +    int srcy, srcx;
  3.3722 +    int posy, posx;
  3.3723 +    int incy, incx;
  3.3724 +
  3.3725 +    srcy = 0;
  3.3726 +    posy = 0;
  3.3727 +    incy = (info->src_h << 16) / info->dst_h;
  3.3728 +    incx = (info->src_w << 16) / info->dst_w;
  3.3729 +
  3.3730 +    while (info->dst_h--) {
  3.3731 +        Uint32 *src;
  3.3732 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3733 +        int n = info->dst_w;
  3.3734 +        srcx = -1;
  3.3735 +        posx = 0x10000L;
  3.3736 +        while (posy >= 0x10000L) {
  3.3737 +            ++srcy;
  3.3738 +            posy -= 0x10000L;
  3.3739 +        }
  3.3740 +        while (n--) {
  3.3741 +            if (posx >= 0x10000L) {
  3.3742 +                while (posx >= 0x10000L) {
  3.3743 +                    ++srcx;
  3.3744 +                    posx -= 0x10000L;
  3.3745 +                }
  3.3746 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.3747 +            }
  3.3748 +            pixel = *src;
  3.3749 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  3.3750 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.3751 +                R = (R * modulateR) / 255;
  3.3752 +                G = (G * modulateG) / 255;
  3.3753 +                B = (B * modulateB) / 255;
  3.3754 +            }
  3.3755 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.3756 +                A = (A * modulateA) / 255;
  3.3757 +            }
  3.3758 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.3759 +            *dst = pixel;
  3.3760 +            posx += incx;
  3.3761 +            ++dst;
  3.3762 +        }
  3.3763 +        posy += incy;
  3.3764 +        info->dst += info->dst_pitch;
  3.3765 +    }
  3.3766 +}
  3.3767 +
  3.3768 +static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  3.3769 +{
  3.3770 +    const int flags = info->flags;
  3.3771 +    const Uint32 modulateR = info->r;
  3.3772 +    const Uint32 modulateG = info->g;
  3.3773 +    const Uint32 modulateB = info->b;
  3.3774 +    const Uint32 modulateA = info->a;
  3.3775 +    Uint32 srcpixel;
  3.3776 +    Uint32 srcR, srcG, srcB, srcA;
  3.3777 +    Uint32 dstpixel;
  3.3778 +    Uint32 dstR, dstG, dstB, dstA;
  3.3779 +
  3.3780 +    while (info->dst_h--) {
  3.3781 +        Uint32 *src = (Uint32 *)info->src;
  3.3782 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3783 +        int n = info->dst_w;
  3.3784 +        while (n--) {
  3.3785 +            srcpixel = *src;
  3.3786 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3.3787 +            dstpixel = *dst;
  3.3788 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.3789 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.3790 +                srcR = (srcR * modulateR) / 255;
  3.3791 +                srcG = (srcG * modulateG) / 255;
  3.3792 +                srcB = (srcB * modulateB) / 255;
  3.3793 +            }
  3.3794 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.3795 +                srcA = (srcA * modulateA) / 255;
  3.3796 +            }
  3.3797 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.3798 +                /* This goes away if we ever use premultiplied alpha */
  3.3799 +                if (srcA < 255) {
  3.3800 +                    srcR = (srcR * srcA) / 255;
  3.3801 +                    srcG = (srcG * srcA) / 255;
  3.3802 +                    srcB = (srcB * srcA) / 255;
  3.3803 +                }
  3.3804 +            }
  3.3805 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.3806 +            case SDL_COPY_MASK:
  3.3807 +                if (srcA) {
  3.3808 +                    dstR = srcR;
  3.3809 +                    dstG = srcG;
  3.3810 +                    dstB = srcB;
  3.3811 +                }
  3.3812 +                break;
  3.3813 +            case SDL_COPY_BLEND:
  3.3814 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.3815 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.3816 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.3817 +                break;
  3.3818 +            case SDL_COPY_ADD:
  3.3819 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.3820 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.3821 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.3822 +                break;
  3.3823 +            case SDL_COPY_MOD:
  3.3824 +                dstR = (srcR * dstR) / 255;
  3.3825 +                dstG = (srcG * dstG) / 255;
  3.3826 +                dstB = (srcB * dstB) / 255;
  3.3827 +                break;
  3.3828 +            }
  3.3829 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.3830 +            *dst = dstpixel;
  3.3831 +            ++src;
  3.3832 +            ++dst;
  3.3833 +        }
  3.3834 +        info->src += info->src_pitch;
  3.3835 +        info->dst += info->dst_pitch;
  3.3836 +    }
  3.3837 +}
  3.3838 +
  3.3839 +static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.3840 +{
  3.3841 +    const int flags = info->flags;
  3.3842 +    const Uint32 modulateR = info->r;
  3.3843 +    const Uint32 modulateG = info->g;
  3.3844 +    const Uint32 modulateB = info->b;
  3.3845 +    const Uint32 modulateA = info->a;
  3.3846 +    Uint32 srcpixel;
  3.3847 +    Uint32 srcR, srcG, srcB, srcA;
  3.3848 +    Uint32 dstpixel;
  3.3849 +    Uint32 dstR, dstG, dstB, dstA;
  3.3850 +    int srcy, srcx;
  3.3851 +    int posy, posx;
  3.3852 +    int incy, incx;
  3.3853 +
  3.3854 +    srcy = 0;
  3.3855 +    posy = 0;
  3.3856 +    incy = (info->src_h << 16) / info->dst_h;
  3.3857 +    incx = (info->src_w << 16) / info->dst_w;
  3.3858 +
  3.3859 +    while (info->dst_h--) {
  3.3860 +        Uint32 *src;
  3.3861 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3862 +        int n = info->dst_w;
  3.3863 +        srcx = -1;
  3.3864 +        posx = 0x10000L;
  3.3865 +        while (posy >= 0x10000L) {
  3.3866 +            ++srcy;
  3.3867 +            posy -= 0x10000L;
  3.3868 +        }
  3.3869 +        while (n--) {
  3.3870 +            if (posx >= 0x10000L) {
  3.3871 +                while (posx >= 0x10000L) {
  3.3872 +                    ++srcx;
  3.3873 +                    posx -= 0x10000L;
  3.3874 +                }
  3.3875 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.3876 +            }
  3.3877 +            srcpixel = *src;
  3.3878 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3.3879 +            dstpixel = *dst;
  3.3880 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.3881 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.3882 +                srcR = (srcR * modulateR) / 255;
  3.3883 +                srcG = (srcG * modulateG) / 255;
  3.3884 +                srcB = (srcB * modulateB) / 255;
  3.3885 +            }
  3.3886 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.3887 +                srcA = (srcA * modulateA) / 255;
  3.3888 +            }
  3.3889 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.3890 +                /* This goes away if we ever use premultiplied alpha */
  3.3891 +                if (srcA < 255) {
  3.3892 +                    srcR = (srcR * srcA) / 255;
  3.3893 +                    srcG = (srcG * srcA) / 255;
  3.3894 +                    srcB = (srcB * srcA) / 255;
  3.3895 +                }
  3.3896 +            }
  3.3897 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.3898 +            case SDL_COPY_MASK:
  3.3899 +                if (srcA) {
  3.3900 +                    dstR = srcR;
  3.3901 +                    dstG = srcG;
  3.3902 +                    dstB = srcB;
  3.3903 +                }
  3.3904 +                break;
  3.3905 +            case SDL_COPY_BLEND:
  3.3906 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.3907 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.3908 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.3909 +                break;
  3.3910 +            case SDL_COPY_ADD:
  3.3911 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.3912 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.3913 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.3914 +                break;
  3.3915 +            case SDL_COPY_MOD:
  3.3916 +                dstR = (srcR * dstR) / 255;
  3.3917 +                dstG = (srcG * dstG) / 255;
  3.3918 +                dstB = (srcB * dstB) / 255;
  3.3919 +                break;
  3.3920 +            }
  3.3921 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.3922 +            *dst = dstpixel;
  3.3923 +            posx += incx;
  3.3924 +            ++dst;
  3.3925 +        }
  3.3926 +        posy += incy;
  3.3927 +        info->dst += info->dst_pitch;
  3.3928 +    }
  3.3929 +}
  3.3930 +
  3.3931 +static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info)
  3.3932 +{
  3.3933 +    const int flags = info->flags;
  3.3934 +    Uint32 pixel;
  3.3935 +    Uint32 R, G, B, A;
  3.3936 +    int srcy, srcx;
  3.3937 +    int posy, posx;
  3.3938 +    int incy, incx;
  3.3939 +
  3.3940 +    srcy = 0;
  3.3941 +    posy = 0;
  3.3942 +    incy = (info->src_h << 16) / info->dst_h;
  3.3943 +    incx = (info->src_w << 16) / info->dst_w;
  3.3944 +
  3.3945 +    while (info->dst_h--) {
  3.3946 +        Uint32 *src;
  3.3947 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3948 +        int n = info->dst_w;
  3.3949 +        srcx = -1;
  3.3950 +        posx = 0x10000L;
  3.3951 +        while (posy >= 0x10000L) {
  3.3952 +            ++srcy;
  3.3953 +            posy -= 0x10000L;
  3.3954 +        }
  3.3955 +        while (n--) {
  3.3956 +            if (posx >= 0x10000L) {
  3.3957 +                while (posx >= 0x10000L) {
  3.3958 +                    ++srcx;
  3.3959 +                    posx -= 0x10000L;
  3.3960 +                }
  3.3961 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.3962 +            }
  3.3963 +            pixel = *src;
  3.3964 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  3.3965 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.3966 +            *dst = pixel;
  3.3967 +            posx += incx;
  3.3968 +            ++dst;
  3.3969 +        }
  3.3970 +        posy += incy;
  3.3971 +        info->dst += info->dst_pitch;
  3.3972 +    }
  3.3973 +}
  3.3974 +
  3.3975 +static void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info)
  3.3976 +{
  3.3977 +    const int flags = info->flags;
  3.3978 +    Uint32 srcpixel;
  3.3979 +    Uint32 srcR, srcG, srcB, srcA;
  3.3980 +    Uint32 dstpixel;
  3.3981 +    Uint32 dstR, dstG, dstB, dstA;
  3.3982 +
  3.3983 +    while (info->dst_h--) {
  3.3984 +        Uint32 *src = (Uint32 *)info->src;
  3.3985 +        Uint32 *dst = (Uint32 *)info->dst;
  3.3986 +        int n = info->dst_w;
  3.3987 +        while (n--) {
  3.3988 +            srcpixel = *src;
  3.3989 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3.3990 +            dstpixel = *dst;
  3.3991 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.3992 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.3993 +                /* This goes away if we ever use premultiplied alpha */
  3.3994 +                if (srcA < 255) {
  3.3995 +                    srcR = (srcR * srcA) / 255;
  3.3996 +                    srcG = (srcG * srcA) / 255;
  3.3997 +                    srcB = (srcB * srcA) / 255;
  3.3998 +                }
  3.3999 +            }
  3.4000 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.4001 +            case SDL_COPY_MASK:
  3.4002 +                if (srcA) {
  3.4003 +                    dstR = srcR;
  3.4004 +                    dstG = srcG;
  3.4005 +                    dstB = srcB;
  3.4006 +                }
  3.4007 +                break;
  3.4008 +            case SDL_COPY_BLEND:
  3.4009 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.4010 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.4011 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.4012 +                break;
  3.4013 +            case SDL_COPY_ADD:
  3.4014 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.4015 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.4016 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.4017 +                break;
  3.4018 +            case SDL_COPY_MOD:
  3.4019 +                dstR = (srcR * dstR) / 255;
  3.4020 +                dstG = (srcG * dstG) / 255;
  3.4021 +                dstB = (srcB * dstB) / 255;
  3.4022 +                break;
  3.4023 +            }
  3.4024 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.4025 +            *dst = dstpixel;
  3.4026 +            ++src;
  3.4027 +            ++dst;
  3.4028 +        }
  3.4029 +        info->src += info->src_pitch;
  3.4030 +        info->dst += info->dst_pitch;
  3.4031 +    }
  3.4032 +}
  3.4033 +
  3.4034 +static void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  3.4035 +{
  3.4036 +    const int flags = info->flags;
  3.4037 +    Uint32 srcpixel;
  3.4038 +    Uint32 srcR, srcG, srcB, srcA;
  3.4039 +    Uint32 dstpixel;
  3.4040 +    Uint32 dstR, dstG, dstB, dstA;
  3.4041 +    int srcy, srcx;
  3.4042 +    int posy, posx;
  3.4043 +    int incy, incx;
  3.4044 +
  3.4045 +    srcy = 0;
  3.4046 +    posy = 0;
  3.4047 +    incy = (info->src_h << 16) / info->dst_h;
  3.4048 +    incx = (info->src_w << 16) / info->dst_w;
  3.4049 +
  3.4050 +    while (info->dst_h--) {
  3.4051 +        Uint32 *src;
  3.4052 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4053 +        int n = info->dst_w;
  3.4054 +        srcx = -1;
  3.4055 +        posx = 0x10000L;
  3.4056 +        while (posy >= 0x10000L) {
  3.4057 +            ++srcy;
  3.4058 +            posy -= 0x10000L;
  3.4059 +        }
  3.4060 +        while (n--) {
  3.4061 +            if (posx >= 0x10000L) {
  3.4062 +                while (posx >= 0x10000L) {
  3.4063 +                    ++srcx;
  3.4064 +                    posx -= 0x10000L;
  3.4065 +                }
  3.4066 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.4067 +            }
  3.4068 +            srcpixel = *src;
  3.4069 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3.4070 +            dstpixel = *dst;
  3.4071 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.4072 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.4073 +                /* This goes away if we ever use premultiplied alpha */
  3.4074 +                if (srcA < 255) {
  3.4075 +                    srcR = (srcR * srcA) / 255;
  3.4076 +                    srcG = (srcG * srcA) / 255;
  3.4077 +                    srcB = (srcB * srcA) / 255;
  3.4078 +                }
  3.4079 +            }
  3.4080 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.4081 +            case SDL_COPY_MASK:
  3.4082 +                if (srcA) {
  3.4083 +                    dstR = srcR;
  3.4084 +                    dstG = srcG;
  3.4085 +                    dstB = srcB;
  3.4086 +                }
  3.4087 +                break;
  3.4088 +            case SDL_COPY_BLEND:
  3.4089 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.4090 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.4091 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.4092 +                break;
  3.4093 +            case SDL_COPY_ADD:
  3.4094 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.4095 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.4096 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.4097 +                break;
  3.4098 +            case SDL_COPY_MOD:
  3.4099 +                dstR = (srcR * dstR) / 255;
  3.4100 +                dstG = (srcG * dstG) / 255;
  3.4101 +                dstB = (srcB * dstB) / 255;
  3.4102 +                break;
  3.4103 +            }
  3.4104 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.4105 +            *dst = dstpixel;
  3.4106 +            posx += incx;
  3.4107 +            ++dst;
  3.4108 +        }
  3.4109 +        posy += incy;
  3.4110 +        info->dst += info->dst_pitch;
  3.4111 +    }
  3.4112 +}
  3.4113 +
  3.4114 +static void SDL_Blit_ABGR8888_BGR888_Modulate(SDL_BlitInfo *info)
  3.4115 +{
  3.4116 +    const int flags = info->flags;
  3.4117 +    const Uint32 modulateR = info->r;
  3.4118 +    const Uint32 modulateG = info->g;
  3.4119 +    const Uint32 modulateB = info->b;
  3.4120 +    const Uint32 modulateA = info->a;
  3.4121 +    Uint32 pixel;
  3.4122 +    Uint32 R, G, B, A;
  3.4123 +
  3.4124 +    while (info->dst_h--) {
  3.4125 +        Uint32 *src = (Uint32 *)info->src;
  3.4126 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4127 +        int n = info->dst_w;
  3.4128 +        while (n--) {
  3.4129 +            pixel = *src;
  3.4130 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  3.4131 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.4132 +                R = (R * modulateR) / 255;
  3.4133 +                G = (G * modulateG) / 255;
  3.4134 +                B = (B * modulateB) / 255;
  3.4135 +            }
  3.4136 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.4137 +                A = (A * modulateA) / 255;
  3.4138 +            }
  3.4139 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.4140 +            *dst = pixel;
  3.4141 +            ++src;
  3.4142 +            ++dst;
  3.4143 +        }
  3.4144 +        info->src += info->src_pitch;
  3.4145 +        info->dst += info->dst_pitch;
  3.4146 +    }
  3.4147 +}
  3.4148 +
  3.4149 +static void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  3.4150 +{
  3.4151 +    const int flags = info->flags;
  3.4152 +    const Uint32 modulateR = info->r;
  3.4153 +    const Uint32 modulateG = info->g;
  3.4154 +    const Uint32 modulateB = info->b;
  3.4155 +    const Uint32 modulateA = info->a;
  3.4156 +    Uint32 pixel;
  3.4157 +    Uint32 R, G, B, A;
  3.4158 +    int srcy, srcx;
  3.4159 +    int posy, posx;
  3.4160 +    int incy, incx;
  3.4161 +
  3.4162 +    srcy = 0;
  3.4163 +    posy = 0;
  3.4164 +    incy = (info->src_h << 16) / info->dst_h;
  3.4165 +    incx = (info->src_w << 16) / info->dst_w;
  3.4166 +
  3.4167 +    while (info->dst_h--) {
  3.4168 +        Uint32 *src;
  3.4169 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4170 +        int n = info->dst_w;
  3.4171 +        srcx = -1;
  3.4172 +        posx = 0x10000L;
  3.4173 +        while (posy >= 0x10000L) {
  3.4174 +            ++srcy;
  3.4175 +            posy -= 0x10000L;
  3.4176 +        }
  3.4177 +        while (n--) {
  3.4178 +            if (posx >= 0x10000L) {
  3.4179 +                while (posx >= 0x10000L) {
  3.4180 +                    ++srcx;
  3.4181 +                    posx -= 0x10000L;
  3.4182 +                }
  3.4183 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.4184 +            }
  3.4185 +            pixel = *src;
  3.4186 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  3.4187 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.4188 +                R = (R * modulateR) / 255;
  3.4189 +                G = (G * modulateG) / 255;
  3.4190 +                B = (B * modulateB) / 255;
  3.4191 +            }
  3.4192 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.4193 +                A = (A * modulateA) / 255;
  3.4194 +            }
  3.4195 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.4196 +            *dst = pixel;
  3.4197 +            posx += incx;
  3.4198 +            ++dst;
  3.4199 +        }
  3.4200 +        posy += incy;
  3.4201 +        info->dst += info->dst_pitch;
  3.4202 +    }
  3.4203 +}
  3.4204 +
  3.4205 +static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  3.4206 +{
  3.4207 +    const int flags = info->flags;
  3.4208 +    const Uint32 modulateR = info->r;
  3.4209 +    const Uint32 modulateG = info->g;
  3.4210 +    const Uint32 modulateB = info->b;
  3.4211 +    const Uint32 modulateA = info->a;
  3.4212 +    Uint32 srcpixel;
  3.4213 +    Uint32 srcR, srcG, srcB, srcA;
  3.4214 +    Uint32 dstpixel;
  3.4215 +    Uint32 dstR, dstG, dstB, dstA;
  3.4216 +
  3.4217 +    while (info->dst_h--) {
  3.4218 +        Uint32 *src = (Uint32 *)info->src;
  3.4219 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4220 +        int n = info->dst_w;
  3.4221 +        while (n--) {
  3.4222 +            srcpixel = *src;
  3.4223 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3.4224 +            dstpixel = *dst;
  3.4225 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.4226 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.4227 +                srcR = (srcR * modulateR) / 255;
  3.4228 +                srcG = (srcG * modulateG) / 255;
  3.4229 +                srcB = (srcB * modulateB) / 255;
  3.4230 +            }
  3.4231 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.4232 +                srcA = (srcA * modulateA) / 255;
  3.4233 +            }
  3.4234 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.4235 +                /* This goes away if we ever use premultiplied alpha */
  3.4236 +                if (srcA < 255) {
  3.4237 +                    srcR = (srcR * srcA) / 255;
  3.4238 +                    srcG = (srcG * srcA) / 255;
  3.4239 +                    srcB = (srcB * srcA) / 255;
  3.4240 +                }
  3.4241 +            }
  3.4242 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.4243 +            case SDL_COPY_MASK:
  3.4244 +                if (srcA) {
  3.4245 +                    dstR = srcR;
  3.4246 +                    dstG = srcG;
  3.4247 +                    dstB = srcB;
  3.4248 +                }
  3.4249 +                break;
  3.4250 +            case SDL_COPY_BLEND:
  3.4251 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.4252 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.4253 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.4254 +                break;
  3.4255 +            case SDL_COPY_ADD:
  3.4256 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.4257 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.4258 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.4259 +                break;
  3.4260 +            case SDL_COPY_MOD:
  3.4261 +                dstR = (srcR * dstR) / 255;
  3.4262 +                dstG = (srcG * dstG) / 255;
  3.4263 +                dstB = (srcB * dstB) / 255;
  3.4264 +                break;
  3.4265 +            }
  3.4266 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.4267 +            *dst = dstpixel;
  3.4268 +            ++src;
  3.4269 +            ++dst;
  3.4270 +        }
  3.4271 +        info->src += info->src_pitch;
  3.4272 +        info->dst += info->dst_pitch;
  3.4273 +    }
  3.4274 +}
  3.4275 +
  3.4276 +static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.4277 +{
  3.4278 +    const int flags = info->flags;
  3.4279 +    const Uint32 modulateR = info->r;
  3.4280 +    const Uint32 modulateG = info->g;
  3.4281 +    const Uint32 modulateB = info->b;
  3.4282 +    const Uint32 modulateA = info->a;
  3.4283 +    Uint32 srcpixel;
  3.4284 +    Uint32 srcR, srcG, srcB, srcA;
  3.4285 +    Uint32 dstpixel;
  3.4286 +    Uint32 dstR, dstG, dstB, dstA;
  3.4287 +    int srcy, srcx;
  3.4288 +    int posy, posx;
  3.4289 +    int incy, incx;
  3.4290 +
  3.4291 +    srcy = 0;
  3.4292 +    posy = 0;
  3.4293 +    incy = (info->src_h << 16) / info->dst_h;
  3.4294 +    incx = (info->src_w << 16) / info->dst_w;
  3.4295 +
  3.4296 +    while (info->dst_h--) {
  3.4297 +        Uint32 *src;
  3.4298 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4299 +        int n = info->dst_w;
  3.4300 +        srcx = -1;
  3.4301 +        posx = 0x10000L;
  3.4302 +        while (posy >= 0x10000L) {
  3.4303 +            ++srcy;
  3.4304 +            posy -= 0x10000L;
  3.4305 +        }
  3.4306 +        while (n--) {
  3.4307 +            if (posx >= 0x10000L) {
  3.4308 +                while (posx >= 0x10000L) {
  3.4309 +                    ++srcx;
  3.4310 +                    posx -= 0x10000L;
  3.4311 +                }
  3.4312 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.4313 +            }
  3.4314 +            srcpixel = *src;
  3.4315 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3.4316 +            dstpixel = *dst;
  3.4317 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.4318 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.4319 +                srcR = (srcR * modulateR) / 255;
  3.4320 +                srcG = (srcG * modulateG) / 255;
  3.4321 +                srcB = (srcB * modulateB) / 255;
  3.4322 +            }
  3.4323 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.4324 +                srcA = (srcA * modulateA) / 255;
  3.4325 +            }
  3.4326 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.4327 +                /* This goes away if we ever use premultiplied alpha */
  3.4328 +                if (srcA < 255) {
  3.4329 +                    srcR = (srcR * srcA) / 255;
  3.4330 +                    srcG = (srcG * srcA) / 255;
  3.4331 +                    srcB = (srcB * srcA) / 255;
  3.4332 +                }
  3.4333 +            }
  3.4334 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.4335 +            case SDL_COPY_MASK:
  3.4336 +                if (srcA) {
  3.4337 +                    dstR = srcR;
  3.4338 +                    dstG = srcG;
  3.4339 +                    dstB = srcB;
  3.4340 +                }
  3.4341 +                break;
  3.4342 +            case SDL_COPY_BLEND:
  3.4343 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.4344 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.4345 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.4346 +                break;
  3.4347 +            case SDL_COPY_ADD:
  3.4348 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.4349 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.4350 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.4351 +                break;
  3.4352 +            case SDL_COPY_MOD:
  3.4353 +                dstR = (srcR * dstR) / 255;
  3.4354 +                dstG = (srcG * dstG) / 255;
  3.4355 +                dstB = (srcB * dstB) / 255;
  3.4356 +                break;
  3.4357 +            }
  3.4358 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.4359 +            *dst = dstpixel;
  3.4360 +            posx += incx;
  3.4361 +            ++dst;
  3.4362 +        }
  3.4363 +        posy += incy;
  3.4364 +        info->dst += info->dst_pitch;
  3.4365 +    }
  3.4366 +}
  3.4367 +
  3.4368 +static void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info)
  3.4369 +{
  3.4370 +    const int flags = info->flags;
  3.4371 +    Uint32 pixel;
  3.4372 +    Uint32 R, G, B, A;
  3.4373 +    int srcy, srcx;
  3.4374 +    int posy, posx;
  3.4375 +    int incy, incx;
  3.4376 +
  3.4377 +    srcy = 0;
  3.4378 +    posy = 0;
  3.4379 +    incy = (info->src_h << 16) / info->dst_h;
  3.4380 +    incx = (info->src_w << 16) / info->dst_w;
  3.4381 +
  3.4382 +    while (info->dst_h--) {
  3.4383 +        Uint32 *src;
  3.4384 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4385 +        int n = info->dst_w;
  3.4386 +        srcx = -1;
  3.4387 +        posx = 0x10000L;
  3.4388 +        while (posy >= 0x10000L) {
  3.4389 +            ++srcy;
  3.4390 +            posy -= 0x10000L;
  3.4391 +        }
  3.4392 +        while (n--) {
  3.4393 +            if (posx >= 0x10000L) {
  3.4394 +                while (posx >= 0x10000L) {
  3.4395 +                    ++srcx;
  3.4396 +                    posx -= 0x10000L;
  3.4397 +                }
  3.4398 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.4399 +            }
  3.4400 +            pixel = *src;
  3.4401 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.4402 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.4403 +            *dst = pixel;
  3.4404 +            posx += incx;
  3.4405 +            ++dst;
  3.4406 +        }
  3.4407 +        posy += incy;
  3.4408 +        info->dst += info->dst_pitch;
  3.4409 +    }
  3.4410 +}
  3.4411 +
  3.4412 +static void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info)
  3.4413 +{
  3.4414 +    const int flags = info->flags;
  3.4415 +    Uint32 srcpixel;
  3.4416 +    Uint32 srcR, srcG, srcB, srcA;
  3.4417 +    Uint32 dstpixel;
  3.4418 +    Uint32 dstR, dstG, dstB, dstA;
  3.4419 +
  3.4420 +    while (info->dst_h--) {
  3.4421 +        Uint32 *src = (Uint32 *)info->src;
  3.4422 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4423 +        int n = info->dst_w;
  3.4424 +        while (n--) {
  3.4425 +            srcpixel = *src;
  3.4426 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.4427 +            dstpixel = *dst;
  3.4428 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.4429 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.4430 +                /* This goes away if we ever use premultiplied alpha */
  3.4431 +                if (srcA < 255) {
  3.4432 +                    srcR = (srcR * srcA) / 255;
  3.4433 +                    srcG = (srcG * srcA) / 255;
  3.4434 +                    srcB = (srcB * srcA) / 255;
  3.4435 +                }
  3.4436 +            }
  3.4437 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.4438 +            case SDL_COPY_MASK:
  3.4439 +                if (srcA) {
  3.4440 +                    dstR = srcR;
  3.4441 +                    dstG = srcG;
  3.4442 +                    dstB = srcB;
  3.4443 +                }
  3.4444 +                break;
  3.4445 +            case SDL_COPY_BLEND:
  3.4446 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.4447 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.4448 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.4449 +                break;
  3.4450 +            case SDL_COPY_ADD:
  3.4451 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.4452 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.4453 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.4454 +                break;
  3.4455 +            case SDL_COPY_MOD:
  3.4456 +                dstR = (srcR * dstR) / 255;
  3.4457 +                dstG = (srcG * dstG) / 255;
  3.4458 +                dstB = (srcB * dstB) / 255;
  3.4459 +                break;
  3.4460 +            }
  3.4461 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.4462 +            *dst = dstpixel;
  3.4463 +            ++src;
  3.4464 +            ++dst;
  3.4465 +        }
  3.4466 +        info->src += info->src_pitch;
  3.4467 +        info->dst += info->dst_pitch;
  3.4468 +    }
  3.4469 +}
  3.4470 +
  3.4471 +static void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  3.4472 +{
  3.4473 +    const int flags = info->flags;
  3.4474 +    Uint32 srcpixel;
  3.4475 +    Uint32 srcR, srcG, srcB, srcA;
  3.4476 +    Uint32 dstpixel;
  3.4477 +    Uint32 dstR, dstG, dstB, dstA;
  3.4478 +    int srcy, srcx;
  3.4479 +    int posy, posx;
  3.4480 +    int incy, incx;
  3.4481 +
  3.4482 +    srcy = 0;
  3.4483 +    posy = 0;
  3.4484 +    incy = (info->src_h << 16) / info->dst_h;
  3.4485 +    incx = (info->src_w << 16) / info->dst_w;
  3.4486 +
  3.4487 +    while (info->dst_h--) {
  3.4488 +        Uint32 *src;
  3.4489 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4490 +        int n = info->dst_w;
  3.4491 +        srcx = -1;
  3.4492 +        posx = 0x10000L;
  3.4493 +        while (posy >= 0x10000L) {
  3.4494 +            ++srcy;
  3.4495 +            posy -= 0x10000L;
  3.4496 +        }
  3.4497 +        while (n--) {
  3.4498 +            if (posx >= 0x10000L) {
  3.4499 +                while (posx >= 0x10000L) {
  3.4500 +                    ++srcx;
  3.4501 +                    posx -= 0x10000L;
  3.4502 +                }
  3.4503 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.4504 +            }
  3.4505 +            srcpixel = *src;
  3.4506 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.4507 +            dstpixel = *dst;
  3.4508 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.4509 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.4510 +                /* This goes away if we ever use premultiplied alpha */
  3.4511 +                if (srcA < 255) {
  3.4512 +                    srcR = (srcR * srcA) / 255;
  3.4513 +                    srcG = (srcG * srcA) / 255;
  3.4514 +                    srcB = (srcB * srcA) / 255;
  3.4515 +                }
  3.4516 +            }
  3.4517 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.4518 +            case SDL_COPY_MASK:
  3.4519 +                if (srcA) {
  3.4520 +                    dstR = srcR;
  3.4521 +                    dstG = srcG;
  3.4522 +                    dstB = srcB;
  3.4523 +                }
  3.4524 +                break;
  3.4525 +            case SDL_COPY_BLEND:
  3.4526 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.4527 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.4528 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.4529 +                break;
  3.4530 +            case SDL_COPY_ADD:
  3.4531 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.4532 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.4533 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.4534 +                break;
  3.4535 +            case SDL_COPY_MOD:
  3.4536 +                dstR = (srcR * dstR) / 255;
  3.4537 +                dstG = (srcG * dstG) / 255;
  3.4538 +                dstB = (srcB * dstB) / 255;
  3.4539 +                break;
  3.4540 +            }
  3.4541 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.4542 +            *dst = dstpixel;
  3.4543 +            posx += incx;
  3.4544 +            ++dst;
  3.4545 +        }
  3.4546 +        posy += incy;
  3.4547 +        info->dst += info->dst_pitch;
  3.4548 +    }
  3.4549 +}
  3.4550 +
  3.4551 +static void SDL_Blit_BGRA8888_RGB888_Modulate(SDL_BlitInfo *info)
  3.4552 +{
  3.4553 +    const int flags = info->flags;
  3.4554 +    const Uint32 modulateR = info->r;
  3.4555 +    const Uint32 modulateG = info->g;
  3.4556 +    const Uint32 modulateB = info->b;
  3.4557 +    const Uint32 modulateA = info->a;
  3.4558 +    Uint32 pixel;
  3.4559 +    Uint32 R, G, B, A;
  3.4560 +
  3.4561 +    while (info->dst_h--) {
  3.4562 +        Uint32 *src = (Uint32 *)info->src;
  3.4563 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4564 +        int n = info->dst_w;
  3.4565 +        while (n--) {
  3.4566 +            pixel = *src;
  3.4567 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.4568 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.4569 +                R = (R * modulateR) / 255;
  3.4570 +                G = (G * modulateG) / 255;
  3.4571 +                B = (B * modulateB) / 255;
  3.4572 +            }
  3.4573 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.4574 +                A = (A * modulateA) / 255;
  3.4575 +            }
  3.4576 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.4577 +            *dst = pixel;
  3.4578 +            ++src;
  3.4579 +            ++dst;
  3.4580 +        }
  3.4581 +        info->src += info->src_pitch;
  3.4582 +        info->dst += info->dst_pitch;
  3.4583 +    }
  3.4584 +}
  3.4585 +
  3.4586 +static void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  3.4587 +{
  3.4588 +    const int flags = info->flags;
  3.4589 +    const Uint32 modulateR = info->r;
  3.4590 +    const Uint32 modulateG = info->g;
  3.4591 +    const Uint32 modulateB = info->b;
  3.4592 +    const Uint32 modulateA = info->a;
  3.4593 +    Uint32 pixel;
  3.4594 +    Uint32 R, G, B, A;
  3.4595 +    int srcy, srcx;
  3.4596 +    int posy, posx;
  3.4597 +    int incy, incx;
  3.4598 +
  3.4599 +    srcy = 0;
  3.4600 +    posy = 0;
  3.4601 +    incy = (info->src_h << 16) / info->dst_h;
  3.4602 +    incx = (info->src_w << 16) / info->dst_w;
  3.4603 +
  3.4604 +    while (info->dst_h--) {
  3.4605 +        Uint32 *src;
  3.4606 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4607 +        int n = info->dst_w;
  3.4608 +        srcx = -1;
  3.4609 +        posx = 0x10000L;
  3.4610 +        while (posy >= 0x10000L) {
  3.4611 +            ++srcy;
  3.4612 +            posy -= 0x10000L;
  3.4613 +        }
  3.4614 +        while (n--) {
  3.4615 +            if (posx >= 0x10000L) {
  3.4616 +                while (posx >= 0x10000L) {
  3.4617 +                    ++srcx;
  3.4618 +                    posx -= 0x10000L;
  3.4619 +                }
  3.4620 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.4621 +            }
  3.4622 +            pixel = *src;
  3.4623 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.4624 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.4625 +                R = (R * modulateR) / 255;
  3.4626 +                G = (G * modulateG) / 255;
  3.4627 +                B = (B * modulateB) / 255;
  3.4628 +            }
  3.4629 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.4630 +                A = (A * modulateA) / 255;
  3.4631 +            }
  3.4632 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.4633 +            *dst = pixel;
  3.4634 +            posx += incx;
  3.4635 +            ++dst;
  3.4636 +        }
  3.4637 +        posy += incy;
  3.4638 +        info->dst += info->dst_pitch;
  3.4639 +    }
  3.4640 +}
  3.4641 +
  3.4642 +static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  3.4643 +{
  3.4644 +    const int flags = info->flags;
  3.4645 +    const Uint32 modulateR = info->r;
  3.4646 +    const Uint32 modulateG = info->g;
  3.4647 +    const Uint32 modulateB = info->b;
  3.4648 +    const Uint32 modulateA = info->a;
  3.4649 +    Uint32 srcpixel;
  3.4650 +    Uint32 srcR, srcG, srcB, srcA;
  3.4651 +    Uint32 dstpixel;
  3.4652 +    Uint32 dstR, dstG, dstB, dstA;
  3.4653 +
  3.4654 +    while (info->dst_h--) {
  3.4655 +        Uint32 *src = (Uint32 *)info->src;
  3.4656 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4657 +        int n = info->dst_w;
  3.4658 +        while (n--) {
  3.4659 +            srcpixel = *src;
  3.4660 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.4661 +            dstpixel = *dst;
  3.4662 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.4663 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.4664 +                srcR = (srcR * modulateR) / 255;
  3.4665 +                srcG = (srcG * modulateG) / 255;
  3.4666 +                srcB = (srcB * modulateB) / 255;
  3.4667 +            }
  3.4668 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.4669 +                srcA = (srcA * modulateA) / 255;
  3.4670 +            }
  3.4671 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.4672 +                /* This goes away if we ever use premultiplied alpha */
  3.4673 +                if (srcA < 255) {
  3.4674 +                    srcR = (srcR * srcA) / 255;
  3.4675 +                    srcG = (srcG * srcA) / 255;
  3.4676 +                    srcB = (srcB * srcA) / 255;
  3.4677 +                }
  3.4678 +            }
  3.4679 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.4680 +            case SDL_COPY_MASK:
  3.4681 +                if (srcA) {
  3.4682 +                    dstR = srcR;
  3.4683 +                    dstG = srcG;
  3.4684 +                    dstB = srcB;
  3.4685 +                }
  3.4686 +                break;
  3.4687 +            case SDL_COPY_BLEND:
  3.4688 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.4689 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.4690 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.4691 +                break;
  3.4692 +            case SDL_COPY_ADD:
  3.4693 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.4694 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.4695 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.4696 +                break;
  3.4697 +            case SDL_COPY_MOD:
  3.4698 +                dstR = (srcR * dstR) / 255;
  3.4699 +                dstG = (srcG * dstG) / 255;
  3.4700 +                dstB = (srcB * dstB) / 255;
  3.4701 +                break;
  3.4702 +            }
  3.4703 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.4704 +            *dst = dstpixel;
  3.4705 +            ++src;
  3.4706 +            ++dst;
  3.4707 +        }
  3.4708 +        info->src += info->src_pitch;
  3.4709 +        info->dst += info->dst_pitch;
  3.4710 +    }
  3.4711 +}
  3.4712 +
  3.4713 +static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.4714 +{
  3.4715 +    const int flags = info->flags;
  3.4716 +    const Uint32 modulateR = info->r;
  3.4717 +    const Uint32 modulateG = info->g;
  3.4718 +    const Uint32 modulateB = info->b;
  3.4719 +    const Uint32 modulateA = info->a;
  3.4720 +    Uint32 srcpixel;
  3.4721 +    Uint32 srcR, srcG, srcB, srcA;
  3.4722 +    Uint32 dstpixel;
  3.4723 +    Uint32 dstR, dstG, dstB, dstA;
  3.4724 +    int srcy, srcx;
  3.4725 +    int posy, posx;
  3.4726 +    int incy, incx;
  3.4727 +
  3.4728 +    srcy = 0;
  3.4729 +    posy = 0;
  3.4730 +    incy = (info->src_h << 16) / info->dst_h;
  3.4731 +    incx = (info->src_w << 16) / info->dst_w;
  3.4732 +
  3.4733 +    while (info->dst_h--) {
  3.4734 +        Uint32 *src;
  3.4735 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4736 +        int n = info->dst_w;
  3.4737 +        srcx = -1;
  3.4738 +        posx = 0x10000L;
  3.4739 +        while (posy >= 0x10000L) {
  3.4740 +            ++srcy;
  3.4741 +            posy -= 0x10000L;
  3.4742 +        }
  3.4743 +        while (n--) {
  3.4744 +            if (posx >= 0x10000L) {
  3.4745 +                while (posx >= 0x10000L) {
  3.4746 +                    ++srcx;
  3.4747 +                    posx -= 0x10000L;
  3.4748 +                }
  3.4749 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.4750 +            }
  3.4751 +            srcpixel = *src;
  3.4752 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.4753 +            dstpixel = *dst;
  3.4754 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.4755 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.4756 +                srcR = (srcR * modulateR) / 255;
  3.4757 +                srcG = (srcG * modulateG) / 255;
  3.4758 +                srcB = (srcB * modulateB) / 255;
  3.4759 +            }
  3.4760 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.4761 +                srcA = (srcA * modulateA) / 255;
  3.4762 +            }
  3.4763 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.4764 +                /* This goes away if we ever use premultiplied alpha */
  3.4765 +                if (srcA < 255) {
  3.4766 +                    srcR = (srcR * srcA) / 255;
  3.4767 +                    srcG = (srcG * srcA) / 255;
  3.4768 +                    srcB = (srcB * srcA) / 255;
  3.4769 +                }
  3.4770 +            }
  3.4771 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.4772 +            case SDL_COPY_MASK:
  3.4773 +                if (srcA) {
  3.4774 +                    dstR = srcR;
  3.4775 +                    dstG = srcG;
  3.4776 +                    dstB = srcB;
  3.4777 +                }
  3.4778 +                break;
  3.4779 +            case SDL_COPY_BLEND:
  3.4780 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.4781 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.4782 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.4783 +                break;
  3.4784 +            case SDL_COPY_ADD:
  3.4785 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.4786 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.4787 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.4788 +                break;
  3.4789 +            case SDL_COPY_MOD:
  3.4790 +                dstR = (srcR * dstR) / 255;
  3.4791 +                dstG = (srcG * dstG) / 255;
  3.4792 +                dstB = (srcB * dstB) / 255;
  3.4793 +                break;
  3.4794 +            }
  3.4795 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.4796 +            *dst = dstpixel;
  3.4797 +            posx += incx;
  3.4798 +            ++dst;
  3.4799 +        }
  3.4800 +        posy += incy;
  3.4801 +        info->dst += info->dst_pitch;
  3.4802 +    }
  3.4803 +}
  3.4804 +
  3.4805 +static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info)
  3.4806 +{
  3.4807 +    const int flags = info->flags;
  3.4808 +    Uint32 pixel;
  3.4809 +    Uint32 R, G, B, A;
  3.4810 +    int srcy, srcx;
  3.4811 +    int posy, posx;
  3.4812 +    int incy, incx;
  3.4813 +
  3.4814 +    srcy = 0;
  3.4815 +    posy = 0;
  3.4816 +    incy = (info->src_h << 16) / info->dst_h;
  3.4817 +    incx = (info->src_w << 16) / info->dst_w;
  3.4818 +
  3.4819 +    while (info->dst_h--) {
  3.4820 +        Uint32 *src;
  3.4821 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4822 +        int n = info->dst_w;
  3.4823 +        srcx = -1;
  3.4824 +        posx = 0x10000L;
  3.4825 +        while (posy >= 0x10000L) {
  3.4826 +            ++srcy;
  3.4827 +            posy -= 0x10000L;
  3.4828 +        }
  3.4829 +        while (n--) {
  3.4830 +            if (posx >= 0x10000L) {
  3.4831 +                while (posx >= 0x10000L) {
  3.4832 +                    ++srcx;
  3.4833 +                    posx -= 0x10000L;
  3.4834 +                }
  3.4835 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.4836 +            }
  3.4837 +            pixel = *src;
  3.4838 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.4839 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.4840 +            *dst = pixel;
  3.4841 +            posx += incx;
  3.4842 +            ++dst;
  3.4843 +        }
  3.4844 +        posy += incy;
  3.4845 +        info->dst += info->dst_pitch;
  3.4846 +    }
  3.4847 +}
  3.4848 +
  3.4849 +static void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info)
  3.4850 +{
  3.4851 +    const int flags = info->flags;
  3.4852 +    Uint32 srcpixel;
  3.4853 +    Uint32 srcR, srcG, srcB, srcA;
  3.4854 +    Uint32 dstpixel;
  3.4855 +    Uint32 dstR, dstG, dstB, dstA;
  3.4856 +
  3.4857 +    while (info->dst_h--) {
  3.4858 +        Uint32 *src = (Uint32 *)info->src;
  3.4859 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4860 +        int n = info->dst_w;
  3.4861 +        while (n--) {
  3.4862 +            srcpixel = *src;
  3.4863 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.4864 +            dstpixel = *dst;
  3.4865 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.4866 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.4867 +                /* This goes away if we ever use premultiplied alpha */
  3.4868 +                if (srcA < 255) {
  3.4869 +                    srcR = (srcR * srcA) / 255;
  3.4870 +                    srcG = (srcG * srcA) / 255;
  3.4871 +                    srcB = (srcB * srcA) / 255;
  3.4872 +                }
  3.4873 +            }
  3.4874 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.4875 +            case SDL_COPY_MASK:
  3.4876 +                if (srcA) {
  3.4877 +                    dstR = srcR;
  3.4878 +                    dstG = srcG;
  3.4879 +                    dstB = srcB;
  3.4880 +                }
  3.4881 +                break;
  3.4882 +            case SDL_COPY_BLEND:
  3.4883 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.4884 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.4885 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.4886 +                break;
  3.4887 +            case SDL_COPY_ADD:
  3.4888 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.4889 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.4890 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.4891 +                break;
  3.4892 +            case SDL_COPY_MOD:
  3.4893 +                dstR = (srcR * dstR) / 255;
  3.4894 +                dstG = (srcG * dstG) / 255;
  3.4895 +                dstB = (srcB * dstB) / 255;
  3.4896 +                break;
  3.4897 +            }
  3.4898 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.4899 +            *dst = dstpixel;
  3.4900 +            ++src;
  3.4901 +            ++dst;
  3.4902 +        }
  3.4903 +        info->src += info->src_pitch;
  3.4904 +        info->dst += info->dst_pitch;
  3.4905 +    }
  3.4906 +}
  3.4907 +
  3.4908 +static void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  3.4909 +{
  3.4910 +    const int flags = info->flags;
  3.4911 +    Uint32 srcpixel;
  3.4912 +    Uint32 srcR, srcG, srcB, srcA;
  3.4913 +    Uint32 dstpixel;
  3.4914 +    Uint32 dstR, dstG, dstB, dstA;
  3.4915 +    int srcy, srcx;
  3.4916 +    int posy, posx;
  3.4917 +    int incy, incx;
  3.4918 +
  3.4919 +    srcy = 0;
  3.4920 +    posy = 0;
  3.4921 +    incy = (info->src_h << 16) / info->dst_h;
  3.4922 +    incx = (info->src_w << 16) / info->dst_w;
  3.4923 +
  3.4924 +    while (info->dst_h--) {
  3.4925 +        Uint32 *src;
  3.4926 +        Uint32 *dst = (Uint32 *)info->dst;
  3.4927 +        int n = info->dst_w;
  3.4928 +        srcx = -1;
  3.4929 +        posx = 0x10000L;
  3.4930 +        while (posy >= 0x10000L) {
  3.4931 +            ++srcy;
  3.4932 +            posy -= 0x10000L;
  3.4933 +        }
  3.4934 +        while (n--) {
  3.4935 +            if (posx >= 0x10000L) {
  3.4936 +                while (posx >= 0x10000L) {
  3.4937 +                    ++srcx;
  3.4938 +                    posx -= 0x10000L;
  3.4939 +                }
  3.4940 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.4941 +            }
  3.4942 +            srcpixel = *src;
  3.4943 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.4944 +            dstpixel = *dst;
  3.4945 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.4946 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.4947 +                /* This goes away if we ever use premultiplied alpha */
  3.4948 +                if (srcA < 255) {
  3.4949 +                    srcR = (srcR * srcA) / 255;
  3.4950 +                    srcG = (srcG * srcA) / 255;
  3.4951 +                    srcB = (srcB * srcA) / 255;
  3.4952 +                }
  3.4953 +            }
  3.4954 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.4955 +            case SDL_COPY_MASK:
  3.4956 +                if (srcA) {
  3.4957 +                    dstR = srcR;
  3.4958 +                    dstG = srcG;
  3.4959 +                    dstB = srcB;
  3.4960 +                }
  3.4961 +                break;
  3.4962 +            case SDL_COPY_BLEND:
  3.4963 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.4964 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.4965 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.4966 +                break;
  3.4967 +            case SDL_COPY_ADD:
  3.4968 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.4969 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.4970 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.4971 +                break;
  3.4972 +            case SDL_COPY_MOD:
  3.4973 +                dstR = (srcR * dstR) / 255;
  3.4974 +                dstG = (srcG * dstG) / 255;
  3.4975 +                dstB = (srcB * dstB) / 255;
  3.4976 +                break;
  3.4977 +            }
  3.4978 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.4979 +            *dst = dstpixel;
  3.4980 +            posx += incx;
  3.4981 +            ++dst;
  3.4982 +        }
  3.4983 +        posy += incy;
  3.4984 +        info->dst += info->dst_pitch;
  3.4985 +    }
  3.4986 +}
  3.4987 +
  3.4988 +static void SDL_Blit_BGRA8888_BGR888_Modulate(SDL_BlitInfo *info)
  3.4989 +{
  3.4990 +    const int flags = info->flags;
  3.4991 +    const Uint32 modulateR = info->r;
  3.4992 +    const Uint32 modulateG = info->g;
  3.4993 +    const Uint32 modulateB = info->b;
  3.4994 +    const Uint32 modulateA = info->a;
  3.4995 +    Uint32 pixel;
  3.4996 +    Uint32 R, G, B, A;
  3.4997 +
  3.4998 +    while (info->dst_h--) {
  3.4999 +        Uint32 *src = (Uint32 *)info->src;
  3.5000 +        Uint32 *dst = (Uint32 *)info->dst;
  3.5001 +        int n = info->dst_w;
  3.5002 +        while (n--) {
  3.5003 +            pixel = *src;
  3.5004 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.5005 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.5006 +                R = (R * modulateR) / 255;
  3.5007 +                G = (G * modulateG) / 255;
  3.5008 +                B = (B * modulateB) / 255;
  3.5009 +            }
  3.5010 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.5011 +                A = (A * modulateA) / 255;
  3.5012 +            }
  3.5013 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.5014 +            *dst = pixel;
  3.5015 +            ++src;
  3.5016 +            ++dst;
  3.5017 +        }
  3.5018 +        info->src += info->src_pitch;
  3.5019 +        info->dst += info->dst_pitch;
  3.5020 +    }
  3.5021 +}
  3.5022 +
  3.5023 +static void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  3.5024 +{
  3.5025 +    const int flags = info->flags;
  3.5026 +    const Uint32 modulateR = info->r;
  3.5027 +    const Uint32 modulateG = info->g;
  3.5028 +    const Uint32 modulateB = info->b;
  3.5029 +    const Uint32 modulateA = info->a;
  3.5030 +    Uint32 pixel;
  3.5031 +    Uint32 R, G, B, A;
  3.5032 +    int srcy, srcx;
  3.5033 +    int posy, posx;
  3.5034 +    int incy, incx;
  3.5035 +
  3.5036 +    srcy = 0;
  3.5037 +    posy = 0;
  3.5038 +    incy = (info->src_h << 16) / info->dst_h;
  3.5039 +    incx = (info->src_w << 16) / info->dst_w;
  3.5040 +
  3.5041 +    while (info->dst_h--) {
  3.5042 +        Uint32 *src;
  3.5043 +        Uint32 *dst = (Uint32 *)info->dst;
  3.5044 +        int n = info->dst_w;
  3.5045 +        srcx = -1;
  3.5046 +        posx = 0x10000L;
  3.5047 +        while (posy >= 0x10000L) {
  3.5048 +            ++srcy;
  3.5049 +            posy -= 0x10000L;
  3.5050 +        }
  3.5051 +        while (n--) {
  3.5052 +            if (posx >= 0x10000L) {
  3.5053 +                while (posx >= 0x10000L) {
  3.5054 +                    ++srcx;
  3.5055 +                    posx -= 0x10000L;
  3.5056 +                }
  3.5057 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.5058 +            }
  3.5059 +            pixel = *src;
  3.5060 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3.5061 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.5062 +                R = (R * modulateR) / 255;
  3.5063 +                G = (G * modulateG) / 255;
  3.5064 +                B = (B * modulateB) / 255;
  3.5065 +            }
  3.5066 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.5067 +                A = (A * modulateA) / 255;
  3.5068 +            }
  3.5069 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.5070 +            *dst = pixel;
  3.5071 +            posx += incx;
  3.5072 +            ++dst;
  3.5073 +        }
  3.5074 +        posy += incy;
  3.5075 +        info->dst += info->dst_pitch;
  3.5076 +    }
  3.5077 +}
  3.5078 +
  3.5079 +static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  3.5080 +{
  3.5081 +    const int flags = info->flags;
  3.5082 +    const Uint32 modulateR = info->r;
  3.5083 +    const Uint32 modulateG = info->g;
  3.5084 +    const Uint32 modulateB = info->b;
  3.5085 +    const Uint32 modulateA = info->a;
  3.5086 +    Uint32 srcpixel;
  3.5087 +    Uint32 srcR, srcG, srcB, srcA;
  3.5088 +    Uint32 dstpixel;
  3.5089 +    Uint32 dstR, dstG, dstB, dstA;
  3.5090 +
  3.5091 +    while (info->dst_h--) {
  3.5092 +        Uint32 *src = (Uint32 *)info->src;
  3.5093 +        Uint32 *dst = (Uint32 *)info->dst;
  3.5094 +        int n = info->dst_w;
  3.5095 +        while (n--) {
  3.5096 +            srcpixel = *src;
  3.5097 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.5098 +            dstpixel = *dst;
  3.5099 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.5100 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.5101 +                srcR = (srcR * modulateR) / 255;
  3.5102 +                srcG = (srcG * modulateG) / 255;
  3.5103 +                srcB = (srcB * modulateB) / 255;
  3.5104 +            }
  3.5105 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.5106 +                srcA = (srcA * modulateA) / 255;
  3.5107 +            }
  3.5108 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.5109 +                /* This goes away if we ever use premultiplied alpha */
  3.5110 +                if (srcA < 255) {
  3.5111 +                    srcR = (srcR * srcA) / 255;
  3.5112 +                    srcG = (srcG * srcA) / 255;
  3.5113 +                    srcB = (srcB * srcA) / 255;
  3.5114 +                }
  3.5115 +            }
  3.5116 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.5117 +            case SDL_COPY_MASK:
  3.5118 +                if (srcA) {
  3.5119 +                    dstR = srcR;
  3.5120 +                    dstG = srcG;
  3.5121 +                    dstB = srcB;
  3.5122 +                }
  3.5123 +                break;
  3.5124 +            case SDL_COPY_BLEND:
  3.5125 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.5126 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.5127 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.5128 +                break;
  3.5129 +            case SDL_COPY_ADD:
  3.5130 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.5131 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.5132 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.5133 +                break;
  3.5134 +            case SDL_COPY_MOD:
  3.5135 +                dstR = (srcR * dstR) / 255;
  3.5136 +                dstG = (srcG * dstG) / 255;
  3.5137 +                dstB = (srcB * dstB) / 255;
  3.5138 +                break;
  3.5139 +            }
  3.5140 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.5141 +            *dst = dstpixel;
  3.5142 +            ++src;
  3.5143 +            ++dst;
  3.5144 +        }
  3.5145 +        info->src += info->src_pitch;
  3.5146 +        info->dst += info->dst_pitch;
  3.5147 +    }
  3.5148 +}
  3.5149 +
  3.5150 +static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.5151 +{
  3.5152 +    const int flags = info->flags;
  3.5153 +    const Uint32 modulateR = info->r;
  3.5154 +    const Uint32 modulateG = info->g;
  3.5155 +    const Uint32 modulateB = info->b;
  3.5156 +    const Uint32 modulateA = info->a;
  3.5157 +    Uint32 srcpixel;
  3.5158 +    Uint32 srcR, srcG, srcB, srcA;
  3.5159 +    Uint32 dstpixel;
  3.5160 +    Uint32 dstR, dstG, dstB, dstA;
  3.5161 +    int srcy, srcx;
  3.5162 +    int posy, posx;
  3.5163 +    int incy, incx;
  3.5164 +
  3.5165 +    srcy = 0;
  3.5166 +    posy = 0;
  3.5167 +    incy = (info->src_h << 16) / info->dst_h;
  3.5168 +    incx = (info->src_w << 16) / info->dst_w;
  3.5169 +
  3.5170 +    while (info->dst_h--) {
  3.5171 +        Uint32 *src;
  3.5172 +        Uint32 *dst = (Uint32 *)info->dst;
  3.5173 +        int n = info->dst_w;
  3.5174 +        srcx = -1;
  3.5175 +        posx = 0x10000L;
  3.5176 +        while (posy >= 0x10000L) {
  3.5177 +            ++srcy;
  3.5178 +            posy -= 0x10000L;
  3.5179 +        }
  3.5180 +        while (n--) {
  3.5181 +            if (posx >= 0x10000L) {
  3.5182 +                while (posx >= 0x10000L) {
  3.5183 +                    ++srcx;
  3.5184 +                    posx -= 0x10000L;
  3.5185 +                }
  3.5186 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.5187 +            }
  3.5188 +            srcpixel = *src;
  3.5189 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3.5190 +            dstpixel = *dst;
  3.5191 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.5192 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.5193 +                srcR = (srcR * modulateR) / 255;
  3.5194 +                srcG = (srcG * modulateG) / 255;
  3.5195 +                srcB = (srcB * modulateB) / 255;
  3.5196 +            }
  3.5197 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.5198 +                srcA = (srcA * modulateA) / 255;
  3.5199 +            }
  3.5200 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.5201 +                /* This goes away if we ever use premultiplied alpha */
  3.5202 +                if (srcA < 255) {
  3.5203 +                    srcR = (srcR * srcA) / 255;
  3.5204 +                    srcG = (srcG * srcA) / 255;
  3.5205 +                    srcB = (srcB * srcA) / 255;
  3.5206 +                }
  3.5207 +            }
  3.5208 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.5209 +            case SDL_COPY_MASK:
  3.5210 +                if (srcA) {
  3.5211 +                    dstR = srcR;
  3.5212 +                    dstG = srcG;
  3.5213 +                    dstB = srcB;
  3.5214 +                }
  3.5215 +                break;
  3.5216 +            case SDL_COPY_BLEND:
  3.5217 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.5218 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.5219 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.5220 +                break;
  3.5221 +            case SDL_COPY_ADD:
  3.5222 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.5223 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.5224 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.5225 +                break;
  3.5226 +            case SDL_COPY_MOD:
  3.5227 +                dstR = (srcR * dstR) / 255;
  3.5228 +                dstG = (srcG * dstG) / 255;
  3.5229 +                dstB = (srcB * dstB) / 255;
  3.5230 +                break;
  3.5231 +            }
  3.5232 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.5233 +            *dst = dstpixel;
  3.5234 +            posx += incx;
  3.5235 +            ++dst;
  3.5236 +        }
  3.5237 +        posy += incy;
  3.5238 +        info->dst += info->dst_pitch;
  3.5239 +    }
  3.5240 +}
  3.5241 +
  3.5242 +static SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
  3.5243      { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale },
  3.5244      { 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 },
  3.5245      { 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 },
  3.5246 @@ -116,5242 +5350,6 @@
  3.5247      { 0, 0, 0, 0, NULL }
  3.5248  };
  3.5249  
  3.5250 -SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable = _SDL_GeneratedBlitFuncTable;
  3.5251 -
  3.5252 -void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info)
  3.5253 -{
  3.5254 -    const int flags = info->flags;
  3.5255 -    int srcy, srcx;
  3.5256 -    int posy, posx;
  3.5257 -    int incy, incx;
  3.5258 -
  3.5259 -    srcy = 0;
  3.5260 -    posy = 0;
  3.5261 -    incy = (info->src_h << 16) / info->dst_h;
  3.5262 -    incx = (info->src_w << 16) / info->dst_w;
  3.5263 -
  3.5264 -    while (info->dst_h--) {
  3.5265 -        Uint32 *src;
  3.5266 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5267 -        int n = info->dst_w;
  3.5268 -        srcx = -1;
  3.5269 -        posx = 0x10000L;
  3.5270 -        while (posy >= 0x10000L) {
  3.5271 -            ++srcy;
  3.5272 -            posy -= 0x10000L;
  3.5273 -        }
  3.5274 -        while (n--) {
  3.5275 -            if (posx >= 0x10000L) {
  3.5276 -                while (posx >= 0x10000L) {
  3.5277 -                    ++srcx;
  3.5278 -                    posx -= 0x10000L;
  3.5279 -                }
  3.5280 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.5281 -            }
  3.5282 -            *dst = *src;
  3.5283 -            posx += incx;
  3.5284 -            ++dst;
  3.5285 -        }
  3.5286 -        posy += incy;
  3.5287 -        info->dst += info->dst_pitch;
  3.5288 -    }
  3.5289 -}
  3.5290 -
  3.5291 -void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info)
  3.5292 -{
  3.5293 -    const int flags = info->flags;
  3.5294 -    Uint32 srcpixel;
  3.5295 -    Uint32 srcR, srcG, srcB, srcA;
  3.5296 -    Uint32 dstpixel;
  3.5297 -    Uint32 dstR, dstG, dstB, dstA;
  3.5298 -
  3.5299 -    while (info->dst_h--) {
  3.5300 -        Uint32 *src = (Uint32 *)info->src;
  3.5301 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5302 -        int n = info->dst_w;
  3.5303 -        while (n--) {
  3.5304 -            srcpixel = *src;
  3.5305 -            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  3.5306 -            dstpixel = *dst;
  3.5307 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.5308 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.5309 -                /* This goes away if we ever use premultiplied alpha */
  3.5310 -                if (srcA < 255) {
  3.5311 -                    srcR = (srcR * srcA) / 255;
  3.5312 -                    srcG = (srcG * srcA) / 255;
  3.5313 -                    srcB = (srcB * srcA) / 255;
  3.5314 -                }
  3.5315 -            }
  3.5316 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.5317 -            case SDL_COPY_MASK:
  3.5318 -                if (srcA) {
  3.5319 -                    dstR = srcR;
  3.5320 -                    dstG = srcG;
  3.5321 -                    dstB = srcB;
  3.5322 -                }
  3.5323 -                break;
  3.5324 -            case SDL_COPY_BLEND:
  3.5325 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.5326 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.5327 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.5328 -                break;
  3.5329 -            case SDL_COPY_ADD:
  3.5330 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.5331 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.5332 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.5333 -                break;
  3.5334 -            case SDL_COPY_MOD:
  3.5335 -                dstR = (srcR * dstR) / 255;
  3.5336 -                dstG = (srcG * dstG) / 255;
  3.5337 -                dstB = (srcB * dstB) / 255;
  3.5338 -                break;
  3.5339 -            }
  3.5340 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.5341 -            *dst = dstpixel;
  3.5342 -            ++src;
  3.5343 -            ++dst;
  3.5344 -        }
  3.5345 -        info->src += info->src_pitch;
  3.5346 -        info->dst += info->dst_pitch;
  3.5347 -    }
  3.5348 -}
  3.5349 -
  3.5350 -void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  3.5351 -{
  3.5352 -    const int flags = info->flags;
  3.5353 -    Uint32 srcpixel;
  3.5354 -    Uint32 srcR, srcG, srcB, srcA;
  3.5355 -    Uint32 dstpixel;
  3.5356 -    Uint32 dstR, dstG, dstB, dstA;
  3.5357 -    int srcy, srcx;
  3.5358 -    int posy, posx;
  3.5359 -    int incy, incx;
  3.5360 -
  3.5361 -    srcy = 0;
  3.5362 -    posy = 0;
  3.5363 -    incy = (info->src_h << 16) / info->dst_h;
  3.5364 -    incx = (info->src_w << 16) / info->dst_w;
  3.5365 -
  3.5366 -    while (info->dst_h--) {
  3.5367 -        Uint32 *src;
  3.5368 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5369 -        int n = info->dst_w;
  3.5370 -        srcx = -1;
  3.5371 -        posx = 0x10000L;
  3.5372 -        while (posy >= 0x10000L) {
  3.5373 -            ++srcy;
  3.5374 -            posy -= 0x10000L;
  3.5375 -        }
  3.5376 -        while (n--) {
  3.5377 -            if (posx >= 0x10000L) {
  3.5378 -                while (posx >= 0x10000L) {
  3.5379 -                    ++srcx;
  3.5380 -                    posx -= 0x10000L;
  3.5381 -                }
  3.5382 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.5383 -            }
  3.5384 -            srcpixel = *src;
  3.5385 -            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  3.5386 -            dstpixel = *dst;
  3.5387 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.5388 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.5389 -                /* This goes away if we ever use premultiplied alpha */
  3.5390 -                if (srcA < 255) {
  3.5391 -                    srcR = (srcR * srcA) / 255;
  3.5392 -                    srcG = (srcG * srcA) / 255;
  3.5393 -                    srcB = (srcB * srcA) / 255;
  3.5394 -                }
  3.5395 -            }
  3.5396 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.5397 -            case SDL_COPY_MASK:
  3.5398 -                if (srcA) {
  3.5399 -                    dstR = srcR;
  3.5400 -                    dstG = srcG;
  3.5401 -                    dstB = srcB;
  3.5402 -                }
  3.5403 -                break;
  3.5404 -            case SDL_COPY_BLEND:
  3.5405 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.5406 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.5407 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.5408 -                break;
  3.5409 -            case SDL_COPY_ADD:
  3.5410 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.5411 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.5412 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.5413 -                break;
  3.5414 -            case SDL_COPY_MOD:
  3.5415 -                dstR = (srcR * dstR) / 255;
  3.5416 -                dstG = (srcG * dstG) / 255;
  3.5417 -                dstB = (srcB * dstB) / 255;
  3.5418 -                break;
  3.5419 -            }
  3.5420 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.5421 -            *dst = dstpixel;
  3.5422 -            posx += incx;
  3.5423 -            ++dst;
  3.5424 -        }
  3.5425 -        posy += incy;
  3.5426 -        info->dst += info->dst_pitch;
  3.5427 -    }
  3.5428 -}
  3.5429 -
  3.5430 -void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info)
  3.5431 -{
  3.5432 -    const int flags = info->flags;
  3.5433 -    const Uint32 modulateR = info->r;
  3.5434 -    const Uint32 modulateG = info->g;
  3.5435 -    const Uint32 modulateB = info->b;
  3.5436 -    const Uint32 modulateA = info->a;
  3.5437 -    Uint32 pixel;
  3.5438 -    Uint32 R, G, B, A;
  3.5439 -
  3.5440 -    while (info->dst_h--) {
  3.5441 -        Uint32 *src = (Uint32 *)info->src;
  3.5442 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5443 -        int n = info->dst_w;
  3.5444 -        while (n--) {
  3.5445 -            pixel = *src;
  3.5446 -            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  3.5447 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.5448 -                R = (R * modulateR) / 255;
  3.5449 -                G = (G * modulateG) / 255;
  3.5450 -                B = (B * modulateB) / 255;
  3.5451 -            }
  3.5452 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.5453 -                A = (A * modulateA) / 255;
  3.5454 -            }
  3.5455 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.5456 -            *dst = pixel;
  3.5457 -            ++src;
  3.5458 -            ++dst;
  3.5459 -        }
  3.5460 -        info->src += info->src_pitch;
  3.5461 -        info->dst += info->dst_pitch;
  3.5462 -    }
  3.5463 -}
  3.5464 -
  3.5465 -void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  3.5466 -{
  3.5467 -    const int flags = info->flags;
  3.5468 -    const Uint32 modulateR = info->r;
  3.5469 -    const Uint32 modulateG = info->g;
  3.5470 -    const Uint32 modulateB = info->b;
  3.5471 -    const Uint32 modulateA = info->a;
  3.5472 -    Uint32 pixel;
  3.5473 -    Uint32 R, G, B, A;
  3.5474 -    int srcy, srcx;
  3.5475 -    int posy, posx;
  3.5476 -    int incy, incx;
  3.5477 -
  3.5478 -    srcy = 0;
  3.5479 -    posy = 0;
  3.5480 -    incy = (info->src_h << 16) / info->dst_h;
  3.5481 -    incx = (info->src_w << 16) / info->dst_w;
  3.5482 -
  3.5483 -    while (info->dst_h--) {
  3.5484 -        Uint32 *src;
  3.5485 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5486 -        int n = info->dst_w;
  3.5487 -        srcx = -1;
  3.5488 -        posx = 0x10000L;
  3.5489 -        while (posy >= 0x10000L) {
  3.5490 -            ++srcy;
  3.5491 -            posy -= 0x10000L;
  3.5492 -        }
  3.5493 -        while (n--) {
  3.5494 -            if (posx >= 0x10000L) {
  3.5495 -                while (posx >= 0x10000L) {
  3.5496 -                    ++srcx;
  3.5497 -                    posx -= 0x10000L;
  3.5498 -                }
  3.5499 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.5500 -            }
  3.5501 -            pixel = *src;
  3.5502 -            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  3.5503 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.5504 -                R = (R * modulateR) / 255;
  3.5505 -                G = (G * modulateG) / 255;
  3.5506 -                B = (B * modulateB) / 255;
  3.5507 -            }
  3.5508 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.5509 -                A = (A * modulateA) / 255;
  3.5510 -            }
  3.5511 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.5512 -            *dst = pixel;
  3.5513 -            posx += incx;
  3.5514 -            ++dst;
  3.5515 -        }
  3.5516 -        posy += incy;
  3.5517 -        info->dst += info->dst_pitch;
  3.5518 -    }
  3.5519 -}
  3.5520 -
  3.5521 -void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  3.5522 -{
  3.5523 -    const int flags = info->flags;
  3.5524 -    const Uint32 modulateR = info->r;
  3.5525 -    const Uint32 modulateG = info->g;
  3.5526 -    const Uint32 modulateB = info->b;
  3.5527 -    const Uint32 modulateA = info->a;
  3.5528 -    Uint32 srcpixel;
  3.5529 -    Uint32 srcR, srcG, srcB, srcA;
  3.5530 -    Uint32 dstpixel;
  3.5531 -    Uint32 dstR, dstG, dstB, dstA;
  3.5532 -
  3.5533 -    while (info->dst_h--) {
  3.5534 -        Uint32 *src = (Uint32 *)info->src;
  3.5535 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5536 -        int n = info->dst_w;
  3.5537 -        while (n--) {
  3.5538 -            srcpixel = *src;
  3.5539 -            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  3.5540 -            dstpixel = *dst;
  3.5541 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.5542 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.5543 -                srcR = (srcR * modulateR) / 255;
  3.5544 -                srcG = (srcG * modulateG) / 255;
  3.5545 -                srcB = (srcB * modulateB) / 255;
  3.5546 -            }
  3.5547 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.5548 -                srcA = (srcA * modulateA) / 255;
  3.5549 -            }
  3.5550 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.5551 -                /* This goes away if we ever use premultiplied alpha */
  3.5552 -                if (srcA < 255) {
  3.5553 -                    srcR = (srcR * srcA) / 255;
  3.5554 -                    srcG = (srcG * srcA) / 255;
  3.5555 -                    srcB = (srcB * srcA) / 255;
  3.5556 -                }
  3.5557 -            }
  3.5558 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.5559 -            case SDL_COPY_MASK:
  3.5560 -                if (srcA) {
  3.5561 -                    dstR = srcR;
  3.5562 -                    dstG = srcG;
  3.5563 -                    dstB = srcB;
  3.5564 -                }
  3.5565 -                break;
  3.5566 -            case SDL_COPY_BLEND:
  3.5567 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.5568 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.5569 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.5570 -                break;
  3.5571 -            case SDL_COPY_ADD:
  3.5572 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.5573 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.5574 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.5575 -                break;
  3.5576 -            case SDL_COPY_MOD:
  3.5577 -                dstR = (srcR * dstR) / 255;
  3.5578 -                dstG = (srcG * dstG) / 255;
  3.5579 -                dstB = (srcB * dstB) / 255;
  3.5580 -                break;
  3.5581 -            }
  3.5582 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.5583 -            *dst = dstpixel;
  3.5584 -            ++src;
  3.5585 -            ++dst;
  3.5586 -        }
  3.5587 -        info->src += info->src_pitch;
  3.5588 -        info->dst += info->dst_pitch;
  3.5589 -    }
  3.5590 -}
  3.5591 -
  3.5592 -void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.5593 -{
  3.5594 -    const int flags = info->flags;
  3.5595 -    const Uint32 modulateR = info->r;
  3.5596 -    const Uint32 modulateG = info->g;
  3.5597 -    const Uint32 modulateB = info->b;
  3.5598 -    const Uint32 modulateA = info->a;
  3.5599 -    Uint32 srcpixel;
  3.5600 -    Uint32 srcR, srcG, srcB, srcA;
  3.5601 -    Uint32 dstpixel;
  3.5602 -    Uint32 dstR, dstG, dstB, dstA;
  3.5603 -    int srcy, srcx;
  3.5604 -    int posy, posx;
  3.5605 -    int incy, incx;
  3.5606 -
  3.5607 -    srcy = 0;
  3.5608 -    posy = 0;
  3.5609 -    incy = (info->src_h << 16) / info->dst_h;
  3.5610 -    incx = (info->src_w << 16) / info->dst_w;
  3.5611 -
  3.5612 -    while (info->dst_h--) {
  3.5613 -        Uint32 *src;
  3.5614 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5615 -        int n = info->dst_w;
  3.5616 -        srcx = -1;
  3.5617 -        posx = 0x10000L;
  3.5618 -        while (posy >= 0x10000L) {
  3.5619 -            ++srcy;
  3.5620 -            posy -= 0x10000L;
  3.5621 -        }
  3.5622 -        while (n--) {
  3.5623 -            if (posx >= 0x10000L) {
  3.5624 -                while (posx >= 0x10000L) {
  3.5625 -                    ++srcx;
  3.5626 -                    posx -= 0x10000L;
  3.5627 -                }
  3.5628 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.5629 -            }
  3.5630 -            srcpixel = *src;
  3.5631 -            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  3.5632 -            dstpixel = *dst;
  3.5633 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.5634 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.5635 -                srcR = (srcR * modulateR) / 255;
  3.5636 -                srcG = (srcG * modulateG) / 255;
  3.5637 -                srcB = (srcB * modulateB) / 255;
  3.5638 -            }
  3.5639 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.5640 -                srcA = (srcA * modulateA) / 255;
  3.5641 -            }
  3.5642 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.5643 -                /* This goes away if we ever use premultiplied alpha */
  3.5644 -                if (srcA < 255) {
  3.5645 -                    srcR = (srcR * srcA) / 255;
  3.5646 -                    srcG = (srcG * srcA) / 255;
  3.5647 -                    srcB = (srcB * srcA) / 255;
  3.5648 -                }
  3.5649 -            }
  3.5650 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.5651 -            case SDL_COPY_MASK:
  3.5652 -                if (srcA) {
  3.5653 -                    dstR = srcR;
  3.5654 -                    dstG = srcG;
  3.5655 -                    dstB = srcB;
  3.5656 -                }
  3.5657 -                break;
  3.5658 -            case SDL_COPY_BLEND:
  3.5659 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.5660 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.5661 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.5662 -                break;
  3.5663 -            case SDL_COPY_ADD:
  3.5664 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.5665 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.5666 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.5667 -                break;
  3.5668 -            case SDL_COPY_MOD:
  3.5669 -                dstR = (srcR * dstR) / 255;
  3.5670 -                dstG = (srcG * dstG) / 255;
  3.5671 -                dstB = (srcB * dstB) / 255;
  3.5672 -                break;
  3.5673 -            }
  3.5674 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.5675 -            *dst = dstpixel;
  3.5676 -            posx += incx;
  3.5677 -            ++dst;
  3.5678 -        }
  3.5679 -        posy += incy;
  3.5680 -        info->dst += info->dst_pitch;
  3.5681 -    }
  3.5682 -}
  3.5683 -
  3.5684 -void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info)
  3.5685 -{
  3.5686 -    const int flags = info->flags;
  3.5687 -    Uint32 pixel;
  3.5688 -    Uint32 R, G, B, A;
  3.5689 -    int srcy, srcx;
  3.5690 -    int posy, posx;
  3.5691 -    int incy, incx;
  3.5692 -
  3.5693 -    srcy = 0;
  3.5694 -    posy = 0;
  3.5695 -    incy = (info->src_h << 16) / info->dst_h;
  3.5696 -    incx = (info->src_w << 16) / info->dst_w;
  3.5697 -
  3.5698 -    while (info->dst_h--) {
  3.5699 -        Uint32 *src;
  3.5700 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5701 -        int n = info->dst_w;
  3.5702 -        srcx = -1;
  3.5703 -        posx = 0x10000L;
  3.5704 -        while (posy >= 0x10000L) {
  3.5705 -            ++srcy;
  3.5706 -            posy -= 0x10000L;
  3.5707 -        }
  3.5708 -        while (n--) {
  3.5709 -            if (posx >= 0x10000L) {
  3.5710 -                while (posx >= 0x10000L) {
  3.5711 -                    ++srcx;
  3.5712 -                    posx -= 0x10000L;
  3.5713 -                }
  3.5714 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.5715 -            }
  3.5716 -            pixel = *src;
  3.5717 -            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  3.5718 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.5719 -            *dst = pixel;
  3.5720 -            posx += incx;
  3.5721 -            ++dst;
  3.5722 -        }
  3.5723 -        posy += incy;
  3.5724 -        info->dst += info->dst_pitch;
  3.5725 -    }
  3.5726 -}
  3.5727 -
  3.5728 -void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info)
  3.5729 -{
  3.5730 -    const int flags = info->flags;
  3.5731 -    Uint32 srcpixel;
  3.5732 -    Uint32 srcR, srcG, srcB, srcA;
  3.5733 -    Uint32 dstpixel;
  3.5734 -    Uint32 dstR, dstG, dstB, dstA;
  3.5735 -
  3.5736 -    while (info->dst_h--) {
  3.5737 -        Uint32 *src = (Uint32 *)info->src;
  3.5738 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5739 -        int n = info->dst_w;
  3.5740 -        while (n--) {
  3.5741 -            srcpixel = *src;
  3.5742 -            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  3.5743 -            dstpixel = *dst;
  3.5744 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.5745 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.5746 -                /* This goes away if we ever use premultiplied alpha */
  3.5747 -                if (srcA < 255) {
  3.5748 -                    srcR = (srcR * srcA) / 255;
  3.5749 -                    srcG = (srcG * srcA) / 255;
  3.5750 -                    srcB = (srcB * srcA) / 255;
  3.5751 -                }
  3.5752 -            }
  3.5753 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.5754 -            case SDL_COPY_MASK:
  3.5755 -                if (srcA) {
  3.5756 -                    dstR = srcR;
  3.5757 -                    dstG = srcG;
  3.5758 -                    dstB = srcB;
  3.5759 -                }
  3.5760 -                break;
  3.5761 -            case SDL_COPY_BLEND:
  3.5762 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.5763 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.5764 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.5765 -                break;
  3.5766 -            case SDL_COPY_ADD:
  3.5767 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.5768 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.5769 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.5770 -                break;
  3.5771 -            case SDL_COPY_MOD:
  3.5772 -                dstR = (srcR * dstR) / 255;
  3.5773 -                dstG = (srcG * dstG) / 255;
  3.5774 -                dstB = (srcB * dstB) / 255;
  3.5775 -                break;
  3.5776 -            }
  3.5777 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.5778 -            *dst = dstpixel;
  3.5779 -            ++src;
  3.5780 -            ++dst;
  3.5781 -        }
  3.5782 -        info->src += info->src_pitch;
  3.5783 -        info->dst += info->dst_pitch;
  3.5784 -    }
  3.5785 -}
  3.5786 -
  3.5787 -void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  3.5788 -{
  3.5789 -    const int flags = info->flags;
  3.5790 -    Uint32 srcpixel;
  3.5791 -    Uint32 srcR, srcG, srcB, srcA;
  3.5792 -    Uint32 dstpixel;
  3.5793 -    Uint32 dstR, dstG, dstB, dstA;
  3.5794 -    int srcy, srcx;
  3.5795 -    int posy, posx;
  3.5796 -    int incy, incx;
  3.5797 -
  3.5798 -    srcy = 0;
  3.5799 -    posy = 0;
  3.5800 -    incy = (info->src_h << 16) / info->dst_h;
  3.5801 -    incx = (info->src_w << 16) / info->dst_w;
  3.5802 -
  3.5803 -    while (info->dst_h--) {
  3.5804 -        Uint32 *src;
  3.5805 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5806 -        int n = info->dst_w;
  3.5807 -        srcx = -1;
  3.5808 -        posx = 0x10000L;
  3.5809 -        while (posy >= 0x10000L) {
  3.5810 -            ++srcy;
  3.5811 -            posy -= 0x10000L;
  3.5812 -        }
  3.5813 -        while (n--) {
  3.5814 -            if (posx >= 0x10000L) {
  3.5815 -                while (posx >= 0x10000L) {
  3.5816 -                    ++srcx;
  3.5817 -                    posx -= 0x10000L;
  3.5818 -                }
  3.5819 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.5820 -            }
  3.5821 -            srcpixel = *src;
  3.5822 -            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  3.5823 -            dstpixel = *dst;
  3.5824 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.5825 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.5826 -                /* This goes away if we ever use premultiplied alpha */
  3.5827 -                if (srcA < 255) {
  3.5828 -                    srcR = (srcR * srcA) / 255;
  3.5829 -                    srcG = (srcG * srcA) / 255;
  3.5830 -                    srcB = (srcB * srcA) / 255;
  3.5831 -                }
  3.5832 -            }
  3.5833 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.5834 -            case SDL_COPY_MASK:
  3.5835 -                if (srcA) {
  3.5836 -                    dstR = srcR;
  3.5837 -                    dstG = srcG;
  3.5838 -                    dstB = srcB;
  3.5839 -                }
  3.5840 -                break;
  3.5841 -            case SDL_COPY_BLEND:
  3.5842 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.5843 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.5844 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.5845 -                break;
  3.5846 -            case SDL_COPY_ADD:
  3.5847 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.5848 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.5849 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.5850 -                break;
  3.5851 -            case SDL_COPY_MOD:
  3.5852 -                dstR = (srcR * dstR) / 255;
  3.5853 -                dstG = (srcG * dstG) / 255;
  3.5854 -                dstB = (srcB * dstB) / 255;
  3.5855 -                break;
  3.5856 -            }
  3.5857 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.5858 -            *dst = dstpixel;
  3.5859 -            posx += incx;
  3.5860 -            ++dst;
  3.5861 -        }
  3.5862 -        posy += incy;
  3.5863 -        info->dst += info->dst_pitch;
  3.5864 -    }
  3.5865 -}
  3.5866 -
  3.5867 -void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info)
  3.5868 -{
  3.5869 -    const int flags = info->flags;
  3.5870 -    const Uint32 modulateR = info->r;
  3.5871 -    const Uint32 modulateG = info->g;
  3.5872 -    const Uint32 modulateB = info->b;
  3.5873 -    const Uint32 modulateA = info->a;
  3.5874 -    Uint32 pixel;
  3.5875 -    Uint32 R, G, B, A;
  3.5876 -
  3.5877 -    while (info->dst_h--) {
  3.5878 -        Uint32 *src = (Uint32 *)info->src;
  3.5879 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5880 -        int n = info->dst_w;
  3.5881 -        while (n--) {
  3.5882 -            pixel = *src;
  3.5883 -            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  3.5884 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.5885 -                R = (R * modulateR) / 255;
  3.5886 -                G = (G * modulateG) / 255;
  3.5887 -                B = (B * modulateB) / 255;
  3.5888 -            }
  3.5889 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.5890 -                A = (A * modulateA) / 255;
  3.5891 -            }
  3.5892 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.5893 -            *dst = pixel;
  3.5894 -            ++src;
  3.5895 -            ++dst;
  3.5896 -        }
  3.5897 -        info->src += info->src_pitch;
  3.5898 -        info->dst += info->dst_pitch;
  3.5899 -    }
  3.5900 -}
  3.5901 -
  3.5902 -void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  3.5903 -{
  3.5904 -    const int flags = info->flags;
  3.5905 -    const Uint32 modulateR = info->r;
  3.5906 -    const Uint32 modulateG = info->g;
  3.5907 -    const Uint32 modulateB = info->b;
  3.5908 -    const Uint32 modulateA = info->a;
  3.5909 -    Uint32 pixel;
  3.5910 -    Uint32 R, G, B, A;
  3.5911 -    int srcy, srcx;
  3.5912 -    int posy, posx;
  3.5913 -    int incy, incx;
  3.5914 -
  3.5915 -    srcy = 0;
  3.5916 -    posy = 0;
  3.5917 -    incy = (info->src_h << 16) / info->dst_h;
  3.5918 -    incx = (info->src_w << 16) / info->dst_w;
  3.5919 -
  3.5920 -    while (info->dst_h--) {
  3.5921 -        Uint32 *src;
  3.5922 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5923 -        int n = info->dst_w;
  3.5924 -        srcx = -1;
  3.5925 -        posx = 0x10000L;
  3.5926 -        while (posy >= 0x10000L) {
  3.5927 -            ++srcy;
  3.5928 -            posy -= 0x10000L;
  3.5929 -        }
  3.5930 -        while (n--) {
  3.5931 -            if (posx >= 0x10000L) {
  3.5932 -                while (posx >= 0x10000L) {
  3.5933 -                    ++srcx;
  3.5934 -                    posx -= 0x10000L;
  3.5935 -                }
  3.5936 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.5937 -            }
  3.5938 -            pixel = *src;
  3.5939 -            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  3.5940 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.5941 -                R = (R * modulateR) / 255;
  3.5942 -                G = (G * modulateG) / 255;
  3.5943 -                B = (B * modulateB) / 255;
  3.5944 -            }
  3.5945 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.5946 -                A = (A * modulateA) / 255;
  3.5947 -            }
  3.5948 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.5949 -            *dst = pixel;
  3.5950 -            posx += incx;
  3.5951 -            ++dst;
  3.5952 -        }
  3.5953 -        posy += incy;
  3.5954 -        info->dst += info->dst_pitch;
  3.5955 -    }
  3.5956 -}
  3.5957 -
  3.5958 -void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  3.5959 -{
  3.5960 -    const int flags = info->flags;
  3.5961 -    const Uint32 modulateR = info->r;
  3.5962 -    const Uint32 modulateG = info->g;
  3.5963 -    const Uint32 modulateB = info->b;
  3.5964 -    const Uint32 modulateA = info->a;
  3.5965 -    Uint32 srcpixel;
  3.5966 -    Uint32 srcR, srcG, srcB, srcA;
  3.5967 -    Uint32 dstpixel;
  3.5968 -    Uint32 dstR, dstG, dstB, dstA;
  3.5969 -
  3.5970 -    while (info->dst_h--) {
  3.5971 -        Uint32 *src = (Uint32 *)info->src;
  3.5972 -        Uint32 *dst = (Uint32 *)info->dst;
  3.5973 -        int n = info->dst_w;
  3.5974 -        while (n--) {
  3.5975 -            srcpixel = *src;
  3.5976 -            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  3.5977 -            dstpixel = *dst;
  3.5978 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.5979 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.5980 -                srcR = (srcR * modulateR) / 255;
  3.5981 -                srcG = (srcG * modulateG) / 255;
  3.5982 -                srcB = (srcB * modulateB) / 255;
  3.5983 -            }
  3.5984 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.5985 -                srcA = (srcA * modulateA) / 255;
  3.5986 -            }
  3.5987 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.5988 -                /* This goes away if we ever use premultiplied alpha */
  3.5989 -                if (srcA < 255) {
  3.5990 -                    srcR = (srcR * srcA) / 255;
  3.5991 -                    srcG = (srcG * srcA) / 255;
  3.5992 -                    srcB = (srcB * srcA) / 255;
  3.5993 -                }
  3.5994 -            }
  3.5995 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.5996 -            case SDL_COPY_MASK:
  3.5997 -                if (srcA) {
  3.5998 -                    dstR = srcR;
  3.5999 -                    dstG = srcG;
  3.6000 -                    dstB = srcB;
  3.6001 -                }
  3.6002 -                break;
  3.6003 -            case SDL_COPY_BLEND:
  3.6004 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.6005 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.6006 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.6007 -                break;
  3.6008 -            case SDL_COPY_ADD:
  3.6009 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.6010 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.6011 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.6012 -                break;
  3.6013 -            case SDL_COPY_MOD:
  3.6014 -                dstR = (srcR * dstR) / 255;
  3.6015 -                dstG = (srcG * dstG) / 255;
  3.6016 -                dstB = (srcB * dstB) / 255;
  3.6017 -                break;
  3.6018 -            }
  3.6019 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.6020 -            *dst = dstpixel;
  3.6021 -            ++src;
  3.6022 -            ++dst;
  3.6023 -        }
  3.6024 -        info->src += info->src_pitch;
  3.6025 -        info->dst += info->dst_pitch;
  3.6026 -    }
  3.6027 -}
  3.6028 -
  3.6029 -void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.6030 -{
  3.6031 -    const int flags = info->flags;
  3.6032 -    const Uint32 modulateR = info->r;
  3.6033 -    const Uint32 modulateG = info->g;
  3.6034 -    const Uint32 modulateB = info->b;
  3.6035 -    const Uint32 modulateA = info->a;
  3.6036 -    Uint32 srcpixel;
  3.6037 -    Uint32 srcR, srcG, srcB, srcA;
  3.6038 -    Uint32 dstpixel;
  3.6039 -    Uint32 dstR, dstG, dstB, dstA;
  3.6040 -    int srcy, srcx;
  3.6041 -    int posy, posx;
  3.6042 -    int incy, incx;
  3.6043 -
  3.6044 -    srcy = 0;
  3.6045 -    posy = 0;
  3.6046 -    incy = (info->src_h << 16) / info->dst_h;
  3.6047 -    incx = (info->src_w << 16) / info->dst_w;
  3.6048 -
  3.6049 -    while (info->dst_h--) {
  3.6050 -        Uint32 *src;
  3.6051 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6052 -        int n = info->dst_w;
  3.6053 -        srcx = -1;
  3.6054 -        posx = 0x10000L;
  3.6055 -        while (posy >= 0x10000L) {
  3.6056 -            ++srcy;
  3.6057 -            posy -= 0x10000L;
  3.6058 -        }
  3.6059 -        while (n--) {
  3.6060 -            if (posx >= 0x10000L) {
  3.6061 -                while (posx >= 0x10000L) {
  3.6062 -                    ++srcx;
  3.6063 -                    posx -= 0x10000L;
  3.6064 -                }
  3.6065 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.6066 -            }
  3.6067 -            srcpixel = *src;
  3.6068 -            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  3.6069 -            dstpixel = *dst;
  3.6070 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.6071 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.6072 -                srcR = (srcR * modulateR) / 255;
  3.6073 -                srcG = (srcG * modulateG) / 255;
  3.6074 -                srcB = (srcB * modulateB) / 255;
  3.6075 -            }
  3.6076 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.6077 -                srcA = (srcA * modulateA) / 255;
  3.6078 -            }
  3.6079 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.6080 -                /* This goes away if we ever use premultiplied alpha */
  3.6081 -                if (srcA < 255) {
  3.6082 -                    srcR = (srcR * srcA) / 255;
  3.6083 -                    srcG = (srcG * srcA) / 255;
  3.6084 -                    srcB = (srcB * srcA) / 255;
  3.6085 -                }
  3.6086 -            }
  3.6087 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.6088 -            case SDL_COPY_MASK:
  3.6089 -                if (srcA) {
  3.6090 -                    dstR = srcR;
  3.6091 -                    dstG = srcG;
  3.6092 -                    dstB = srcB;
  3.6093 -                }
  3.6094 -                break;
  3.6095 -            case SDL_COPY_BLEND:
  3.6096 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.6097 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.6098 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.6099 -                break;
  3.6100 -            case SDL_COPY_ADD:
  3.6101 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.6102 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.6103 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.6104 -                break;
  3.6105 -            case SDL_COPY_MOD:
  3.6106 -                dstR = (srcR * dstR) / 255;
  3.6107 -                dstG = (srcG * dstG) / 255;
  3.6108 -                dstB = (srcB * dstB) / 255;
  3.6109 -                break;
  3.6110 -            }
  3.6111 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.6112 -            *dst = dstpixel;
  3.6113 -            posx += incx;
  3.6114 -            ++dst;
  3.6115 -        }
  3.6116 -        posy += incy;
  3.6117 -        info->dst += info->dst_pitch;
  3.6118 -    }
  3.6119 -}
  3.6120 -
  3.6121 -void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info)
  3.6122 -{
  3.6123 -    const int flags = info->flags;
  3.6124 -    Uint32 pixel;
  3.6125 -    Uint32 R, G, B, A;
  3.6126 -    int srcy, srcx;
  3.6127 -    int posy, posx;
  3.6128 -    int incy, incx;
  3.6129 -
  3.6130 -    srcy = 0;
  3.6131 -    posy = 0;
  3.6132 -    incy = (info->src_h << 16) / info->dst_h;
  3.6133 -    incx = (info->src_w << 16) / info->dst_w;
  3.6134 -
  3.6135 -    while (info->dst_h--) {
  3.6136 -        Uint32 *src;
  3.6137 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6138 -        int n = info->dst_w;
  3.6139 -        srcx = -1;
  3.6140 -        posx = 0x10000L;
  3.6141 -        while (posy >= 0x10000L) {
  3.6142 -            ++srcy;
  3.6143 -            posy -= 0x10000L;
  3.6144 -        }
  3.6145 -        while (n--) {
  3.6146 -            if (posx >= 0x10000L) {
  3.6147 -                while (posx >= 0x10000L) {
  3.6148 -                    ++srcx;
  3.6149 -                    posx -= 0x10000L;
  3.6150 -                }
  3.6151 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.6152 -            }
  3.6153 -            pixel = *src;
  3.6154 -            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  3.6155 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.6156 -            *dst = pixel;
  3.6157 -            posx += incx;
  3.6158 -            ++dst;
  3.6159 -        }
  3.6160 -        posy += incy;
  3.6161 -        info->dst += info->dst_pitch;
  3.6162 -    }
  3.6163 -}
  3.6164 -
  3.6165 -void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
  3.6166 -{
  3.6167 -    const int flags = info->flags;
  3.6168 -    Uint32 srcpixel;
  3.6169 -    Uint32 srcR, srcG, srcB, srcA;
  3.6170 -    Uint32 dstpixel;
  3.6171 -    Uint32 dstR, dstG, dstB, dstA;
  3.6172 -
  3.6173 -    while (info->dst_h--) {
  3.6174 -        Uint32 *src = (Uint32 *)info->src;
  3.6175 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6176 -        int n = info->dst_w;
  3.6177 -        while (n--) {
  3.6178 -            srcpixel = *src;
  3.6179 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.6180 -            dstpixel = *dst;
  3.6181 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.6182 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.6183 -                /* This goes away if we ever use premultiplied alpha */
  3.6184 -                if (srcA < 255) {
  3.6185 -                    srcR = (srcR * srcA) / 255;
  3.6186 -                    srcG = (srcG * srcA) / 255;
  3.6187 -                    srcB = (srcB * srcA) / 255;
  3.6188 -                }
  3.6189 -            }
  3.6190 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.6191 -            case SDL_COPY_MASK:
  3.6192 -                if (srcA) {
  3.6193 -                    dstR = srcR;
  3.6194 -                    dstG = srcG;
  3.6195 -                    dstB = srcB;
  3.6196 -                }
  3.6197 -                break;
  3.6198 -            case SDL_COPY_BLEND:
  3.6199 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.6200 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.6201 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.6202 -                break;
  3.6203 -            case SDL_COPY_ADD:
  3.6204 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.6205 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.6206 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.6207 -                break;
  3.6208 -            case SDL_COPY_MOD:
  3.6209 -                dstR = (srcR * dstR) / 255;
  3.6210 -                dstG = (srcG * dstG) / 255;
  3.6211 -                dstB = (srcB * dstB) / 255;
  3.6212 -                break;
  3.6213 -            }
  3.6214 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.6215 -            *dst = dstpixel;
  3.6216 -            ++src;
  3.6217 -            ++dst;
  3.6218 -        }
  3.6219 -        info->src += info->src_pitch;
  3.6220 -        info->dst += info->dst_pitch;
  3.6221 -    }
  3.6222 -}
  3.6223 -
  3.6224 -void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  3.6225 -{
  3.6226 -    const int flags = info->flags;
  3.6227 -    Uint32 srcpixel;
  3.6228 -    Uint32 srcR, srcG, srcB, srcA;
  3.6229 -    Uint32 dstpixel;
  3.6230 -    Uint32 dstR, dstG, dstB, dstA;
  3.6231 -    int srcy, srcx;
  3.6232 -    int posy, posx;
  3.6233 -    int incy, incx;
  3.6234 -
  3.6235 -    srcy = 0;
  3.6236 -    posy = 0;
  3.6237 -    incy = (info->src_h << 16) / info->dst_h;
  3.6238 -    incx = (info->src_w << 16) / info->dst_w;
  3.6239 -
  3.6240 -    while (info->dst_h--) {
  3.6241 -        Uint32 *src;
  3.6242 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6243 -        int n = info->dst_w;
  3.6244 -        srcx = -1;
  3.6245 -        posx = 0x10000L;
  3.6246 -        while (posy >= 0x10000L) {
  3.6247 -            ++srcy;
  3.6248 -            posy -= 0x10000L;
  3.6249 -        }
  3.6250 -        while (n--) {
  3.6251 -            if (posx >= 0x10000L) {
  3.6252 -                while (posx >= 0x10000L) {
  3.6253 -                    ++srcx;
  3.6254 -                    posx -= 0x10000L;
  3.6255 -                }
  3.6256 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.6257 -            }
  3.6258 -            srcpixel = *src;
  3.6259 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.6260 -            dstpixel = *dst;
  3.6261 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.6262 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.6263 -                /* This goes away if we ever use premultiplied alpha */
  3.6264 -                if (srcA < 255) {
  3.6265 -                    srcR = (srcR * srcA) / 255;
  3.6266 -                    srcG = (srcG * srcA) / 255;
  3.6267 -                    srcB = (srcB * srcA) / 255;
  3.6268 -                }
  3.6269 -            }
  3.6270 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.6271 -            case SDL_COPY_MASK:
  3.6272 -                if (srcA) {
  3.6273 -                    dstR = srcR;
  3.6274 -                    dstG = srcG;
  3.6275 -                    dstB = srcB;
  3.6276 -                }
  3.6277 -                break;
  3.6278 -            case SDL_COPY_BLEND:
  3.6279 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.6280 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.6281 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.6282 -                break;
  3.6283 -            case SDL_COPY_ADD:
  3.6284 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.6285 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.6286 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.6287 -                break;
  3.6288 -            case SDL_COPY_MOD:
  3.6289 -                dstR = (srcR * dstR) / 255;
  3.6290 -                dstG = (srcG * dstG) / 255;
  3.6291 -                dstB = (srcB * dstB) / 255;
  3.6292 -                break;
  3.6293 -            }
  3.6294 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.6295 -            *dst = dstpixel;
  3.6296 -            posx += incx;
  3.6297 -            ++dst;
  3.6298 -        }
  3.6299 -        posy += incy;
  3.6300 -        info->dst += info->dst_pitch;
  3.6301 -    }
  3.6302 -}
  3.6303 -
  3.6304 -void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info)
  3.6305 -{
  3.6306 -    const int flags = info->flags;
  3.6307 -    const Uint32 modulateR = info->r;
  3.6308 -    const Uint32 modulateG = info->g;
  3.6309 -    const Uint32 modulateB = info->b;
  3.6310 -    const Uint32 modulateA = info->a;
  3.6311 -    Uint32 pixel;
  3.6312 -    Uint32 R, G, B, A;
  3.6313 -
  3.6314 -    while (info->dst_h--) {
  3.6315 -        Uint32 *src = (Uint32 *)info->src;
  3.6316 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6317 -        int n = info->dst_w;
  3.6318 -        while (n--) {
  3.6319 -            pixel = *src;
  3.6320 -            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  3.6321 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.6322 -                R = (R * modulateR) / 255;
  3.6323 -                G = (G * modulateG) / 255;
  3.6324 -                B = (B * modulateB) / 255;
  3.6325 -            }
  3.6326 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.6327 -                A = (A * modulateA) / 255;
  3.6328 -            }
  3.6329 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.6330 -            *dst = pixel;
  3.6331 -            ++src;
  3.6332 -            ++dst;
  3.6333 -        }
  3.6334 -        info->src += info->src_pitch;
  3.6335 -        info->dst += info->dst_pitch;
  3.6336 -    }
  3.6337 -}
  3.6338 -
  3.6339 -void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  3.6340 -{
  3.6341 -    const int flags = info->flags;
  3.6342 -    const Uint32 modulateR = info->r;
  3.6343 -    const Uint32 modulateG = info->g;
  3.6344 -    const Uint32 modulateB = info->b;
  3.6345 -    const Uint32 modulateA = info->a;
  3.6346 -    Uint32 pixel;
  3.6347 -    Uint32 R, G, B, A;
  3.6348 -    int srcy, srcx;
  3.6349 -    int posy, posx;
  3.6350 -    int incy, incx;
  3.6351 -
  3.6352 -    srcy = 0;
  3.6353 -    posy = 0;
  3.6354 -    incy = (info->src_h << 16) / info->dst_h;
  3.6355 -    incx = (info->src_w << 16) / info->dst_w;
  3.6356 -
  3.6357 -    while (info->dst_h--) {
  3.6358 -        Uint32 *src;
  3.6359 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6360 -        int n = info->dst_w;
  3.6361 -        srcx = -1;
  3.6362 -        posx = 0x10000L;
  3.6363 -        while (posy >= 0x10000L) {
  3.6364 -            ++srcy;
  3.6365 -            posy -= 0x10000L;
  3.6366 -        }
  3.6367 -        while (n--) {
  3.6368 -            if (posx >= 0x10000L) {
  3.6369 -                while (posx >= 0x10000L) {
  3.6370 -                    ++srcx;
  3.6371 -                    posx -= 0x10000L;
  3.6372 -                }
  3.6373 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.6374 -            }
  3.6375 -            pixel = *src;
  3.6376 -            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  3.6377 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.6378 -                R = (R * modulateR) / 255;
  3.6379 -                G = (G * modulateG) / 255;
  3.6380 -                B = (B * modulateB) / 255;
  3.6381 -            }
  3.6382 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.6383 -                A = (A * modulateA) / 255;
  3.6384 -            }
  3.6385 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.6386 -            *dst = pixel;
  3.6387 -            posx += incx;
  3.6388 -            ++dst;
  3.6389 -        }
  3.6390 -        posy += incy;
  3.6391 -        info->dst += info->dst_pitch;
  3.6392 -    }
  3.6393 -}
  3.6394 -
  3.6395 -void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  3.6396 -{
  3.6397 -    const int flags = info->flags;
  3.6398 -    const Uint32 modulateR = info->r;
  3.6399 -    const Uint32 modulateG = info->g;
  3.6400 -    const Uint32 modulateB = info->b;
  3.6401 -    const Uint32 modulateA = info->a;
  3.6402 -    Uint32 srcpixel;
  3.6403 -    Uint32 srcR, srcG, srcB, srcA;
  3.6404 -    Uint32 dstpixel;
  3.6405 -    Uint32 dstR, dstG, dstB, dstA;
  3.6406 -
  3.6407 -    while (info->dst_h--) {
  3.6408 -        Uint32 *src = (Uint32 *)info->src;
  3.6409 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6410 -        int n = info->dst_w;
  3.6411 -        while (n--) {
  3.6412 -            srcpixel = *src;
  3.6413 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.6414 -            dstpixel = *dst;
  3.6415 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.6416 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.6417 -                srcR = (srcR * modulateR) / 255;
  3.6418 -                srcG = (srcG * modulateG) / 255;
  3.6419 -                srcB = (srcB * modulateB) / 255;
  3.6420 -            }
  3.6421 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.6422 -                srcA = (srcA * modulateA) / 255;
  3.6423 -            }
  3.6424 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.6425 -                /* This goes away if we ever use premultiplied alpha */
  3.6426 -                if (srcA < 255) {
  3.6427 -                    srcR = (srcR * srcA) / 255;
  3.6428 -                    srcG = (srcG * srcA) / 255;
  3.6429 -                    srcB = (srcB * srcA) / 255;
  3.6430 -                }
  3.6431 -            }
  3.6432 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.6433 -            case SDL_COPY_MASK:
  3.6434 -                if (srcA) {
  3.6435 -                    dstR = srcR;
  3.6436 -                    dstG = srcG;
  3.6437 -                    dstB = srcB;
  3.6438 -                }
  3.6439 -                break;
  3.6440 -            case SDL_COPY_BLEND:
  3.6441 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.6442 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.6443 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.6444 -                break;
  3.6445 -            case SDL_COPY_ADD:
  3.6446 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.6447 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.6448 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.6449 -                break;
  3.6450 -            case SDL_COPY_MOD:
  3.6451 -                dstR = (srcR * dstR) / 255;
  3.6452 -                dstG = (srcG * dstG) / 255;
  3.6453 -                dstB = (srcB * dstB) / 255;
  3.6454 -                break;
  3.6455 -            }
  3.6456 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.6457 -            *dst = dstpixel;
  3.6458 -            ++src;
  3.6459 -            ++dst;
  3.6460 -        }
  3.6461 -        info->src += info->src_pitch;
  3.6462 -        info->dst += info->dst_pitch;
  3.6463 -    }
  3.6464 -}
  3.6465 -
  3.6466 -void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.6467 -{
  3.6468 -    const int flags = info->flags;
  3.6469 -    const Uint32 modulateR = info->r;
  3.6470 -    const Uint32 modulateG = info->g;
  3.6471 -    const Uint32 modulateB = info->b;
  3.6472 -    const Uint32 modulateA = info->a;
  3.6473 -    Uint32 srcpixel;
  3.6474 -    Uint32 srcR, srcG, srcB, srcA;
  3.6475 -    Uint32 dstpixel;
  3.6476 -    Uint32 dstR, dstG, dstB, dstA;
  3.6477 -    int srcy, srcx;
  3.6478 -    int posy, posx;
  3.6479 -    int incy, incx;
  3.6480 -
  3.6481 -    srcy = 0;
  3.6482 -    posy = 0;
  3.6483 -    incy = (info->src_h << 16) / info->dst_h;
  3.6484 -    incx = (info->src_w << 16) / info->dst_w;
  3.6485 -
  3.6486 -    while (info->dst_h--) {
  3.6487 -        Uint32 *src;
  3.6488 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6489 -        int n = info->dst_w;
  3.6490 -        srcx = -1;
  3.6491 -        posx = 0x10000L;
  3.6492 -        while (posy >= 0x10000L) {
  3.6493 -            ++srcy;
  3.6494 -            posy -= 0x10000L;
  3.6495 -        }
  3.6496 -        while (n--) {
  3.6497 -            if (posx >= 0x10000L) {
  3.6498 -                while (posx >= 0x10000L) {
  3.6499 -                    ++srcx;
  3.6500 -                    posx -= 0x10000L;
  3.6501 -                }
  3.6502 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.6503 -            }
  3.6504 -            srcpixel = *src;
  3.6505 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.6506 -            dstpixel = *dst;
  3.6507 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.6508 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.6509 -                srcR = (srcR * modulateR) / 255;
  3.6510 -                srcG = (srcG * modulateG) / 255;
  3.6511 -                srcB = (srcB * modulateB) / 255;
  3.6512 -            }
  3.6513 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.6514 -                srcA = (srcA * modulateA) / 255;
  3.6515 -            }
  3.6516 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.6517 -                /* This goes away if we ever use premultiplied alpha */
  3.6518 -                if (srcA < 255) {
  3.6519 -                    srcR = (srcR * srcA) / 255;
  3.6520 -                    srcG = (srcG * srcA) / 255;
  3.6521 -                    srcB = (srcB * srcA) / 255;
  3.6522 -                }
  3.6523 -            }
  3.6524 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.6525 -            case SDL_COPY_MASK:
  3.6526 -                if (srcA) {
  3.6527 -                    dstR = srcR;
  3.6528 -                    dstG = srcG;
  3.6529 -                    dstB = srcB;
  3.6530 -                }
  3.6531 -                break;
  3.6532 -            case SDL_COPY_BLEND:
  3.6533 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.6534 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.6535 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.6536 -                break;
  3.6537 -            case SDL_COPY_ADD:
  3.6538 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.6539 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.6540 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.6541 -                break;
  3.6542 -            case SDL_COPY_MOD:
  3.6543 -                dstR = (srcR * dstR) / 255;
  3.6544 -                dstG = (srcG * dstG) / 255;
  3.6545 -                dstB = (srcB * dstB) / 255;
  3.6546 -                break;
  3.6547 -            }
  3.6548 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.6549 -            *dst = dstpixel;
  3.6550 -            posx += incx;
  3.6551 -            ++dst;
  3.6552 -        }
  3.6553 -        posy += incy;
  3.6554 -        info->dst += info->dst_pitch;
  3.6555 -    }
  3.6556 -}
  3.6557 -
  3.6558 -void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info)
  3.6559 -{
  3.6560 -    const int flags = info->flags;
  3.6561 -    int srcy, srcx;
  3.6562 -    int posy, posx;
  3.6563 -    int incy, incx;
  3.6564 -
  3.6565 -    srcy = 0;
  3.6566 -    posy = 0;
  3.6567 -    incy = (info->src_h << 16) / info->dst_h;
  3.6568 -    incx = (info->src_w << 16) / info->dst_w;
  3.6569 -
  3.6570 -    while (info->dst_h--) {
  3.6571 -        Uint32 *src;
  3.6572 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6573 -        int n = info->dst_w;
  3.6574 -        srcx = -1;
  3.6575 -        posx = 0x10000L;
  3.6576 -        while (posy >= 0x10000L) {
  3.6577 -            ++srcy;
  3.6578 -            posy -= 0x10000L;
  3.6579 -        }
  3.6580 -        while (n--) {
  3.6581 -            if (posx >= 0x10000L) {
  3.6582 -                while (posx >= 0x10000L) {
  3.6583 -                    ++srcx;
  3.6584 -                    posx -= 0x10000L;
  3.6585 -                }
  3.6586 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.6587 -            }
  3.6588 -            *dst = *src;
  3.6589 -            posx += incx;
  3.6590 -            ++dst;
  3.6591 -        }
  3.6592 -        posy += incy;
  3.6593 -        info->dst += info->dst_pitch;
  3.6594 -    }
  3.6595 -}
  3.6596 -
  3.6597 -void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info)
  3.6598 -{
  3.6599 -    const int flags = info->flags;
  3.6600 -    Uint32 srcpixel;
  3.6601 -    Uint32 srcR, srcG, srcB, srcA;
  3.6602 -    Uint32 dstpixel;
  3.6603 -    Uint32 dstR, dstG, dstB, dstA;
  3.6604 -
  3.6605 -    while (info->dst_h--) {
  3.6606 -        Uint32 *src = (Uint32 *)info->src;
  3.6607 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6608 -        int n = info->dst_w;
  3.6609 -        while (n--) {
  3.6610 -            srcpixel = *src;
  3.6611 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.6612 -            dstpixel = *dst;
  3.6613 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.6614 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.6615 -                /* This goes away if we ever use premultiplied alpha */
  3.6616 -                if (srcA < 255) {
  3.6617 -                    srcR = (srcR * srcA) / 255;
  3.6618 -                    srcG = (srcG * srcA) / 255;
  3.6619 -                    srcB = (srcB * srcA) / 255;
  3.6620 -                }
  3.6621 -            }
  3.6622 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.6623 -            case SDL_COPY_MASK:
  3.6624 -                if (srcA) {
  3.6625 -                    dstR = srcR;
  3.6626 -                    dstG = srcG;
  3.6627 -                    dstB = srcB;
  3.6628 -                }
  3.6629 -                break;
  3.6630 -            case SDL_COPY_BLEND:
  3.6631 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.6632 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.6633 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.6634 -                break;
  3.6635 -            case SDL_COPY_ADD:
  3.6636 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.6637 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.6638 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.6639 -                break;
  3.6640 -            case SDL_COPY_MOD:
  3.6641 -                dstR = (srcR * dstR) / 255;
  3.6642 -                dstG = (srcG * dstG) / 255;
  3.6643 -                dstB = (srcB * dstB) / 255;
  3.6644 -                break;
  3.6645 -            }
  3.6646 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.6647 -            *dst = dstpixel;
  3.6648 -            ++src;
  3.6649 -            ++dst;
  3.6650 -        }
  3.6651 -        info->src += info->src_pitch;
  3.6652 -        info->dst += info->dst_pitch;
  3.6653 -    }
  3.6654 -}
  3.6655 -
  3.6656 -void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  3.6657 -{
  3.6658 -    const int flags = info->flags;
  3.6659 -    Uint32 srcpixel;
  3.6660 -    Uint32 srcR, srcG, srcB, srcA;
  3.6661 -    Uint32 dstpixel;
  3.6662 -    Uint32 dstR, dstG, dstB, dstA;
  3.6663 -    int srcy, srcx;
  3.6664 -    int posy, posx;
  3.6665 -    int incy, incx;
  3.6666 -
  3.6667 -    srcy = 0;
  3.6668 -    posy = 0;
  3.6669 -    incy = (info->src_h << 16) / info->dst_h;
  3.6670 -    incx = (info->src_w << 16) / info->dst_w;
  3.6671 -
  3.6672 -    while (info->dst_h--) {
  3.6673 -        Uint32 *src;
  3.6674 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6675 -        int n = info->dst_w;
  3.6676 -        srcx = -1;
  3.6677 -        posx = 0x10000L;
  3.6678 -        while (posy >= 0x10000L) {
  3.6679 -            ++srcy;
  3.6680 -            posy -= 0x10000L;
  3.6681 -        }
  3.6682 -        while (n--) {
  3.6683 -            if (posx >= 0x10000L) {
  3.6684 -                while (posx >= 0x10000L) {
  3.6685 -                    ++srcx;
  3.6686 -                    posx -= 0x10000L;
  3.6687 -                }
  3.6688 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.6689 -            }
  3.6690 -            srcpixel = *src;
  3.6691 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.6692 -            dstpixel = *dst;
  3.6693 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.6694 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.6695 -                /* This goes away if we ever use premultiplied alpha */
  3.6696 -                if (srcA < 255) {
  3.6697 -                    srcR = (srcR * srcA) / 255;
  3.6698 -                    srcG = (srcG * srcA) / 255;
  3.6699 -                    srcB = (srcB * srcA) / 255;
  3.6700 -                }
  3.6701 -            }
  3.6702 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.6703 -            case SDL_COPY_MASK:
  3.6704 -                if (srcA) {
  3.6705 -                    dstR = srcR;
  3.6706 -                    dstG = srcG;
  3.6707 -                    dstB = srcB;
  3.6708 -                }
  3.6709 -                break;
  3.6710 -            case SDL_COPY_BLEND:
  3.6711 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.6712 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.6713 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.6714 -                break;
  3.6715 -            case SDL_COPY_ADD:
  3.6716 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.6717 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.6718 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.6719 -                break;
  3.6720 -            case SDL_COPY_MOD:
  3.6721 -                dstR = (srcR * dstR) / 255;
  3.6722 -                dstG = (srcG * dstG) / 255;
  3.6723 -                dstB = (srcB * dstB) / 255;
  3.6724 -                break;
  3.6725 -            }
  3.6726 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.6727 -            *dst = dstpixel;
  3.6728 -            posx += incx;
  3.6729 -            ++dst;
  3.6730 -        }
  3.6731 -        posy += incy;
  3.6732 -        info->dst += info->dst_pitch;
  3.6733 -    }
  3.6734 -}
  3.6735 -
  3.6736 -void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info)
  3.6737 -{
  3.6738 -    const int flags = info->flags;
  3.6739 -    const Uint32 modulateR = info->r;
  3.6740 -    const Uint32 modulateG = info->g;
  3.6741 -    const Uint32 modulateB = info->b;
  3.6742 -    const Uint32 modulateA = info->a;
  3.6743 -    Uint32 pixel;
  3.6744 -    Uint32 R, G, B, A;
  3.6745 -
  3.6746 -    while (info->dst_h--) {
  3.6747 -        Uint32 *src = (Uint32 *)info->src;
  3.6748 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6749 -        int n = info->dst_w;
  3.6750 -        while (n--) {
  3.6751 -            pixel = *src;
  3.6752 -            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  3.6753 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.6754 -                R = (R * modulateR) / 255;
  3.6755 -                G = (G * modulateG) / 255;
  3.6756 -                B = (B * modulateB) / 255;
  3.6757 -            }
  3.6758 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.6759 -                A = (A * modulateA) / 255;
  3.6760 -            }
  3.6761 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.6762 -            *dst = pixel;
  3.6763 -            ++src;
  3.6764 -            ++dst;
  3.6765 -        }
  3.6766 -        info->src += info->src_pitch;
  3.6767 -        info->dst += info->dst_pitch;
  3.6768 -    }
  3.6769 -}
  3.6770 -
  3.6771 -void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  3.6772 -{
  3.6773 -    const int flags = info->flags;
  3.6774 -    const Uint32 modulateR = info->r;
  3.6775 -    const Uint32 modulateG = info->g;
  3.6776 -    const Uint32 modulateB = info->b;
  3.6777 -    const Uint32 modulateA = info->a;
  3.6778 -    Uint32 pixel;
  3.6779 -    Uint32 R, G, B, A;
  3.6780 -    int srcy, srcx;
  3.6781 -    int posy, posx;
  3.6782 -    int incy, incx;
  3.6783 -
  3.6784 -    srcy = 0;
  3.6785 -    posy = 0;
  3.6786 -    incy = (info->src_h << 16) / info->dst_h;
  3.6787 -    incx = (info->src_w << 16) / info->dst_w;
  3.6788 -
  3.6789 -    while (info->dst_h--) {
  3.6790 -        Uint32 *src;
  3.6791 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6792 -        int n = info->dst_w;
  3.6793 -        srcx = -1;
  3.6794 -        posx = 0x10000L;
  3.6795 -        while (posy >= 0x10000L) {
  3.6796 -            ++srcy;
  3.6797 -            posy -= 0x10000L;
  3.6798 -        }
  3.6799 -        while (n--) {
  3.6800 -            if (posx >= 0x10000L) {
  3.6801 -                while (posx >= 0x10000L) {
  3.6802 -                    ++srcx;
  3.6803 -                    posx -= 0x10000L;
  3.6804 -                }
  3.6805 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.6806 -            }
  3.6807 -            pixel = *src;
  3.6808 -            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  3.6809 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.6810 -                R = (R * modulateR) / 255;
  3.6811 -                G = (G * modulateG) / 255;
  3.6812 -                B = (B * modulateB) / 255;
  3.6813 -            }
  3.6814 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.6815 -                A = (A * modulateA) / 255;
  3.6816 -            }
  3.6817 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.6818 -            *dst = pixel;
  3.6819 -            posx += incx;
  3.6820 -            ++dst;
  3.6821 -        }
  3.6822 -        posy += incy;
  3.6823 -        info->dst += info->dst_pitch;
  3.6824 -    }
  3.6825 -}
  3.6826 -
  3.6827 -void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  3.6828 -{
  3.6829 -    const int flags = info->flags;
  3.6830 -    const Uint32 modulateR = info->r;
  3.6831 -    const Uint32 modulateG = info->g;
  3.6832 -    const Uint32 modulateB = info->b;
  3.6833 -    const Uint32 modulateA = info->a;
  3.6834 -    Uint32 srcpixel;
  3.6835 -    Uint32 srcR, srcG, srcB, srcA;
  3.6836 -    Uint32 dstpixel;
  3.6837 -    Uint32 dstR, dstG, dstB, dstA;
  3.6838 -
  3.6839 -    while (info->dst_h--) {
  3.6840 -        Uint32 *src = (Uint32 *)info->src;
  3.6841 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6842 -        int n = info->dst_w;
  3.6843 -        while (n--) {
  3.6844 -            srcpixel = *src;
  3.6845 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.6846 -            dstpixel = *dst;
  3.6847 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.6848 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.6849 -                srcR = (srcR * modulateR) / 255;
  3.6850 -                srcG = (srcG * modulateG) / 255;
  3.6851 -                srcB = (srcB * modulateB) / 255;
  3.6852 -            }
  3.6853 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.6854 -                srcA = (srcA * modulateA) / 255;
  3.6855 -            }
  3.6856 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.6857 -                /* This goes away if we ever use premultiplied alpha */
  3.6858 -                if (srcA < 255) {
  3.6859 -                    srcR = (srcR * srcA) / 255;
  3.6860 -                    srcG = (srcG * srcA) / 255;
  3.6861 -                    srcB = (srcB * srcA) / 255;
  3.6862 -                }
  3.6863 -            }
  3.6864 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.6865 -            case SDL_COPY_MASK:
  3.6866 -                if (srcA) {
  3.6867 -                    dstR = srcR;
  3.6868 -                    dstG = srcG;
  3.6869 -                    dstB = srcB;
  3.6870 -                }
  3.6871 -                break;
  3.6872 -            case SDL_COPY_BLEND:
  3.6873 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.6874 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.6875 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.6876 -                break;
  3.6877 -            case SDL_COPY_ADD:
  3.6878 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.6879 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.6880 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.6881 -                break;
  3.6882 -            case SDL_COPY_MOD:
  3.6883 -                dstR = (srcR * dstR) / 255;
  3.6884 -                dstG = (srcG * dstG) / 255;
  3.6885 -                dstB = (srcB * dstB) / 255;
  3.6886 -                break;
  3.6887 -            }
  3.6888 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.6889 -            *dst = dstpixel;
  3.6890 -            ++src;
  3.6891 -            ++dst;
  3.6892 -        }
  3.6893 -        info->src += info->src_pitch;
  3.6894 -        info->dst += info->dst_pitch;
  3.6895 -    }
  3.6896 -}
  3.6897 -
  3.6898 -void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.6899 -{
  3.6900 -    const int flags = info->flags;
  3.6901 -    const Uint32 modulateR = info->r;
  3.6902 -    const Uint32 modulateG = info->g;
  3.6903 -    const Uint32 modulateB = info->b;
  3.6904 -    const Uint32 modulateA = info->a;
  3.6905 -    Uint32 srcpixel;
  3.6906 -    Uint32 srcR, srcG, srcB, srcA;
  3.6907 -    Uint32 dstpixel;
  3.6908 -    Uint32 dstR, dstG, dstB, dstA;
  3.6909 -    int srcy, srcx;
  3.6910 -    int posy, posx;
  3.6911 -    int incy, incx;
  3.6912 -
  3.6913 -    srcy = 0;
  3.6914 -    posy = 0;
  3.6915 -    incy = (info->src_h << 16) / info->dst_h;
  3.6916 -    incx = (info->src_w << 16) / info->dst_w;
  3.6917 -
  3.6918 -    while (info->dst_h--) {
  3.6919 -        Uint32 *src;
  3.6920 -        Uint32 *dst = (Uint32 *)info->dst;
  3.6921 -        int n = info->dst_w;
  3.6922 -        srcx = -1;
  3.6923 -        posx = 0x10000L;
  3.6924 -        while (posy >= 0x10000L) {
  3.6925 -            ++srcy;
  3.6926 -            posy -= 0x10000L;
  3.6927 -        }
  3.6928 -        while (n--) {
  3.6929 -            if (posx >= 0x10000L) {
  3.6930 -                while (posx >= 0x10000L) {
  3.6931 -                    ++srcx;
  3.6932 -                    posx -= 0x10000L;
  3.6933 -                }
  3.6934 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.6935 -            }
  3.6936 -            srcpixel = *src;
  3.6937 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  3.6938 -            dstpixel = *dst;
  3.6939 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.6940 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.6941 -                srcR = (srcR * modulateR) / 255;
  3.6942 -                srcG = (srcG * modulateG) / 255;
  3.6943 -                srcB = (srcB * modulateB) / 255;
  3.6944 -            }
  3.6945 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.6946 -                srcA = (srcA * modulateA) / 255;
  3.6947 -            }
  3.6948 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.6949 -                /* This goes away if we ever use premultiplied alpha */
  3.6950 -                if (srcA < 255) {
  3.6951 -                    srcR = (srcR * srcA) / 255;
  3.6952 -                    srcG = (srcG * srcA) / 255;
  3.6953 -                    srcB = (srcB * srcA) / 255;
  3.6954 -                }
  3.6955 -            }
  3.6956 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.6957 -            case SDL_COPY_MASK:
  3.6958 -                if (srcA) {
  3.6959 -                    dstR = srcR;
  3.6960 -                    dstG = srcG;
  3.6961 -                    dstB = srcB;
  3.6962 -                }
  3.6963 -                break;
  3.6964 -            case SDL_COPY_BLEND:
  3.6965 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.6966 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.6967 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.6968 -                break;
  3.6969 -            case SDL_COPY_ADD:
  3.6970 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.6971 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.6972 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.6973 -                break;
  3.6974 -            case SDL_COPY_MOD:
  3.6975 -                dstR = (srcR * dstR) / 255;
  3.6976 -                dstG = (srcG * dstG) / 255;
  3.6977 -                dstB = (srcB * dstB) / 255;
  3.6978 -                break;
  3.6979 -            }
  3.6980 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.6981 -            *dst = dstpixel;
  3.6982 -            posx += incx;
  3.6983 -            ++dst;
  3.6984 -        }
  3.6985 -        posy += incy;
  3.6986 -        info->dst += info->dst_pitch;
  3.6987 -    }
  3.6988 -}
  3.6989 -
  3.6990 -void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
  3.6991 -{
  3.6992 -    const int flags = info->flags;
  3.6993 -    Uint32 pixel;
  3.6994 -    Uint32 R, G, B, A;
  3.6995 -    int srcy, srcx;
  3.6996 -    int posy, posx;
  3.6997 -    int incy, incx;
  3.6998 -
  3.6999 -    srcy = 0;
  3.7000 -    posy = 0;
  3.7001 -    incy = (info->src_h << 16) / info->dst_h;
  3.7002 -    incx = (info->src_w << 16) / info->dst_w;
  3.7003 -
  3.7004 -    while (info->dst_h--) {
  3.7005 -        Uint32 *src;
  3.7006 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7007 -        int n = info->dst_w;
  3.7008 -        srcx = -1;
  3.7009 -        posx = 0x10000L;
  3.7010 -        while (posy >= 0x10000L) {
  3.7011 -            ++srcy;
  3.7012 -            posy -= 0x10000L;
  3.7013 -        }
  3.7014 -        while (n--) {
  3.7015 -            if (posx >= 0x10000L) {
  3.7016 -                while (posx >= 0x10000L) {
  3.7017 -                    ++srcx;
  3.7018 -                    posx -= 0x10000L;
  3.7019 -                }
  3.7020 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.7021 -            }
  3.7022 -            pixel = *src;
  3.7023 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.7024 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.7025 -            *dst = pixel;
  3.7026 -            posx += incx;
  3.7027 -            ++dst;
  3.7028 -        }
  3.7029 -        posy += incy;
  3.7030 -        info->dst += info->dst_pitch;
  3.7031 -    }
  3.7032 -}
  3.7033 -
  3.7034 -void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info)
  3.7035 -{
  3.7036 -    const int flags = info->flags;
  3.7037 -    Uint32 srcpixel;
  3.7038 -    Uint32 srcR, srcG, srcB, srcA;
  3.7039 -    Uint32 dstpixel;
  3.7040 -    Uint32 dstR, dstG, dstB, dstA;
  3.7041 -
  3.7042 -    while (info->dst_h--) {
  3.7043 -        Uint32 *src = (Uint32 *)info->src;
  3.7044 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7045 -        int n = info->dst_w;
  3.7046 -        while (n--) {
  3.7047 -            srcpixel = *src;
  3.7048 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.7049 -            dstpixel = *dst;
  3.7050 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.7051 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.7052 -                /* This goes away if we ever use premultiplied alpha */
  3.7053 -                if (srcA < 255) {
  3.7054 -                    srcR = (srcR * srcA) / 255;
  3.7055 -                    srcG = (srcG * srcA) / 255;
  3.7056 -                    srcB = (srcB * srcA) / 255;
  3.7057 -                }
  3.7058 -            }
  3.7059 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.7060 -            case SDL_COPY_MASK:
  3.7061 -                if (srcA) {
  3.7062 -                    dstR = srcR;
  3.7063 -                    dstG = srcG;
  3.7064 -                    dstB = srcB;
  3.7065 -                }
  3.7066 -                break;
  3.7067 -            case SDL_COPY_BLEND:
  3.7068 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.7069 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.7070 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.7071 -                break;
  3.7072 -            case SDL_COPY_ADD:
  3.7073 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.7074 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.7075 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.7076 -                break;
  3.7077 -            case SDL_COPY_MOD:
  3.7078 -                dstR = (srcR * dstR) / 255;
  3.7079 -                dstG = (srcG * dstG) / 255;
  3.7080 -                dstB = (srcB * dstB) / 255;
  3.7081 -                break;
  3.7082 -            }
  3.7083 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.7084 -            *dst = dstpixel;
  3.7085 -            ++src;
  3.7086 -            ++dst;
  3.7087 -        }
  3.7088 -        info->src += info->src_pitch;
  3.7089 -        info->dst += info->dst_pitch;
  3.7090 -    }
  3.7091 -}
  3.7092 -
  3.7093 -void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  3.7094 -{
  3.7095 -    const int flags = info->flags;
  3.7096 -    Uint32 srcpixel;
  3.7097 -    Uint32 srcR, srcG, srcB, srcA;
  3.7098 -    Uint32 dstpixel;
  3.7099 -    Uint32 dstR, dstG, dstB, dstA;
  3.7100 -    int srcy, srcx;
  3.7101 -    int posy, posx;
  3.7102 -    int incy, incx;
  3.7103 -
  3.7104 -    srcy = 0;
  3.7105 -    posy = 0;
  3.7106 -    incy = (info->src_h << 16) / info->dst_h;
  3.7107 -    incx = (info->src_w << 16) / info->dst_w;
  3.7108 -
  3.7109 -    while (info->dst_h--) {
  3.7110 -        Uint32 *src;
  3.7111 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7112 -        int n = info->dst_w;
  3.7113 -        srcx = -1;
  3.7114 -        posx = 0x10000L;
  3.7115 -        while (posy >= 0x10000L) {
  3.7116 -            ++srcy;
  3.7117 -            posy -= 0x10000L;
  3.7118 -        }
  3.7119 -        while (n--) {
  3.7120 -            if (posx >= 0x10000L) {
  3.7121 -                while (posx >= 0x10000L) {
  3.7122 -                    ++srcx;
  3.7123 -                    posx -= 0x10000L;
  3.7124 -                }
  3.7125 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.7126 -            }
  3.7127 -            srcpixel = *src;
  3.7128 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.7129 -            dstpixel = *dst;
  3.7130 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.7131 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.7132 -                /* This goes away if we ever use premultiplied alpha */
  3.7133 -                if (srcA < 255) {
  3.7134 -                    srcR = (srcR * srcA) / 255;
  3.7135 -                    srcG = (srcG * srcA) / 255;
  3.7136 -                    srcB = (srcB * srcA) / 255;
  3.7137 -                }
  3.7138 -            }
  3.7139 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.7140 -            case SDL_COPY_MASK:
  3.7141 -                if (srcA) {
  3.7142 -                    dstR = srcR;
  3.7143 -                    dstG = srcG;
  3.7144 -                    dstB = srcB;
  3.7145 -                }
  3.7146 -                break;
  3.7147 -            case SDL_COPY_BLEND:
  3.7148 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.7149 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.7150 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.7151 -                break;
  3.7152 -            case SDL_COPY_ADD:
  3.7153 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.7154 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.7155 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.7156 -                break;
  3.7157 -            case SDL_COPY_MOD:
  3.7158 -                dstR = (srcR * dstR) / 255;
  3.7159 -                dstG = (srcG * dstG) / 255;
  3.7160 -                dstB = (srcB * dstB) / 255;
  3.7161 -                break;
  3.7162 -            }
  3.7163 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.7164 -            *dst = dstpixel;
  3.7165 -            posx += incx;
  3.7166 -            ++dst;
  3.7167 -        }
  3.7168 -        posy += incy;
  3.7169 -        info->dst += info->dst_pitch;
  3.7170 -    }
  3.7171 -}
  3.7172 -
  3.7173 -void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info)
  3.7174 -{
  3.7175 -    const int flags = info->flags;
  3.7176 -    const Uint32 modulateR = info->r;
  3.7177 -    const Uint32 modulateG = info->g;
  3.7178 -    const Uint32 modulateB = info->b;
  3.7179 -    const Uint32 modulateA = info->a;
  3.7180 -    Uint32 pixel;
  3.7181 -    Uint32 R, G, B, A;
  3.7182 -
  3.7183 -    while (info->dst_h--) {
  3.7184 -        Uint32 *src = (Uint32 *)info->src;
  3.7185 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7186 -        int n = info->dst_w;
  3.7187 -        while (n--) {
  3.7188 -            pixel = *src;
  3.7189 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.7190 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.7191 -                R = (R * modulateR) / 255;
  3.7192 -                G = (G * modulateG) / 255;
  3.7193 -                B = (B * modulateB) / 255;
  3.7194 -            }
  3.7195 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.7196 -                A = (A * modulateA) / 255;
  3.7197 -            }
  3.7198 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.7199 -            *dst = pixel;
  3.7200 -            ++src;
  3.7201 -            ++dst;
  3.7202 -        }
  3.7203 -        info->src += info->src_pitch;
  3.7204 -        info->dst += info->dst_pitch;
  3.7205 -    }
  3.7206 -}
  3.7207 -
  3.7208 -void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  3.7209 -{
  3.7210 -    const int flags = info->flags;
  3.7211 -    const Uint32 modulateR = info->r;
  3.7212 -    const Uint32 modulateG = info->g;
  3.7213 -    const Uint32 modulateB = info->b;
  3.7214 -    const Uint32 modulateA = info->a;
  3.7215 -    Uint32 pixel;
  3.7216 -    Uint32 R, G, B, A;
  3.7217 -    int srcy, srcx;
  3.7218 -    int posy, posx;
  3.7219 -    int incy, incx;
  3.7220 -
  3.7221 -    srcy = 0;
  3.7222 -    posy = 0;
  3.7223 -    incy = (info->src_h << 16) / info->dst_h;
  3.7224 -    incx = (info->src_w << 16) / info->dst_w;
  3.7225 -
  3.7226 -    while (info->dst_h--) {
  3.7227 -        Uint32 *src;
  3.7228 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7229 -        int n = info->dst_w;
  3.7230 -        srcx = -1;
  3.7231 -        posx = 0x10000L;
  3.7232 -        while (posy >= 0x10000L) {
  3.7233 -            ++srcy;
  3.7234 -            posy -= 0x10000L;
  3.7235 -        }
  3.7236 -        while (n--) {
  3.7237 -            if (posx >= 0x10000L) {
  3.7238 -                while (posx >= 0x10000L) {
  3.7239 -                    ++srcx;
  3.7240 -                    posx -= 0x10000L;
  3.7241 -                }
  3.7242 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.7243 -            }
  3.7244 -            pixel = *src;
  3.7245 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.7246 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.7247 -                R = (R * modulateR) / 255;
  3.7248 -                G = (G * modulateG) / 255;
  3.7249 -                B = (B * modulateB) / 255;
  3.7250 -            }
  3.7251 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.7252 -                A = (A * modulateA) / 255;
  3.7253 -            }
  3.7254 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3.7255 -            *dst = pixel;
  3.7256 -            posx += incx;
  3.7257 -            ++dst;
  3.7258 -        }
  3.7259 -        posy += incy;
  3.7260 -        info->dst += info->dst_pitch;
  3.7261 -    }
  3.7262 -}
  3.7263 -
  3.7264 -void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  3.7265 -{
  3.7266 -    const int flags = info->flags;
  3.7267 -    const Uint32 modulateR = info->r;
  3.7268 -    const Uint32 modulateG = info->g;
  3.7269 -    const Uint32 modulateB = info->b;
  3.7270 -    const Uint32 modulateA = info->a;
  3.7271 -    Uint32 srcpixel;
  3.7272 -    Uint32 srcR, srcG, srcB, srcA;
  3.7273 -    Uint32 dstpixel;
  3.7274 -    Uint32 dstR, dstG, dstB, dstA;
  3.7275 -
  3.7276 -    while (info->dst_h--) {
  3.7277 -        Uint32 *src = (Uint32 *)info->src;
  3.7278 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7279 -        int n = info->dst_w;
  3.7280 -        while (n--) {
  3.7281 -            srcpixel = *src;
  3.7282 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.7283 -            dstpixel = *dst;
  3.7284 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.7285 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.7286 -                srcR = (srcR * modulateR) / 255;
  3.7287 -                srcG = (srcG * modulateG) / 255;
  3.7288 -                srcB = (srcB * modulateB) / 255;
  3.7289 -            }
  3.7290 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.7291 -                srcA = (srcA * modulateA) / 255;
  3.7292 -            }
  3.7293 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.7294 -                /* This goes away if we ever use premultiplied alpha */
  3.7295 -                if (srcA < 255) {
  3.7296 -                    srcR = (srcR * srcA) / 255;
  3.7297 -                    srcG = (srcG * srcA) / 255;
  3.7298 -                    srcB = (srcB * srcA) / 255;
  3.7299 -                }
  3.7300 -            }
  3.7301 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.7302 -            case SDL_COPY_MASK:
  3.7303 -                if (srcA) {
  3.7304 -                    dstR = srcR;
  3.7305 -                    dstG = srcG;
  3.7306 -                    dstB = srcB;
  3.7307 -                }
  3.7308 -                break;
  3.7309 -            case SDL_COPY_BLEND:
  3.7310 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.7311 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.7312 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.7313 -                break;
  3.7314 -            case SDL_COPY_ADD:
  3.7315 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.7316 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.7317 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.7318 -                break;
  3.7319 -            case SDL_COPY_MOD:
  3.7320 -                dstR = (srcR * dstR) / 255;
  3.7321 -                dstG = (srcG * dstG) / 255;
  3.7322 -                dstB = (srcB * dstB) / 255;
  3.7323 -                break;
  3.7324 -            }
  3.7325 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.7326 -            *dst = dstpixel;
  3.7327 -            ++src;
  3.7328 -            ++dst;
  3.7329 -        }
  3.7330 -        info->src += info->src_pitch;
  3.7331 -        info->dst += info->dst_pitch;
  3.7332 -    }
  3.7333 -}
  3.7334 -
  3.7335 -void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3.7336 -{
  3.7337 -    const int flags = info->flags;
  3.7338 -    const Uint32 modulateR = info->r;
  3.7339 -    const Uint32 modulateG = info->g;
  3.7340 -    const Uint32 modulateB = info->b;
  3.7341 -    const Uint32 modulateA = info->a;
  3.7342 -    Uint32 srcpixel;
  3.7343 -    Uint32 srcR, srcG, srcB, srcA;
  3.7344 -    Uint32 dstpixel;
  3.7345 -    Uint32 dstR, dstG, dstB, dstA;
  3.7346 -    int srcy, srcx;
  3.7347 -    int posy, posx;
  3.7348 -    int incy, incx;
  3.7349 -
  3.7350 -    srcy = 0;
  3.7351 -    posy = 0;
  3.7352 -    incy = (info->src_h << 16) / info->dst_h;
  3.7353 -    incx = (info->src_w << 16) / info->dst_w;
  3.7354 -
  3.7355 -    while (info->dst_h--) {
  3.7356 -        Uint32 *src;
  3.7357 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7358 -        int n = info->dst_w;
  3.7359 -        srcx = -1;
  3.7360 -        posx = 0x10000L;
  3.7361 -        while (posy >= 0x10000L) {
  3.7362 -            ++srcy;
  3.7363 -            posy -= 0x10000L;
  3.7364 -        }
  3.7365 -        while (n--) {
  3.7366 -            if (posx >= 0x10000L) {
  3.7367 -                while (posx >= 0x10000L) {
  3.7368 -                    ++srcx;
  3.7369 -                    posx -= 0x10000L;
  3.7370 -                }
  3.7371 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.7372 -            }
  3.7373 -            srcpixel = *src;
  3.7374 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.7375 -            dstpixel = *dst;
  3.7376 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3.7377 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.7378 -                srcR = (srcR * modulateR) / 255;
  3.7379 -                srcG = (srcG * modulateG) / 255;
  3.7380 -                srcB = (srcB * modulateB) / 255;
  3.7381 -            }
  3.7382 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.7383 -                srcA = (srcA * modulateA) / 255;
  3.7384 -            }
  3.7385 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.7386 -                /* This goes away if we ever use premultiplied alpha */
  3.7387 -                if (srcA < 255) {
  3.7388 -                    srcR = (srcR * srcA) / 255;
  3.7389 -                    srcG = (srcG * srcA) / 255;
  3.7390 -                    srcB = (srcB * srcA) / 255;
  3.7391 -                }
  3.7392 -            }
  3.7393 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.7394 -            case SDL_COPY_MASK:
  3.7395 -                if (srcA) {
  3.7396 -                    dstR = srcR;
  3.7397 -                    dstG = srcG;
  3.7398 -                    dstB = srcB;
  3.7399 -                }
  3.7400 -                break;
  3.7401 -            case SDL_COPY_BLEND:
  3.7402 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.7403 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.7404 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.7405 -                break;
  3.7406 -            case SDL_COPY_ADD:
  3.7407 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.7408 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.7409 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.7410 -                break;
  3.7411 -            case SDL_COPY_MOD:
  3.7412 -                dstR = (srcR * dstR) / 255;
  3.7413 -                dstG = (srcG * dstG) / 255;
  3.7414 -                dstB = (srcB * dstB) / 255;
  3.7415 -                break;
  3.7416 -            }
  3.7417 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3.7418 -            *dst = dstpixel;
  3.7419 -            posx += incx;
  3.7420 -            ++dst;
  3.7421 -        }
  3.7422 -        posy += incy;
  3.7423 -        info->dst += info->dst_pitch;
  3.7424 -    }
  3.7425 -}
  3.7426 -
  3.7427 -void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info)
  3.7428 -{
  3.7429 -    const int flags = info->flags;
  3.7430 -    Uint32 pixel;
  3.7431 -    Uint32 R, G, B, A;
  3.7432 -    int srcy, srcx;
  3.7433 -    int posy, posx;
  3.7434 -    int incy, incx;
  3.7435 -
  3.7436 -    srcy = 0;
  3.7437 -    posy = 0;
  3.7438 -    incy = (info->src_h << 16) / info->dst_h;
  3.7439 -    incx = (info->src_w << 16) / info->dst_w;
  3.7440 -
  3.7441 -    while (info->dst_h--) {
  3.7442 -        Uint32 *src;
  3.7443 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7444 -        int n = info->dst_w;
  3.7445 -        srcx = -1;
  3.7446 -        posx = 0x10000L;
  3.7447 -        while (posy >= 0x10000L) {
  3.7448 -            ++srcy;
  3.7449 -            posy -= 0x10000L;
  3.7450 -        }
  3.7451 -        while (n--) {
  3.7452 -            if (posx >= 0x10000L) {
  3.7453 -                while (posx >= 0x10000L) {
  3.7454 -                    ++srcx;
  3.7455 -                    posx -= 0x10000L;
  3.7456 -                }
  3.7457 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.7458 -            }
  3.7459 -            pixel = *src;
  3.7460 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.7461 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.7462 -            *dst = pixel;
  3.7463 -            posx += incx;
  3.7464 -            ++dst;
  3.7465 -        }
  3.7466 -        posy += incy;
  3.7467 -        info->dst += info->dst_pitch;
  3.7468 -    }
  3.7469 -}
  3.7470 -
  3.7471 -void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info)
  3.7472 -{
  3.7473 -    const int flags = info->flags;
  3.7474 -    Uint32 srcpixel;
  3.7475 -    Uint32 srcR, srcG, srcB, srcA;
  3.7476 -    Uint32 dstpixel;
  3.7477 -    Uint32 dstR, dstG, dstB, dstA;
  3.7478 -
  3.7479 -    while (info->dst_h--) {
  3.7480 -        Uint32 *src = (Uint32 *)info->src;
  3.7481 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7482 -        int n = info->dst_w;
  3.7483 -        while (n--) {
  3.7484 -            srcpixel = *src;
  3.7485 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.7486 -            dstpixel = *dst;
  3.7487 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.7488 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.7489 -                /* This goes away if we ever use premultiplied alpha */
  3.7490 -                if (srcA < 255) {
  3.7491 -                    srcR = (srcR * srcA) / 255;
  3.7492 -                    srcG = (srcG * srcA) / 255;
  3.7493 -                    srcB = (srcB * srcA) / 255;
  3.7494 -                }
  3.7495 -            }
  3.7496 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.7497 -            case SDL_COPY_MASK:
  3.7498 -                if (srcA) {
  3.7499 -                    dstR = srcR;
  3.7500 -                    dstG = srcG;
  3.7501 -                    dstB = srcB;
  3.7502 -                }
  3.7503 -                break;
  3.7504 -            case SDL_COPY_BLEND:
  3.7505 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.7506 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.7507 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.7508 -                break;
  3.7509 -            case SDL_COPY_ADD:
  3.7510 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.7511 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.7512 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.7513 -                break;
  3.7514 -            case SDL_COPY_MOD:
  3.7515 -                dstR = (srcR * dstR) / 255;
  3.7516 -                dstG = (srcG * dstG) / 255;
  3.7517 -                dstB = (srcB * dstB) / 255;
  3.7518 -                break;
  3.7519 -            }
  3.7520 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.7521 -            *dst = dstpixel;
  3.7522 -            ++src;
  3.7523 -            ++dst;
  3.7524 -        }
  3.7525 -        info->src += info->src_pitch;
  3.7526 -        info->dst += info->dst_pitch;
  3.7527 -    }
  3.7528 -}
  3.7529 -
  3.7530 -void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  3.7531 -{
  3.7532 -    const int flags = info->flags;
  3.7533 -    Uint32 srcpixel;
  3.7534 -    Uint32 srcR, srcG, srcB, srcA;
  3.7535 -    Uint32 dstpixel;
  3.7536 -    Uint32 dstR, dstG, dstB, dstA;
  3.7537 -    int srcy, srcx;
  3.7538 -    int posy, posx;
  3.7539 -    int incy, incx;
  3.7540 -
  3.7541 -    srcy = 0;
  3.7542 -    posy = 0;
  3.7543 -    incy = (info->src_h << 16) / info->dst_h;
  3.7544 -    incx = (info->src_w << 16) / info->dst_w;
  3.7545 -
  3.7546 -    while (info->dst_h--) {
  3.7547 -        Uint32 *src;
  3.7548 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7549 -        int n = info->dst_w;
  3.7550 -        srcx = -1;
  3.7551 -        posx = 0x10000L;
  3.7552 -        while (posy >= 0x10000L) {
  3.7553 -            ++srcy;
  3.7554 -            posy -= 0x10000L;
  3.7555 -        }
  3.7556 -        while (n--) {
  3.7557 -            if (posx >= 0x10000L) {
  3.7558 -                while (posx >= 0x10000L) {
  3.7559 -                    ++srcx;
  3.7560 -                    posx -= 0x10000L;
  3.7561 -                }
  3.7562 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.7563 -            }
  3.7564 -            srcpixel = *src;
  3.7565 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.7566 -            dstpixel = *dst;
  3.7567 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.7568 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.7569 -                /* This goes away if we ever use premultiplied alpha */
  3.7570 -                if (srcA < 255) {
  3.7571 -                    srcR = (srcR * srcA) / 255;
  3.7572 -                    srcG = (srcG * srcA) / 255;
  3.7573 -                    srcB = (srcB * srcA) / 255;
  3.7574 -                }
  3.7575 -            }
  3.7576 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.7577 -            case SDL_COPY_MASK:
  3.7578 -                if (srcA) {
  3.7579 -                    dstR = srcR;
  3.7580 -                    dstG = srcG;
  3.7581 -                    dstB = srcB;
  3.7582 -                }
  3.7583 -                break;
  3.7584 -            case SDL_COPY_BLEND:
  3.7585 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.7586 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.7587 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.7588 -                break;
  3.7589 -            case SDL_COPY_ADD:
  3.7590 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.7591 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.7592 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.7593 -                break;
  3.7594 -            case SDL_COPY_MOD:
  3.7595 -                dstR = (srcR * dstR) / 255;
  3.7596 -                dstG = (srcG * dstG) / 255;
  3.7597 -                dstB = (srcB * dstB) / 255;
  3.7598 -                break;
  3.7599 -            }
  3.7600 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3.7601 -            *dst = dstpixel;
  3.7602 -            posx += incx;
  3.7603 -            ++dst;
  3.7604 -        }
  3.7605 -        posy += incy;
  3.7606 -        info->dst += info->dst_pitch;
  3.7607 -    }
  3.7608 -}
  3.7609 -
  3.7610 -void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info)
  3.7611 -{
  3.7612 -    const int flags = info->flags;
  3.7613 -    const Uint32 modulateR = info->r;
  3.7614 -    const Uint32 modulateG = info->g;
  3.7615 -    const Uint32 modulateB = info->b;
  3.7616 -    const Uint32 modulateA = info->a;
  3.7617 -    Uint32 pixel;
  3.7618 -    Uint32 R, G, B, A;
  3.7619 -
  3.7620 -    while (info->dst_h--) {
  3.7621 -        Uint32 *src = (Uint32 *)info->src;
  3.7622 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7623 -        int n = info->dst_w;
  3.7624 -        while (n--) {
  3.7625 -            pixel = *src;
  3.7626 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.7627 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.7628 -                R = (R * modulateR) / 255;
  3.7629 -                G = (G * modulateG) / 255;
  3.7630 -                B = (B * modulateB) / 255;
  3.7631 -            }
  3.7632 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.7633 -                A = (A * modulateA) / 255;
  3.7634 -            }
  3.7635 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.7636 -            *dst = pixel;
  3.7637 -            ++src;
  3.7638 -            ++dst;
  3.7639 -        }
  3.7640 -        info->src += info->src_pitch;
  3.7641 -        info->dst += info->dst_pitch;
  3.7642 -    }
  3.7643 -}
  3.7644 -
  3.7645 -void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  3.7646 -{
  3.7647 -    const int flags = info->flags;
  3.7648 -    const Uint32 modulateR = info->r;
  3.7649 -    const Uint32 modulateG = info->g;
  3.7650 -    const Uint32 modulateB = info->b;
  3.7651 -    const Uint32 modulateA = info->a;
  3.7652 -    Uint32 pixel;
  3.7653 -    Uint32 R, G, B, A;
  3.7654 -    int srcy, srcx;
  3.7655 -    int posy, posx;
  3.7656 -    int incy, incx;
  3.7657 -
  3.7658 -    srcy = 0;
  3.7659 -    posy = 0;
  3.7660 -    incy = (info->src_h << 16) / info->dst_h;
  3.7661 -    incx = (info->src_w << 16) / info->dst_w;
  3.7662 -
  3.7663 -    while (info->dst_h--) {
  3.7664 -        Uint32 *src;
  3.7665 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7666 -        int n = info->dst_w;
  3.7667 -        srcx = -1;
  3.7668 -        posx = 0x10000L;
  3.7669 -        while (posy >= 0x10000L) {
  3.7670 -            ++srcy;
  3.7671 -            posy -= 0x10000L;
  3.7672 -        }
  3.7673 -        while (n--) {
  3.7674 -            if (posx >= 0x10000L) {
  3.7675 -                while (posx >= 0x10000L) {
  3.7676 -                    ++srcx;
  3.7677 -                    posx -= 0x10000L;
  3.7678 -                }
  3.7679 -                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3.7680 -            }
  3.7681 -            pixel = *src;
  3.7682 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3.7683 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.7684 -                R = (R * modulateR) / 255;
  3.7685 -                G = (G * modulateG) / 255;
  3.7686 -                B = (B * modulateB) / 255;
  3.7687 -            }
  3.7688 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.7689 -                A = (A * modulateA) / 255;
  3.7690 -            }
  3.7691 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3.7692 -            *dst = pixel;
  3.7693 -            posx += incx;
  3.7694 -            ++dst;
  3.7695 -        }
  3.7696 -        posy += incy;
  3.7697 -        info->dst += info->dst_pitch;
  3.7698 -    }
  3.7699 -}
  3.7700 -
  3.7701 -void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  3.7702 -{
  3.7703 -    const int flags = info->flags;
  3.7704 -    const Uint32 modulateR = info->r;
  3.7705 -    const Uint32 modulateG = info->g;
  3.7706 -    const Uint32 modulateB = info->b;
  3.7707 -    const Uint32 modulateA = info->a;
  3.7708 -    Uint32 srcpixel;
  3.7709 -    Uint32 srcR, srcG, srcB, srcA;
  3.7710 -    Uint32 dstpixel;
  3.7711 -    Uint32 dstR, dstG, dstB, dstA;
  3.7712 -
  3.7713 -    while (info->dst_h--) {
  3.7714 -        Uint32 *src = (Uint32 *)info->src;
  3.7715 -        Uint32 *dst = (Uint32 *)info->dst;
  3.7716 -        int n = info->dst_w;
  3.7717 -        while (n--) {
  3.7718 -            srcpixel = *src;
  3.7719 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3.7720 -            dstpixel = *dst;
  3.7721 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3.7722 -            if (flags & SDL_COPY_MODULATE_COLOR) {
  3.7723 -                srcR = (srcR * modulateR) / 255;
  3.7724 -                srcG = (srcG * modulateG) / 255;
  3.7725 -                srcB = (srcB * modulateB) / 255;
  3.7726 -            }
  3.7727 -            if (flags & SDL_COPY_MODULATE_ALPHA) {
  3.7728 -                srcA = (srcA * modulateA) / 255;
  3.7729 -            }
  3.7730 -            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3.7731 -                /* This goes away if we ever use premultiplied alpha */
  3.7732 -                if (srcA < 255) {
  3.7733 -                    srcR = (srcR * srcA) / 255;
  3.7734 -                    srcG = (srcG * srcA) / 255;
  3.7735 -                    srcB = (srcB * srcA) / 255;
  3.7736 -                }
  3.7737 -            }
  3.7738 -            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3.7739 -            case SDL_COPY_MASK:
  3.7740 -                if (srcA) {
  3.7741 -                    dstR = srcR;
  3.7742 -                    dstG = srcG;
  3.7743 -                    dstB = srcB;
  3.7744 -                }
  3.7745 -                break;
  3.7746 -            case SDL_COPY_BLEND:
  3.7747 -                dstR = srcR + ((255 - srcA) * dstR) / 255;
  3.7748 -                dstG = srcG + ((255 - srcA) * dstG) / 255;
  3.7749 -                dstB = srcB + ((255 - srcA) * dstB) / 255;
  3.7750 -                break;
  3.7751 -            case SDL_COPY_ADD:
  3.7752 -                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3.7753 -                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3.7754 -                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3.7755 -                break;
  3.7756 -            case SDL_COPY_MOD:
  3.7757 -                dstR = (srcR * dstR) / 255;
  3.7758 -                dstG = (srcG * dstG) / 255;
  3.7759 -                dstB = (srcB * dstB) / 255;
  3.7760 -                break;
  3.7761 -