changeset 2267:c785543d1843

Okay, still some bugs, but everything builds again...
author Sam Lantinga <slouken@libsdl.org>
date Sat, 18 Aug 2007 05:39:09 +0000
parents e61ad15a205f
children 4baee598306d
files include/SDL_compat.h include/SDL_video.h src/SDL_compat.c src/video/SDL_RLEaccel.c src/video/SDL_blit.c src/video/SDL_blit.h src/video/SDL_blit_0.c src/video/SDL_blit_1.c src/video/SDL_blit_A.c src/video/SDL_blit_N.c src/video/SDL_blit_auto.c src/video/SDL_blit_copy.c src/video/SDL_pixels.c src/video/SDL_renderer_sw.c src/video/SDL_surface.c src/video/SDL_video.c src/video/dummy/SDL_nullrender.c src/video/sdlgenblit.pl test/testalpha.c test/testblitspeed.c test/testgl.c test/testoverlay.c test/testoverlay2.c
diffstat 23 files changed, 604 insertions(+), 676 deletions(-) [+]
line wrap: on
line diff
--- a/include/SDL_compat.h	Sat Aug 18 01:44:21 2007 +0000
+++ b/include/SDL_compat.h	Sat Aug 18 05:39:09 2007 +0000
@@ -37,8 +37,8 @@
 #endif
 
 #define SDL_SWSURFACE       0x00000000  /* Not used */
-//#define SDL_SRCALPHA        0x00010000
-//#define SDL_SRCCOLORKEY     0x00020000
+#define SDL_SRCALPHA        0x00010000
+#define SDL_SRCCOLORKEY     0x00020000
 #define SDL_ANYFORMAT       0x00100000
 #define SDL_HWPALETTE       0x00200000
 #define SDL_DOUBLEBUF       0x00400000
@@ -48,6 +48,7 @@
 #define SDL_OPENGL          0x04000000
 #define SDL_HWSURFACE       0x08000001  /* Not used */
 #define SDL_ASYNCBLIT       0x08000000  /* Not used */
+#define SDL_RLEACCELOK      0x08000000  /* Not used */
 #define SDL_HWACCEL         0x08000000  /* Not used */
 
 #define SDL_APPMOUSEFOCUS	0x01
--- a/include/SDL_video.h	Sat Aug 18 01:44:21 2007 +0000
+++ b/include/SDL_video.h	Sat Aug 18 05:39:09 2007 +0000
@@ -265,7 +265,7 @@
 /* These are the currently supported flags for the SDL_surface */
 /* Used internally (read-only) */
 #define SDL_PREALLOC        0x00000001  /* Surface uses preallocated memory */
-#define SDL_RLEACCEL        0x00000001  /* Surface is RLE encoded */
+#define SDL_RLEACCEL        0x00000002  /* Surface is RLE encoded */
 
 /* Evaluates to true if the surface needs to be locked before access */
 #define SDL_MUSTLOCK(S)	(((S)->flags & SDL_RLEACCEL) != 0)
@@ -1407,7 +1407,8 @@
  * \note If RLE is enabled, colorkey and alpha blending blits are much faster,
  *       but the surface must be locked before directly accessing the pixels.
  */
-extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, int flag);
+extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
+                                              int flag);
 
 /*
  * \fn int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key)
@@ -1420,7 +1421,8 @@
  *
  * \return 0 on success, or -1 if the surface is not valid
  */
-extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key);
+extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
+                                            Uint32 flag, Uint32 key);
 
 /**
  * \fn int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
@@ -1436,7 +1438,7 @@
  *
  * \sa SDL_GetSurfaceColorMod()
  */
-extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface,
+extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
                                                    Uint8 r, Uint8 g, Uint8 b);
 
 
@@ -1454,7 +1456,7 @@
  *
  * \sa SDL_SetSurfaceColorMod()
  */
-extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface,
+extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
                                                    Uint8 * r, Uint8 * g,
                                                    Uint8 * b);
 
@@ -1470,7 +1472,7 @@
  *
  * \sa SDL_GetSurfaceAlphaMod()
  */
-extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface,
+extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
                                                    Uint8 alpha);
 
 /**
@@ -1485,7 +1487,7 @@
  *
  * \sa SDL_SetSurfaceAlphaMod()
  */
-extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface,
+extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
                                                    Uint8 * alpha);
 
 /**
@@ -1500,7 +1502,7 @@
  *
  * \sa SDL_GetSurfaceBlendMode()
  */
-extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface,
+extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
                                                     int blendMode);
 
 /**
@@ -1515,7 +1517,7 @@
  *
  * \sa SDL_SetSurfaceBlendMode()
  */
-extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface,
+extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
                                                     int *blendMode);
 
 /**
@@ -1532,7 +1534,7 @@
  *
  * \sa SDL_GetSurfaceScaleMode()
  */
-extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface *surface,
+extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface * surface,
                                                     int scaleMode);
 
 /**
@@ -1547,7 +1549,7 @@
  *
  * \sa SDL_SetSurfaceScaleMode()
  */
-extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface *surface,
+extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface * surface,
                                                     int *scaleMode);
 
 /*
--- a/src/SDL_compat.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/SDL_compat.c	Sat Aug 18 05:39:09 2007 +0000
@@ -608,7 +608,7 @@
 SDL_Surface *
 SDL_DisplayFormat(SDL_Surface * surface)
 {
-    Uint32 flags;
+    SDL_Surface *converted;
 
     if (!SDL_PublicSurface) {
         SDL_SetError("No video mode has been set");
@@ -616,7 +616,9 @@
     }
 
     /* Set the flags appropriate for copying to display surface */
-    return SDL_ConvertSurface(surface, SDL_PublicSurface->format, SDL_RLEACCELOK);
+    converted = SDL_ConvertSurface(surface, SDL_PublicSurface->format, 0);
+    SDL_SetSurfaceRLE(converted, 1);
+    return converted;
 }
 
 SDL_Surface *
@@ -625,7 +627,6 @@
     SDL_PixelFormat *vf;
     SDL_PixelFormat *format;
     SDL_Surface *converted;
-    Uint32 flags;
     /* default to ARGB8888 */
     Uint32 amask = 0xff000000;
     Uint32 rmask = 0x00ff0000;
@@ -666,7 +667,8 @@
         break;
     }
     format = SDL_AllocFormat(32, rmask, gmask, bmask, amask);
-    converted = SDL_ConvertSurface(surface, format, SDL_RLEACCELOK);
+    converted = SDL_ConvertSurface(surface, format, 0);
+    SDL_SetSurfaceRLE(converted, 1);
     SDL_FreeFormat(format);
     return converted;
 }
--- a/src/video/SDL_RLEaccel.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_RLEaccel.c	Sat Aug 18 05:39:09 2007 +0000
@@ -1821,13 +1821,13 @@
 
     /* If we don't have colorkey or blending, nothing to do... */
     flags = surface->map->info.flags;
-    if(!(flags & (SDL_COPY_COLORKEY|SDL_COPY_BLEND))) {
+    if (!(flags & (SDL_COPY_COLORKEY | SDL_COPY_BLEND))) {
         return -1;
     }
 
     /* Pass on combinations not supported */
     if ((flags & SDL_COPY_MODULATE_COLOR) ||
-        (flags & (SDL_COPY_ADD|SDL_COPY_MOD)) ||
+        (flags & (SDL_COPY_ADD | SDL_COPY_MOD)) ||
         (flags & SDL_COPY_NEAREST)) {
         return -1;
     }
@@ -1971,7 +1971,8 @@
                 }
             }
         }
-        surface->map->info.flags &= (SDL_COPY_RLE_COLORKEY|SDL_COPY_RLE_ALPHAKEY);
+        surface->map->info.flags &=
+            (SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY);
 
         if (surface->map->data) {
             SDL_free(surface->map->data);
--- a/src/video/SDL_blit.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_blit.c	Sat Aug 18 05:39:09 2007 +0000
@@ -71,11 +71,15 @@
             (Uint16) srcrect->x * info->src_fmt->BytesPerPixel;
         info->src_w = srcrect->w;
         info->src_h = srcrect->h;
-        info->dst = (Uint8 *) dst->pixels +
-            (Uint16) dstrect->y * dst->pitch +
+        info->src_skip =
+            info->src_pitch - info->src_w * info->src_fmt->BytesPerPixel;
+        info->dst =
+            (Uint8 *) dst->pixels + (Uint16) dstrect->y * dst->pitch +
             (Uint16) dstrect->x * info->dst_fmt->BytesPerPixel;
         info->dst_w = dstrect->w;
         info->dst_h = dstrect->h;
+        info->dst_skip =
+            info->dst_pitch - info->dst_w * info->dst_fmt->BytesPerPixel;
         RunBlit = (SDL_BlitFunc) src->map->data;
 
         /* Run the actual software blit */
@@ -119,7 +123,8 @@
 #endif /* __MACOSX__ */
 
 static SDL_BlitFunc
-SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries)
+SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
+                   SDL_BlitFuncEntry * entries)
 {
     int i, flagcheck;
     static Uint32 features = 0xffffffff;
@@ -166,13 +171,16 @@
         }
 
         /* Check modulation flags */
-        flagcheck = (flags & (SDL_COPY_MODULATE_COLOR|SDL_COPY_MODULATE_COLOR));
+        flagcheck =
+            (flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_COLOR));
         if ((flagcheck & entries[i].flags) != flagcheck) {
             continue;
         }
 
         /* Check blend flags */
-        flagcheck = (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD));
+        flagcheck =
+            (flags &
+             (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD));
         if ((flagcheck & entries[i].flags) != flagcheck) {
             continue;
         }
@@ -208,8 +216,6 @@
     SDL_BlitFunc blit = NULL;
     SDL_BlitMap *map = surface->map;
     SDL_Surface *dst = map->dst;
-    Uint32 src_format;
-    Uint32 dst_format;
 
     /* Clean everything out to start */
     if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
@@ -222,16 +228,13 @@
     map->info.dst_pitch = dst->pitch;
 
     /* See if we can do RLE acceleration */
-    if (surface->flags & SDL_RLEACCELOK) {
+    if (surface->map->info.flags & SDL_COPY_RLE_DESIRED) {
         if (SDL_RLESurface(surface) == 0) {
             return 0;
         }
     }
 
     /* Choose a standard blit function */
-    src_format = SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask);
-    dst_format = SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel, dst->format->Rmask, dst->format->Gmask, dst->format->Bmask, dst->format->Amask);
-
     if (map->identity && !map->info.flags) {
         /* Handle overlapping blits on the same surface */
         if (surface == dst) {
@@ -240,15 +243,32 @@
             blit = SDL_BlitCopy;
         }
     } else if (surface->format->BitsPerPixel < 8) {
-        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTable0);
+        blit = SDL_CalculateBlit0(surface);
     } else if (surface->format->BytesPerPixel == 1) {
-        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTable1);
+        blit = SDL_CalculateBlit1(surface);
+    } else if (map->info.flags & SDL_COPY_BLEND) {
+        blit = SDL_CalculateBlitA(surface);
     } else {
-        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTableN);
+        blit = SDL_CalculateBlitN(surface);
     }
     if (blit == NULL) {
-        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_GeneratedBlitFuncTable);
+        Uint32 src_format =
+            SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel,
+                                       surface->format->Rmask,
+                                       surface->format->Gmask,
+                                       surface->format->Bmask,
+                                       surface->format->Amask);
+        Uint32 dst_format =
+            SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel,
+                                       dst->format->Rmask, dst->format->Gmask,
+                                       dst->format->Bmask,
+                                       dst->format->Amask);
+
+        blit =
+            SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags,
+                               SDL_GeneratedBlitFuncTable);
     }
+    map->data = blit;
 
     /* Make sure we have a blit function */
     if (blit == NULL) {
--- a/src/video/SDL_blit.h	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_blit.h	Sat Aug 18 05:39:09 2007 +0000
@@ -62,13 +62,16 @@
 #define SDL_CPU_ALTIVEC_PREFETCH    0x00000010
 #define SDL_CPU_ALTIVEC_NOPREFETCH  0x00000020
 
-typedef struct {
+typedef struct
+{
     Uint8 *src;
     int src_w, src_h;
     int src_pitch;
+    int src_skip;
     Uint8 *dst;
     int dst_w, dst_h;
     int dst_pitch;
+    int dst_skip;
     SDL_PixelFormat *src_fmt;
     SDL_PixelFormat *dst_fmt;
     Uint8 *table;
@@ -77,9 +80,10 @@
     Uint8 r, g, b, a;
 } SDL_BlitInfo;
 
-typedef void (SDLCALL * SDL_BlitFunc)(SDL_BlitInfo *info);
+typedef void (SDLCALL * SDL_BlitFunc) (SDL_BlitInfo * info);
 
-typedef struct {
+typedef struct
+{
     Uint32 src_format;
     Uint32 dst_format;
     int flags;
@@ -104,10 +108,11 @@
 /* Functions found in SDL_blit.c */
 extern int SDL_CalculateBlit(SDL_Surface * surface);
 
-/* Blit function tables in SDL_blit_*.c */
-extern SDL_BlitFuncEntry SDL_BlitFuncTable0[];
-extern SDL_BlitFuncEntry SDL_BlitFuncTable1[];
-extern SDL_BlitFuncEntry SDL_BlitFuncTableN[];
+/* Functions found in SDL_blit_*.c */
+extern SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface * surface);
+extern SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface * surface);
+extern SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface * surface);
+extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface * surface);
 
 /*
  * Useful macros for blitting routines
--- a/src/video/SDL_blit_0.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_blit_0.c	Sat Aug 18 05:39:09 2007 +0000
@@ -38,9 +38,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = info->src;
-    srcskip = info->s_skip;
+    srcskip = info->src_skip;
     dst = info->dst;
-    dstskip = info->dst_pitch;
+    dstskip = info->dst_skip;
     map = info->table;
     srcskip += width - (width + 7) / 8;
 
@@ -93,9 +93,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = info->src;
-    srcskip = info->s_skip;
+    srcskip = info->src_skip;
     dst = (Uint16 *) info->dst;
-    dstskip = info->dst_pitch / 2;
+    dstskip = info->dst_skip / 2;
     map = (Uint16 *) info->table;
     srcskip += width - (width + 7) / 8;
 
@@ -128,9 +128,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = info->src;
-    srcskip = info->s_skip;
+    srcskip = info->src_skip;
     dst = info->dst;
-    dstskip = info->dst_pitch;
+    dstskip = info->dst_skip;
     map = info->table;
     srcskip += width - (width + 7) / 8;
 
@@ -167,9 +167,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = info->src;
-    srcskip = info->s_skip;
+    srcskip = info->src_skip;
     dst = (Uint32 *) info->dst;
-    dstskip = info->dst_pitch / 4;
+    dstskip = info->dst_skip / 4;
     map = (Uint32 *) info->table;
     srcskip += width - (width + 7) / 8;
 
@@ -198,9 +198,9 @@
     int height = info->dst_h;
     Uint8 *src = info->src;
     Uint8 *dst = info->dst;
-    int srcskip = info->s_skip;
-    int dstskip = info->dst_pitch;
-    Uint32 ckey = info->ckey;
+    int srcskip = info->src_skip;
+    int dstskip = info->dst_skip;
+    Uint32 ckey = info->colorkey;
     Uint8 *palmap = info->table;
     int c;
 
@@ -251,9 +251,9 @@
     int height = info->dst_h;
     Uint8 *src = info->src;
     Uint16 *dstp = (Uint16 *) info->dst;
-    int srcskip = info->s_skip;
-    int dstskip = info->dst_pitch;
-    Uint32 ckey = info->ckey;
+    int srcskip = info->src_skip;
+    int dstskip = info->dst_skip;
+    Uint32 ckey = info->colorkey;
     Uint8 *palmap = info->table;
     int c;
 
@@ -286,9 +286,9 @@
     int height = info->dst_h;
     Uint8 *src = info->src;
     Uint8 *dst = info->dst;
-    int srcskip = info->s_skip;
-    int dstskip = info->dst_pitch;
-    Uint32 ckey = info->ckey;
+    int srcskip = info->src_skip;
+    int dstskip = info->dst_skip;
+    Uint32 ckey = info->colorkey;
     Uint8 *palmap = info->table;
     int c;
 
@@ -320,9 +320,9 @@
     int height = info->dst_h;
     Uint8 *src = info->src;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int srcskip = info->s_skip;
-    int dstskip = info->dst_pitch;
-    Uint32 ckey = info->ckey;
+    int srcskip = info->src_skip;
+    int dstskip = info->dst_skip;
+    Uint32 ckey = info->colorkey;
     Uint8 *palmap = info->table;
     int c;
 
@@ -355,13 +355,13 @@
     int height = info->dst_h;
     Uint8 *src = info->src;
     Uint8 *dst = info->dst;
-    int srcskip = info->s_skip;
-    int dstskip = info->dst_pitch;
-    const SDL_Color *srcpal = info->src->palette->colors;
-    SDL_PixelFormat *dstfmt = info->dst;
+    int srcskip = info->src_skip;
+    int dstskip = info->dst_skip;
+    const SDL_Color *srcpal = info->src_fmt->palette->colors;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
     int dstbpp;
     int c;
-    const int A = (info->cmod >> 24);
+    const int A = info->a;
 
     /* Set up some basic variables */
     dstbpp = dstfmt->BytesPerPixel;
@@ -400,15 +400,15 @@
     int height = info->dst_h;
     Uint8 *src = info->src;
     Uint8 *dst = info->dst;
-    int srcskip = info->s_skip;
-    int dstskip = info->dst_pitch;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
+    int srcskip = info->src_skip;
+    int dstskip = info->dst_skip;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
     const SDL_Color *srcpal = srcfmt->palette->colors;
     int dstbpp;
     int c;
-    const int A = (info->cmod >> 24);
-    Uint32 ckey = info->ckey;
+    const int A = info->a;
+    Uint32 ckey = info->colorkey;
 
     /* Set up some basic variables */
     dstbpp = dstfmt->BytesPerPixel;
@@ -440,16 +440,16 @@
     }
 }
 
-static SDL_loblit bitmap_blit[] = {
+static SDL_BlitFunc bitmap_blit[] = {
     NULL, BlitBto1, BlitBto2, BlitBto3, BlitBto4
 };
 
-static SDL_loblit colorkey_blit[] = {
+static SDL_BlitFunc colorkey_blit[] = {
     NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key
 };
 
-SDL_loblit
-SDL_CalculateBlit0(SDL_Surface * surface, int blit_index)
+SDL_BlitFunc
+SDL_CalculateBlit0(SDL_Surface * surface)
 {
     int which;
 
@@ -462,17 +462,17 @@
     } else {
         which = surface->map->dst->format->BytesPerPixel;
     }
-    switch (blit_index) {
-    case 0:                    /* copy */
+    switch (surface->map->info.flags) {
+    case 0:
         return bitmap_blit[which];
 
-    case 1:                    /* colorkey */
+    case SDL_COPY_COLORKEY:
         return colorkey_blit[which];
 
-    case 2:                    /* alpha */
+    case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
         return which >= 2 ? BlitBtoNAlpha : NULL;
 
-    case 4:                    /* alpha + colorkey */
+    case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
         return which >= 2 ? BlitBtoNAlphaKey : NULL;
     }
     return NULL;
--- a/src/video/SDL_blit_1.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_blit_1.c	Sat Aug 18 05:39:09 2007 +0000
@@ -42,9 +42,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = info->src;
-    srcskip = info->s_skip;
+    srcskip = info->src_skip;
     dst = info->dst;
-    dstskip = info->dst_pitch;
+    dstskip = info->dst_skip;
     map = info->table;
 
     while (height--) {
@@ -93,9 +93,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = info->src;
-    srcskip = info->s_skip;
+    srcskip = info->src_skip;
     dst = info->dst;
-    dstskip = info->dst_pitch;
+    dstskip = info->dst_skip;
     map = (Uint16 *) info->table;
 
 #ifdef USE_DUFFS_LOOP
@@ -199,9 +199,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = info->src;
-    srcskip = info->s_skip;
+    srcskip = info->src_skip;
     dst = info->dst;
-    dstskip = info->dst_pitch;
+    dstskip = info->dst_skip;
     map = info->table;
 
     while (height--) {
@@ -247,9 +247,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = info->src;
-    srcskip = info->s_skip;
+    srcskip = info->src_skip;
     dst = (Uint32 *) info->dst;
-    dstskip = info->dst_pitch / 4;
+    dstskip = info->dst_skip / 4;
     map = (Uint32 *) info->table;
 
     while (height--) {
@@ -286,11 +286,11 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     Uint8 *palmap = info->table;
-    Uint32 ckey = info->ckey;
+    Uint32 ckey = info->colorkey;
 
     if (palmap) {
         while (height--) {
@@ -333,11 +333,11 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint16 *dstp = (Uint16 *) info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     Uint16 *palmap = (Uint16 *) info->table;
-    Uint32 ckey = info->ckey;
+    Uint32 ckey = info->colorkey;
 
     /* Set up some basic variables */
     dstskip /= 2;
@@ -365,11 +365,11 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     Uint8 *palmap = info->table;
-    Uint32 ckey = info->ckey;
+    Uint32 ckey = info->colorkey;
     int o;
 
     while (height--) {
@@ -398,11 +398,11 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     Uint32 *palmap = (Uint32 *) info->table;
-    Uint32 ckey = info->ckey;
+    Uint32 ckey = info->colorkey;
 
     /* Set up some basic variables */
     dstskip /= 4;
@@ -430,13 +430,13 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
-    SDL_PixelFormat *dstfmt = info->dst;
-    const SDL_Color *srcpal = info->src->palette->colors;
+    int dstskip = info->dst_skip;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
+    const SDL_Color *srcpal = info->src_fmt->palette->colors;
     int dstbpp;
-    const int A = (info->cmod >> 24);
+    const int A = info->a;
 
     /* Set up some basic variables */
     dstbpp = dstfmt->BytesPerPixel;
@@ -471,15 +471,15 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    const SDL_Color *srcpal = info->src->palette->colors;
-    Uint32 ckey = info->ckey;
+    int dstskip = info->dst_skip;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
+    const SDL_Color *srcpal = info->src_fmt->palette->colors;
+    Uint32 ckey = info->colorkey;
     int dstbpp;
-    const int A = (info->cmod >> 24);
+    const int A = info->a;
 
     /* Set up some basic variables */
     dstbpp = dstfmt->BytesPerPixel;
@@ -510,16 +510,16 @@
     }
 }
 
-static SDL_loblit one_blit[] = {
+static SDL_BlitFunc one_blit[] = {
     NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4
 };
 
-static SDL_loblit one_blitkey[] = {
+static SDL_BlitFunc one_blitkey[] = {
     NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key
 };
 
-SDL_loblit
-SDL_CalculateBlit1(SDL_Surface * surface, int blit_index)
+SDL_BlitFunc
+SDL_CalculateBlit1(SDL_Surface * surface)
 {
     int which;
     SDL_PixelFormat *dstfmt;
@@ -530,22 +530,21 @@
     } else {
         which = dstfmt->BytesPerPixel;
     }
-    switch (blit_index) {
-    case 0:                    /* copy */
+    switch (surface->map->info.flags) {
+    case 0:
         return one_blit[which];
 
-    case 1:                    /* colorkey */
+    case SDL_COPY_COLORKEY:
         return one_blitkey[which];
 
-    case 2:                    /* alpha */
+    case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
         /* Supporting 8bpp->8bpp alpha is doable but requires lots of
            tables which consume space and takes time to precompute,
            so is better left to the user */
         return which >= 2 ? Blit1toNAlpha : NULL;
 
-    case 3:                    /* alpha + colorkey */
+    case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
         return which >= 2 ? Blit1toNAlphaKey : NULL;
-
     }
     return NULL;
 }
--- a/src/video/SDL_blit_A.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_blit_A.c	Sat Aug 18 05:39:09 2007 +0000
@@ -33,15 +33,15 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     Uint8 *palmap = info->table;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
     int srcbpp = srcfmt->BytesPerPixel;
 
-    const unsigned A = (info->cmod >> 24);
+    const unsigned A = info->a;
 
     while (height--) {
 	    /* *INDENT-OFF* */
@@ -89,12 +89,12 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     Uint8 *palmap = info->table;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
     int srcbpp = srcfmt->BytesPerPixel;
 
     /* FIXME: fix alpha bit field expansion here too? */
@@ -145,16 +145,16 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     Uint8 *palmap = info->table;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
     int srcbpp = srcfmt->BytesPerPixel;
-    Uint32 ckey = info->ckey;
+    Uint32 ckey = info->colorkey;
 
-    const int A = (info->cmod >> 24);
+    const int A = info->a;
 
     while (height--) {
 	    /* *INDENT-OFF* */
@@ -206,10 +206,10 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch >> 2;
-    Uint32 dalpha = info->dst->Amask;
+    int dstskip = info->dst_skip >> 2;
+    Uint32 dalpha = info->dst_fmt->Amask;
 
     __m64 src1, src2, dst1, dst2, lmask, hmask, dsta;
 
@@ -259,9 +259,9 @@
 static void
 BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info)
 {
-    SDL_PixelFormat *df = info->dst;
+    SDL_PixelFormat *df = info->dst_fmt;
     Uint32 chanmask = df->Rmask | df->Gmask | df->Bmask;
-    unsigned alpha = (info->cmod >> 24);
+    unsigned alpha = info->a;
 
     if (alpha == 128 && (df->Rmask | df->Gmask | df->Bmask) == 0x00FFFFFF) {
         /* only call a128 version when R,G,B occupy lower bits */
@@ -270,9 +270,9 @@
         int width = info->dst_w;
         int height = info->dst_h;
         Uint32 *srcp = (Uint32 *) info->src;
-        int srcskip = info->s_skip >> 2;
+        int srcskip = info->src_skip >> 2;
         Uint32 *dstp = (Uint32 *) info->dst;
-        int dstskip = info->dst_pitch >> 2;
+        int dstskip = info->dst_skip >> 2;
         Uint32 dalpha = df->Amask;
         Uint32 amult;
 
@@ -359,10 +359,10 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch >> 2;
-    SDL_PixelFormat *sf = info->src;
+    int dstskip = info->dst_skip >> 2;
+    SDL_PixelFormat *sf = info->src_fmt;
     Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask;
     Uint32 amask = sf->Amask;
     Uint32 ashift = sf->Ashift;
@@ -544,10 +544,10 @@
 {
     int height = info->dst_h;
     Uint8 *src = (Uint8 *) info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = (Uint8 *) info->dst;
-    int dstskip = info->dst_pitch;
-    SDL_PixelFormat *srcfmt = info->src;
+    int dstskip = info->dst_skip;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
 
     vector unsigned char v0 = vec_splat_u8(0);
     vector unsigned short v8_16 = vec_splat_u16(8);
@@ -720,15 +720,15 @@
 {
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch >> 2;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    unsigned sA = (info->cmod >> 24);
+    int dstskip = info->dst_skip >> 2;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
+    unsigned sA = info->a;
     unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
     Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
-    Uint32 ckey = info->ckey;
+    Uint32 ckey = info->colorkey;
     vector unsigned char mergePermute;
     vector unsigned char vsrcPermute;
     vector unsigned char vdstPermute;
@@ -847,11 +847,11 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch >> 2;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
+    int dstskip = info->dst_skip >> 2;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
     vector unsigned char mergePermute;
     vector unsigned char valphaPermute;
     vector unsigned char vsrcPermute;
@@ -945,9 +945,9 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch >> 2;
+    int dstskip = info->dst_skip >> 2;
     vector unsigned char mergePermute;
     vector unsigned char valphaPermute;
     vector unsigned char valphamask;
@@ -1042,12 +1042,12 @@
     /* XXX : 6 */
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch >> 2;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    unsigned sA = (info->cmod >> 24);
+    int dstskip = info->dst_skip >> 2;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
+    unsigned sA = info->a;
     unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
     vector unsigned char mergePermute;
     vector unsigned char vsrcPermute;
@@ -1136,12 +1136,12 @@
 static void
 BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo * info)
 {
-    unsigned alpha = (info->cmod >> 24);
+    unsigned alpha = info->a;
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch >> 2;
+    int dstskip = info->dst_skip >> 2;
     vector unsigned char mergePermute;
     vector unsigned char valpha;
     vector unsigned char valphamask;
@@ -1227,9 +1227,9 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch >> 2;
+    int dstskip = info->dst_skip >> 2;
 
     while (height--) {
 	    /* *INDENT-OFF* */
@@ -1249,16 +1249,16 @@
 static void
 BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info)
 {
-    unsigned alpha = (info->cmod >> 24);
+    unsigned alpha = info->a;
     if (alpha == 128) {
         BlitRGBtoRGBSurfaceAlpha128(info);
     } else {
         int width = info->dst_w;
         int height = info->dst_h;
         Uint32 *srcp = (Uint32 *) info->src;
-        int srcskip = info->s_skip >> 2;
+        int srcskip = info->src_skip >> 2;
         Uint32 *dstp = (Uint32 *) info->dst;
-        int dstskip = info->dst_pitch >> 2;
+        int dstskip = info->dst_skip >> 2;
         Uint32 s;
         Uint32 d;
         Uint32 s1;
@@ -1324,9 +1324,9 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch >> 2;
+    int dstskip = info->dst_skip >> 2;
 
     while (height--) {
 	    /* *INDENT-OFF* */
@@ -1377,10 +1377,10 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch >> 2;
-    SDL_PixelFormat *sf = info->src;
+    int dstskip = info->dst_skip >> 2;
+    SDL_PixelFormat *sf = info->src_fmt;
     Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask;
     Uint32 amask = sf->Amask;
     Uint32 ashift = sf->Ashift;
@@ -1459,9 +1459,9 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint16 *srcp = (Uint16 *) info->src;
-    int srcskip = info->s_skip >> 1;
+    int srcskip = info->src_skip >> 1;
     Uint16 *dstp = (Uint16 *) info->dst;
-    int dstskip = info->dst_pitch >> 1;
+    int dstskip = info->dst_skip >> 1;
 
     while (height--) {
         if (((uintptr_t) srcp ^ (uintptr_t) dstp) & 2) {
@@ -1558,16 +1558,16 @@
 static void
 Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info)
 {
-    unsigned alpha = (info->cmod >> 24);
+    unsigned alpha = info->a;
     if (alpha == 128) {
         Blit16to16SurfaceAlpha128(info, 0xf7de);
     } else {
         int width = info->dst_w;
         int height = info->dst_h;
         Uint16 *srcp = (Uint16 *) info->src;
-        int srcskip = info->s_skip >> 1;
+        int srcskip = info->src_skip >> 1;
         Uint16 *dstp = (Uint16 *) info->dst;
-        int dstskip = info->dst_pitch >> 1;
+        int dstskip = info->dst_skip >> 1;
         Uint32 s, d;
 
         __m64 src1, dst1, src2, dst2, gmask, bmask, mm_res, mm_alpha;
@@ -1695,16 +1695,16 @@
 static void
 Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info)
 {
-    unsigned alpha = (info->cmod >> 24);
+    unsigned alpha = info->a;
     if (alpha == 128) {
         Blit16to16SurfaceAlpha128(info, 0xfbde);
     } else {
         int width = info->dst_w;
         int height = info->dst_h;
         Uint16 *srcp = (Uint16 *) info->src;
-        int srcskip = info->s_skip >> 1;
+        int srcskip = info->src_skip >> 1;
         Uint16 *dstp = (Uint16 *) info->dst;
-        int dstskip = info->dst_pitch >> 1;
+        int dstskip = info->dst_skip >> 1;
         Uint32 s, d;
 
         __m64 src1, dst1, src2, dst2, rmask, gmask, bmask, mm_res, mm_alpha;
@@ -1835,16 +1835,16 @@
 static void
 Blit565to565SurfaceAlpha(SDL_BlitInfo * info)
 {
-    unsigned alpha = (info->cmod >> 24);
+    unsigned alpha = info->a;
     if (alpha == 128) {
         Blit16to16SurfaceAlpha128(info, 0xf7de);
     } else {
         int width = info->dst_w;
         int height = info->dst_h;
         Uint16 *srcp = (Uint16 *) info->src;
-        int srcskip = info->s_skip >> 1;
+        int srcskip = info->src_skip >> 1;
         Uint16 *dstp = (Uint16 *) info->dst;
-        int dstskip = info->dst_pitch >> 1;
+        int dstskip = info->dst_skip >> 1;
         alpha >>= 3;            /* downscale alpha to 5 bits */
 
         while (height--) {
@@ -1874,16 +1874,16 @@
 static void
 Blit555to555SurfaceAlpha(SDL_BlitInfo * info)
 {
-    unsigned alpha = (info->cmod >> 24);        /* downscale alpha to 5 bits */
+    unsigned alpha = info->a;   /* downscale alpha to 5 bits */
     if (alpha == 128) {
         Blit16to16SurfaceAlpha128(info, 0xfbde);
     } else {
         int width = info->dst_w;
         int height = info->dst_h;
         Uint16 *srcp = (Uint16 *) info->src;
-        int srcskip = info->s_skip >> 1;
+        int srcskip = info->src_skip >> 1;
         Uint16 *dstp = (Uint16 *) info->dst;
-        int dstskip = info->dst_pitch >> 1;
+        int dstskip = info->dst_skip >> 1;
         alpha >>= 3;            /* downscale alpha to 5 bits */
 
         while (height--) {
@@ -1916,9 +1916,9 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint16 *dstp = (Uint16 *) info->dst;
-    int dstskip = info->dst_pitch >> 1;
+    int dstskip = info->dst_skip >> 1;
 
     while (height--) {
 	    /* *INDENT-OFF* */
@@ -1962,9 +1962,9 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip >> 2;
+    int srcskip = info->src_skip >> 2;
     Uint16 *dstp = (Uint16 *) info->dst;
-    int dstskip = info->dst_pitch >> 1;
+    int dstskip = info->dst_skip >> 1;
 
     while (height--) {
 	    /* *INDENT-OFF* */
@@ -2009,14 +2009,14 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
+    int dstskip = info->dst_skip;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
     int srcbpp = srcfmt->BytesPerPixel;
     int dstbpp = dstfmt->BytesPerPixel;
-    unsigned sA = (info->cmod >> 24);
+    unsigned sA = info->a;
     unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
 
     if (sA) {
@@ -2053,15 +2053,15 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    Uint32 ckey = info->ckey;
+    int dstskip = info->dst_skip;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
+    Uint32 ckey = info->colorkey;
     int srcbpp = srcfmt->BytesPerPixel;
     int dstbpp = dstfmt->BytesPerPixel;
-    unsigned sA = (info->cmod >> 24);
+    unsigned sA = info->a;
     unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
 
     while (height--) {
@@ -2099,11 +2099,11 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
+    int dstskip = info->dst_skip;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
 
     int srcbpp;
     int dstbpp;
@@ -2147,81 +2147,14 @@
 }
 
 
-SDL_loblit
-SDL_CalculateAlphaBlit(SDL_Surface * surface, int blit_index)
+SDL_BlitFunc
+SDL_CalculateBlitA(SDL_Surface * surface)
 {
     SDL_PixelFormat *sf = surface->format;
     SDL_PixelFormat *df = surface->map->dst->format;
 
-    if (sf->Amask == 0) {
-        if ((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
-            if (df->BytesPerPixel == 1)
-                return BlitNto1SurfaceAlphaKey;
-            else
-#if SDL_ALTIVEC_BLITTERS
-            if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 &&
-                    SDL_HasAltiVec())
-                return Blit32to32SurfaceAlphaKeyAltivec;
-            else
-#endif
-                return BlitNtoNSurfaceAlphaKey;
-        } else {
-            /* Per-surface alpha blits */
-            switch (df->BytesPerPixel) {
-            case 1:
-                return BlitNto1SurfaceAlpha;
-
-            case 2:
-                if (surface->map->identity) {
-                    if (df->Gmask == 0x7e0) {
-#ifdef __MMX__
-                        if (SDL_HasMMX())
-                            return Blit565to565SurfaceAlphaMMX;
-                        else
-#endif
-                            return Blit565to565SurfaceAlpha;
-                    } else if (df->Gmask == 0x3e0) {
-#ifdef __MMX__
-                        if (SDL_HasMMX())
-                            return Blit555to555SurfaceAlphaMMX;
-                        else
-#endif
-                            return Blit555to555SurfaceAlpha;
-                    }
-                }
-                return BlitNtoNSurfaceAlpha;
-
-            case 4:
-                if (sf->Rmask == df->Rmask
-                    && sf->Gmask == df->Gmask
-                    && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) {
-#ifdef __MMX__
-                    if (sf->Rshift % 8 == 0
-                        && sf->Gshift % 8 == 0
-                        && sf->Bshift % 8 == 0 && SDL_HasMMX())
-                        return BlitRGBtoRGBSurfaceAlphaMMX;
-#endif
-                    if ((sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff) {
-#if SDL_ALTIVEC_BLITTERS
-                        if (SDL_HasAltiVec())
-                            return BlitRGBtoRGBSurfaceAlphaAltivec;
-#endif
-                        return BlitRGBtoRGBSurfaceAlpha;
-                    }
-                }
-#if SDL_ALTIVEC_BLITTERS
-                if ((sf->BytesPerPixel == 4) && SDL_HasAltiVec())
-                    return Blit32to32SurfaceAlphaAltivec;
-                else
-#endif
-                    return BlitNtoNSurfaceAlpha;
-
-            case 3:
-            default:
-                return BlitNtoNSurfaceAlpha;
-            }
-        }
-    } else {
+    switch (surface->map->info.flags) {
+    case SDL_COPY_BLEND:
         /* Per-pixel alpha blits */
         switch (df->BytesPerPixel) {
         case 1:
@@ -2284,7 +2217,84 @@
         default:
             return BlitNtoNPixelAlpha;
         }
+        break;
+
+    case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
+        if (sf->Amask == 0) {
+            /* Per-surface alpha blits */
+            switch (df->BytesPerPixel) {
+            case 1:
+                return BlitNto1SurfaceAlpha;
+
+            case 2:
+                if (surface->map->identity) {
+                    if (df->Gmask == 0x7e0) {
+#ifdef __MMX__
+                        if (SDL_HasMMX())
+                            return Blit565to565SurfaceAlphaMMX;
+                        else
+#endif
+                            return Blit565to565SurfaceAlpha;
+                    } else if (df->Gmask == 0x3e0) {
+#ifdef __MMX__
+                        if (SDL_HasMMX())
+                            return Blit555to555SurfaceAlphaMMX;
+                        else
+#endif
+                            return Blit555to555SurfaceAlpha;
+                    }
+                }
+                return BlitNtoNSurfaceAlpha;
+
+            case 4:
+                if (sf->Rmask == df->Rmask
+                    && sf->Gmask == df->Gmask
+                    && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) {
+#ifdef __MMX__
+                    if (sf->Rshift % 8 == 0
+                        && sf->Gshift % 8 == 0
+                        && sf->Bshift % 8 == 0 && SDL_HasMMX())
+                        return BlitRGBtoRGBSurfaceAlphaMMX;
+#endif
+                    if ((sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff) {
+#if SDL_ALTIVEC_BLITTERS
+                        if (SDL_HasAltiVec())
+                            return BlitRGBtoRGBSurfaceAlphaAltivec;
+#endif
+                        return BlitRGBtoRGBSurfaceAlpha;
+                    }
+                }
+#if SDL_ALTIVEC_BLITTERS
+                if ((sf->BytesPerPixel == 4) && SDL_HasAltiVec())
+                    return Blit32to32SurfaceAlphaAltivec;
+                else
+#endif
+                    return BlitNtoNSurfaceAlpha;
+
+            case 3:
+            default:
+                return BlitNtoNSurfaceAlpha;
+            }
+        }
+        break;
+
+    case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
+        if (sf->Amask == 0) {
+            if (df->BytesPerPixel == 1)
+                return BlitNto1SurfaceAlphaKey;
+            else
+#if SDL_ALTIVEC_BLITTERS
+            if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 &&
+                    SDL_HasAltiVec())
+                return Blit32to32SurfaceAlphaKeyAltivec;
+            else
+#endif
+                return BlitNtoNSurfaceAlphaKey;
+        }
+        break;
     }
+
+    return NULL;
 }
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_blit_N.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_blit_N.c	Sat Aug 18 05:39:09 2007 +0000
@@ -160,9 +160,9 @@
 {
     int height = info->dst_h;
     Uint8 *src = (Uint8 *) info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = (Uint8 *) info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     SDL_PixelFormat *srcfmt = info->src;
     vector unsigned char valpha = vec_splat_u8(0);
     vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL);
@@ -264,9 +264,9 @@
 {
     int height = info->dst_h;
     Uint8 *src = (Uint8 *) info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = (Uint8 *) info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     unsigned alpha;
@@ -322,8 +322,8 @@
     vf800 = (vector unsigned short) vec_splat_u8(-7);
     vf800 = vec_sl(vf800, vec_splat_u16(8));
 
-    if (dstfmt->Amask && (info->cmod >> 24)) {
-        ((unsigned char *) &valpha)[0] = alpha = (info->cmod >> 24);
+    if (dstfmt->Amask && info->a) {
+        ((unsigned char *) &valpha)[0] = alpha = info->a;
         valpha = vec_splat(valpha, 0);
     } else {
         alpha = 0;
@@ -412,9 +412,9 @@
 {
     int height = info->dst_h;
     Uint8 *src = (Uint8 *) info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = (Uint8 *) info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     unsigned alpha;
@@ -470,8 +470,8 @@
     vf800 = (vector unsigned short) vec_splat_u8(-7);
     vf800 = vec_sl(vf800, vec_splat_u16(8));
 
-    if (dstfmt->Amask && (info->cmod >> 24)) {
-        ((unsigned char *) &valpha)[0] = alpha = (info->cmod >> 24);
+    if (dstfmt->Amask && info->a) {
+        ((unsigned char *) &valpha)[0] = alpha = info->a;
         valpha = vec_splat(valpha, 0);
     } else {
         alpha = 0;
@@ -561,17 +561,17 @@
 {
     int height = info->dst_h;
     Uint32 *srcp = (Uint32 *) info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint32 *dstp = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     SDL_PixelFormat *srcfmt = info->src;
     int srcbpp = srcfmt->BytesPerPixel;
     SDL_PixelFormat *dstfmt = info->dst;
     int dstbpp = dstfmt->BytesPerPixel;
     int copy_alpha = (srcfmt->Amask && dstfmt->Amask);
-    unsigned alpha = dstfmt->Amask ? (info->cmod >> 24) : 0;
+    unsigned alpha = dstfmt->Amask ? info->a : 0;
     Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
-    Uint32 ckey = info->ckey;
+    Uint32 ckey = info->colorkey;
     vector unsigned int valpha;
     vector unsigned char vpermute;
     vector unsigned char vzero;
@@ -679,17 +679,17 @@
 {
     int height = info->dst_h;
     Uint32 *src = (Uint32 *) info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint32 *dst = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     vector unsigned int vzero = vec_splat_u32(0);
     vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt);
     if (dstfmt->Amask && !srcfmt->Amask) {
-        if ((info->cmod >> 24)) {
+        if (info->a) {
             vector unsigned char valpha;
-            ((unsigned char *) &valpha)[0] = (info->cmod >> 24);
+            ((unsigned char *) &valpha)[0] = info->a;
             vzero = (vector unsigned int) vec_splat(valpha, 0);
         }
     }
@@ -758,17 +758,17 @@
 
     int height = info->dst_h;
     Uint32 *src = (Uint32 *) info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint32 *dst = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch;
+    int dstskip = info->dst_skip;
     SDL_PixelFormat *srcfmt = info->src;
     SDL_PixelFormat *dstfmt = info->dst;
     vector unsigned int vzero = vec_splat_u32(0);
     vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt);
     if (dstfmt->Amask && !srcfmt->Amask) {
-        if ((info->cmod >> 24)) {
+        if (info->a) {
             vector unsigned char valpha;
-            ((unsigned char *) &valpha)[0] = (info->cmod >> 24);
+            ((unsigned char *) &valpha)[0] = info->a;
             vzero = (vector unsigned int) vec_splat(valpha, 0);
         }
     }
@@ -901,9 +901,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = (Uint32 *) info->src;
-    srcskip = info->s_skip / 4;
+    srcskip = info->src_skip / 4;
     dst = info->dst;
-    dstskip = info->dst_pitch;
+    dstskip = info->dst_skip;
     map = info->table;
 
     if (map == NULL) {
@@ -1018,9 +1018,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = (Uint32 *) info->src;
-    srcskip = info->s_skip / 4;
+    srcskip = info->src_skip / 4;
     dst = (Uint16 *) info->dst;
-    dstskip = info->dst_pitch / 2;
+    dstskip = info->dst_skip / 2;
 
 #ifdef USE_DUFFS_LOOP
     while (height--) {
@@ -1142,9 +1142,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = (Uint32 *) info->src;
-    srcskip = info->s_skip / 4;
+    srcskip = info->src_skip / 4;
     dst = (Uint16 *) info->dst;
-    dstskip = info->dst_pitch / 2;
+    dstskip = info->dst_skip / 2;
 
 #ifdef USE_DUFFS_LOOP
     while (height--) {
@@ -1255,9 +1255,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = (Uint8 *) info->src;
-    srcskip = info->s_skip;
+    srcskip = info->src_skip;
     dst = (Uint32 *) info->dst;
-    dstskip = info->dst_pitch / 4;
+    dstskip = info->dst_skip / 4;
 
 #ifdef USE_DUFFS_LOOP
     while (height--) {
@@ -1877,9 +1877,9 @@
     width = info->dst_w;
     height = info->dst_h;
     src = (Uint32 *) info->src;
-    srcskip = info->s_skip / 4;
+    srcskip = info->src_skip / 4;
     dst = info->dst;
-    dstskip = info->dst_pitch;
+    dstskip = info->dst_skip;
     map = info->table;
 
 #ifdef USE_DUFFS_LOOP
@@ -1950,11 +1950,11 @@
     width = info->dst_w;
     height = info->dst_h;
     src = info->src;
-    srcskip = info->s_skip;
+    srcskip = info->src_skip;
     dst = info->dst;
-    dstskip = info->dst_pitch;
+    dstskip = info->dst_skip;
     map = info->table;
-    srcfmt = info->src;
+    srcfmt = info->src_fmt;
     srcbpp = srcfmt->BytesPerPixel;
 
     if (map == NULL) {
@@ -2031,15 +2031,15 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint32 *src = (Uint32 *) info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint32 *dst = (Uint32 *) info->dst;
-    int dstskip = info->dst_pitch;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
+    int dstskip = info->dst_skip;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
 
     if (dstfmt->Amask) {
         /* RGB->RGBA, SET_ALPHA */
-        Uint32 mask = ((info->cmod >> 24) >> dstfmt->Aloss) << dstfmt->Ashift;
+        Uint32 mask = (info->a >> dstfmt->Aloss) << dstfmt->Ashift;
 
         while (height--) {
 			/* *INDENT-OFF* */
@@ -2080,14 +2080,14 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
-    SDL_PixelFormat *srcfmt = info->src;
+    int dstskip = info->dst_skip;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
     int srcbpp = srcfmt->BytesPerPixel;
-    SDL_PixelFormat *dstfmt = info->dst;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
     int dstbpp = dstfmt->BytesPerPixel;
-    unsigned alpha = dstfmt->Amask ? (info->cmod >> 24) : 0;
+    unsigned alpha = dstfmt->Amask ? info->a : 0;
 
     while (height--) {
 		/* *INDENT-OFF* */
@@ -2115,12 +2115,12 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
-    SDL_PixelFormat *srcfmt = info->src;
+    int dstskip = info->dst_skip;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
     int srcbpp = srcfmt->BytesPerPixel;
-    SDL_PixelFormat *dstfmt = info->dst;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
     int dstbpp = dstfmt->BytesPerPixel;
     int c;
 
@@ -2145,12 +2145,12 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
-    SDL_PixelFormat *srcfmt = info->src;
+    int dstskip = info->dst_skip;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
     const Uint8 *palmap = info->table;
-    Uint32 ckey = info->ckey;
+    Uint32 ckey = info->colorkey;
     Uint32 rgbmask = ~srcfmt->Amask;
     int srcbpp;
     Uint32 Pixel;
@@ -2211,11 +2211,11 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint16 *srcp = (Uint16 *) info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint16 *dstp = (Uint16 *) info->dst;
-    int dstskip = info->dst_pitch;
-    Uint32 ckey = info->ckey;
-    Uint32 rgbmask = ~info->src->Amask;
+    int dstskip = info->dst_skip;
+    Uint32 ckey = info->colorkey;
+    Uint32 rgbmask = ~info->src_fmt->Amask;
 
     /* Set up some basic variables */
     srcskip /= 2;
@@ -2245,15 +2245,15 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
-    Uint32 ckey = info->ckey;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
+    int dstskip = info->dst_skip;
+    Uint32 ckey = info->colorkey;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
     int srcbpp = srcfmt->BytesPerPixel;
     int dstbpp = dstfmt->BytesPerPixel;
-    unsigned alpha = dstfmt->Amask ? (info->cmod >> 24) : 0;
+    unsigned alpha = dstfmt->Amask ? info->a : 0;
     Uint32 rgbmask = ~srcfmt->Amask;
 
     /* Set up some basic variables */
@@ -2288,12 +2288,12 @@
     int width = info->dst_w;
     int height = info->dst_h;
     Uint8 *src = info->src;
-    int srcskip = info->s_skip;
+    int srcskip = info->src_skip;
     Uint8 *dst = info->dst;
-    int dstskip = info->dst_pitch;
-    Uint32 ckey = info->ckey;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
+    int dstskip = info->dst_skip;
+    Uint32 ckey = info->colorkey;
+    SDL_PixelFormat *srcfmt = info->src_fmt;
+    SDL_PixelFormat *dstfmt = info->dst_fmt;
     Uint32 rgbmask = ~srcfmt->Amask;
 
     Uint8 srcbpp;
@@ -2332,7 +2332,7 @@
     int dstbpp;
     Uint32 dstR, dstG, dstB;
     Uint32 blit_features;
-    SDL_loblit blitfunc;
+    SDL_BlitFunc blitfunc;
     enum
     { NO_ALPHA = 1, SET_ALPHA = 2, COPY_ALPHA = 4 } alpha;
 };
@@ -2403,30 +2403,77 @@
 /* Mask matches table, or table entry is zero */
 #define MASKOK(x, y) (((x) == (y)) || ((y) == 0x00000000))
 
-SDL_loblit
-SDL_CalculateBlitN(SDL_Surface * surface, int blit_index)
+SDL_BlitFunc
+SDL_CalculateBlitN(SDL_Surface * surface)
 {
     SDL_PixelFormat *srcfmt;
     SDL_PixelFormat *dstfmt;
     const struct blit_table *table;
     int which;
-    SDL_loblit blitfun;
+    SDL_BlitFunc blitfun;
 
     /* Set up data for choosing the blit */
     srcfmt = surface->format;
     dstfmt = surface->map->dst->format;
 
-    if (blit_index & 2) {
-        /* alpha or alpha+colorkey */
-        return SDL_CalculateAlphaBlit(surface, blit_index);
-    }
-
     /* We don't support destinations less than 8-bits */
     if (dstfmt->BitsPerPixel < 8) {
         return (NULL);
     }
 
-    if (blit_index == 1) {
+    switch (surface->map->info.flags) {
+    case 0:
+        blitfun = NULL;
+        if (dstfmt->BitsPerPixel == 8) {
+            /* We assume 8-bit destinations are palettized */
+            if ((srcfmt->BytesPerPixel == 4) &&
+                (srcfmt->Rmask == 0x00FF0000) &&
+                (srcfmt->Gmask == 0x0000FF00) &&
+                (srcfmt->Bmask == 0x000000FF)) {
+                if (surface->map->info.table) {
+                    blitfun = Blit_RGB888_index8_map;
+                } else {
+                    blitfun = Blit_RGB888_index8;
+                }
+            } else {
+                blitfun = BlitNto1;
+            }
+        } else {
+            /* Now the meat, choose the blitter we want */
+            int a_need = NO_ALPHA;
+            if (dstfmt->Amask)
+                a_need = srcfmt->Amask ? COPY_ALPHA : SET_ALPHA;
+            table = normal_blit[srcfmt->BytesPerPixel - 1];
+            for (which = 0; table[which].dstbpp; ++which) {
+                if (MASKOK(srcfmt->Rmask, table[which].srcR) &&
+                    MASKOK(srcfmt->Gmask, table[which].srcG) &&
+                    MASKOK(srcfmt->Bmask, table[which].srcB) &&
+                    MASKOK(dstfmt->Rmask, table[which].dstR) &&
+                    MASKOK(dstfmt->Gmask, table[which].dstG) &&
+                    MASKOK(dstfmt->Bmask, table[which].dstB) &&
+                    dstfmt->BytesPerPixel == table[which].dstbpp &&
+                    (a_need & table[which].alpha) == a_need &&
+                    ((table[which].blit_features & GetBlitFeatures()) ==
+                     table[which].blit_features))
+                    break;
+            }
+            blitfun = table[which].blitfunc;
+
+            if (blitfun == BlitNtoN) {  /* default C fallback catch-all. Slow! */
+                /* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
+                if (srcfmt->BytesPerPixel == 4 && dstfmt->BytesPerPixel == 4
+                    && srcfmt->Rmask == dstfmt->Rmask
+                    && srcfmt->Gmask == dstfmt->Gmask
+                    && srcfmt->Bmask == dstfmt->Bmask) {
+                    blitfun = Blit4to4MaskAlpha;
+                } else if (a_need == COPY_ALPHA) {
+                    blitfun = BlitNtoNCopyAlpha;
+                }
+            }
+        }
+        return (blitfun);
+
+    case SDL_COPY_COLORKEY:
         /* colorkey blit: Here we don't have too many options, mostly
            because RLE is the preferred fast way to deal with this.
            If a particular case turns out to be useful we'll add it. */
@@ -2442,70 +2489,15 @@
                 return Blit32to32KeyAltivec;
             } else
 #endif
-
-            if (srcfmt->Amask && dstfmt->Amask)
+            if (srcfmt->Amask && dstfmt->Amask) {
                 return BlitNtoNKeyCopyAlpha;
-            else
-                return BlitNtoNKey;
-        }
-    }
-
-    blitfun = NULL;
-    if (dstfmt->BitsPerPixel == 8) {
-        /* We assume 8-bit destinations are palettized */
-        if ((srcfmt->BytesPerPixel == 4) &&
-            (srcfmt->Rmask == 0x00FF0000) &&
-            (srcfmt->Gmask == 0x0000FF00) && (srcfmt->Bmask == 0x000000FF)) {
-            if (surface->map->table) {
-                blitfun = Blit_RGB888_index8_map;
             } else {
-                blitfun = Blit_RGB888_index8;
-            }
-        } else {
-            blitfun = BlitNto1;
-        }
-    } else {
-        /* Now the meat, choose the blitter we want */
-        int a_need = NO_ALPHA;
-        if (dstfmt->Amask)
-            a_need = srcfmt->Amask ? COPY_ALPHA : SET_ALPHA;
-        table = normal_blit[srcfmt->BytesPerPixel - 1];
-        for (which = 0; table[which].dstbpp; ++which) {
-            if (MASKOK(srcfmt->Rmask, table[which].srcR) &&
-                MASKOK(srcfmt->Gmask, table[which].srcG) &&
-                MASKOK(srcfmt->Bmask, table[which].srcB) &&
-                MASKOK(dstfmt->Rmask, table[which].dstR) &&
-                MASKOK(dstfmt->Gmask, table[which].dstG) &&
-                MASKOK(dstfmt->Bmask, table[which].dstB) &&
-                dstfmt->BytesPerPixel == table[which].dstbpp &&
-                (a_need & table[which].alpha) == a_need &&
-                ((table[which].blit_features & GetBlitFeatures()) ==
-                 table[which].blit_features))
-                break;
-        }
-        blitfun = table[which].blitfunc;
-
-        if (blitfun == BlitNtoN) {      /* default C fallback catch-all. Slow! */
-            /* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
-            if (srcfmt->BytesPerPixel == 4 && dstfmt->BytesPerPixel == 4 &&
-                srcfmt->Rmask == dstfmt->Rmask &&
-                srcfmt->Gmask == dstfmt->Gmask &&
-                srcfmt->Bmask == dstfmt->Bmask) {
-                blitfun = Blit4to4MaskAlpha;
-            } else if (a_need == COPY_ALPHA) {
-                blitfun = BlitNtoNCopyAlpha;
+                return BlitNtoNKey;
             }
         }
     }
 
-#ifdef DEBUG_ASM
-    if ((blitfun == BlitNtoN) || (blitfun == BlitNto1))
-        fprintf(stderr, "Using C blit\n");
-    else
-        fprintf(stderr, "Using optimized C blit\n");
-#endif /* DEBUG_ASM */
-
-    return (blitfun);
+    return NULL;
 }
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_blit_auto.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_blit_auto.c	Sat Aug 18 05:39:09 2007 +0000
@@ -5262,7 +5262,7 @@
     }
 }
 
-static SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
+SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale },
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend },
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale },
--- a/src/video/SDL_blit_copy.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_blit_copy.c	Sat Aug 18 05:39:09 2007 +0000
@@ -95,12 +95,12 @@
     int w, h;
     int srcskip, dstskip;
 
-    w = info->dst_w * info->dst->BytesPerPixel;
+    w = info->dst_w * info->dst_fmt->BytesPerPixel;
     h = info->dst_h;
     src = info->src;
     dst = info->dst;
-    srcskip = w + info->s_skip;
-    dstskip = w + info->dst_pitch;
+    srcskip = info->src_pitch;
+    dstskip = info->dst_pitch;
 
 #ifdef __SSE__
     if (SDL_HasSSE() && !((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) {
@@ -139,11 +139,11 @@
     int w, h;
     int skip;
 
-    w = info->dst_w * info->dst->BytesPerPixel;
+    w = info->dst_w * info->dst_fmt->BytesPerPixel;
     h = info->dst_h;
     src = info->src;
     dst = info->dst;
-    skip = w + info->s_skip;
+    skip = info->src_pitch;
     if ((dst < src) || (dst >= (src + h * skip))) {
         SDL_BlitCopy(info);
     } else {
--- a/src/video/SDL_pixels.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_pixels.c	Sat Aug 18 05:39:09 2007 +0000
@@ -668,12 +668,12 @@
 
 /* Map from Palette to BitField */
 static Uint8 *
-Map1toN(SDL_PixelFormat * src, Uint32 cmod, SDL_PixelFormat * dst)
+Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod,
+        SDL_PixelFormat * dst)
 {
     Uint8 *map;
     int i;
     int bpp;
-    unsigned Amod, Rmod, Gmod, Bmod;
     SDL_Palette *pal = src->palette;
 
     bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
@@ -683,17 +683,12 @@
         return (NULL);
     }
 
-    Amod = (cmod >> 24) & 0xFF;
-    Rmod = (cmod >> 16) & 0xFF;
-    Gmod = (cmod >> 8) & 0xFF;
-    Bmod = (cmod >> 0) & 0xFF;
-
     /* We memory copy to the pixel map so the endianness is preserved */
     for (i = 0; i < pal->ncolors; ++i) {
         Uint8 A = Amod;
-        Uint8 R = (pal->colors[i].r * Rmod) / 255;
-        Uint8 G = (pal->colors[i].g * Gmod) / 255;
-        Uint8 B = (pal->colors[i].b * Bmod) / 255;
+        Uint8 R = (Uint8) ((pal->colors[i].r * Rmod) / 255);
+        Uint8 G = (Uint8) ((pal->colors[i].g * Gmod) / 255);
+        Uint8 B = (Uint8) ((pal->colors[i].b * Bmod) / 255);
         ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, R, G, B, A);
     }
     return (map);
@@ -725,7 +720,10 @@
         SDL_OutOfMemory();
         return (NULL);
     }
-    map->cmod = 0xFFFFFFFF;
+    map->info.r = 0xFF;
+    map->info.g = 0xFF;
+    map->info.b = 0xFF;
+    map->info.a = 0xFF;
 
     /* It's ready to go */
     return (map);
@@ -739,9 +737,9 @@
     }
     map->dst = NULL;
     map->format_version = (unsigned int) -1;
-    if (map->table) {
-        SDL_free(map->table);
-        map->table = NULL;
+    if (map->info.table) {
+        SDL_free(map->info.table);
+        map->info.table = NULL;
     }
 }
 int
@@ -767,10 +765,10 @@
         switch (dstfmt->BytesPerPixel) {
         case 1:
             /* Palette --> Palette */
-            map->table =
+            map->info.table =
                 Map1to1(srcfmt->palette, dstfmt->palette, &map->identity);
             if (!map->identity) {
-                if (map->table == NULL) {
+                if (map->info.table == NULL) {
                     return (-1);
                 }
             }
@@ -780,8 +778,10 @@
 
         default:
             /* Palette --> BitField */
-            map->table = Map1toN(srcfmt, src->map->cmod, dstfmt);
-            if (map->table == NULL) {
+            map->info.table =
+                Map1toN(srcfmt, src->map->info.r, src->map->info.g,
+                        src->map->info.b, src->map->info.a, dstfmt);
+            if (map->info.table == NULL) {
                 return (-1);
             }
             break;
@@ -791,9 +791,9 @@
         switch (dstfmt->BytesPerPixel) {
         case 1:
             /* BitField --> Palette */
-            map->table = MapNto1(srcfmt, dstfmt, &map->identity);
+            map->info.table = MapNto1(srcfmt, dstfmt, &map->identity);
             if (!map->identity) {
-                if (map->table == NULL) {
+                if (map->info.table == NULL) {
                     return (-1);
                 }
             }
--- a/src/video/SDL_renderer_sw.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_renderer_sw.c	Sat Aug 18 05:39:09 2007 +0000
@@ -26,7 +26,6 @@
 #include "SDL_pixels_c.h"
 #include "SDL_rect_c.h"
 #include "SDL_yuv_sw_c.h"
-#include "SDL_rendercopy.h"
 
 
 /* SDL surface based renderer implementation */
@@ -431,81 +430,33 @@
     }
 }
 
-static void
-SW_UpdateRenderCopyFunc(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
-    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
-    SDL_DisplayMode *displayMode = &display->current_mode;
-    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-
-    /* We only need a special copy function for advanced features */
-    if (texture->modMode
-        || (texture->
-            blendMode & (SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD))
-        || texture->scaleMode) {
-        surface->userdata =
-            SDL_GetRenderCopyFunc(texture->format, displayMode->format,
-                                  texture->modMode, texture->blendMode,
-                                  texture->scaleMode);
-    } else {
-        surface->userdata = NULL;
-    }
-}
-
 static int
 SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
 {
-    SW_UpdateRenderCopyFunc(renderer, texture);
-    return 0;
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
+                                  texture->b);
 }
 
 static int
 SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
 {
-    SW_UpdateRenderCopyFunc(renderer, texture);
-    return 0;
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    return SDL_SetSurfaceAlphaMod(surface, texture->a);
 }
 
 static int
 SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
 {
-    switch (texture->blendMode) {
-    case SDL_TEXTUREBLENDMODE_NONE:
-    case SDL_TEXTUREBLENDMODE_MASK:
-    case SDL_TEXTUREBLENDMODE_BLEND:
-    case SDL_TEXTUREBLENDMODE_ADD:
-    case SDL_TEXTUREBLENDMODE_MOD:
-        SW_UpdateRenderCopyFunc(renderer, texture);
-        return 0;
-    default:
-        SDL_Unsupported();
-        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
-        SW_UpdateRenderCopyFunc(renderer, texture);
-        return -1;
-    }
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
 }
 
 static int
 SW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
 {
-    switch (texture->scaleMode) {
-    case SDL_TEXTURESCALEMODE_NONE:
-    case SDL_TEXTURESCALEMODE_FAST:
-        SW_UpdateRenderCopyFunc(renderer, texture);
-        return 0;
-    case SDL_TEXTURESCALEMODE_SLOW:
-    case SDL_TEXTURESCALEMODE_BEST:
-        SDL_Unsupported();
-        texture->scaleMode = SDL_TEXTURESCALEMODE_FAST;
-        SW_UpdateRenderCopyFunc(renderer, texture);
-        return -1;
-    default:
-        SDL_Unsupported();
-        texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
-        SW_UpdateRenderCopyFunc(renderer, texture);
-        return -1;
-    }
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    return SDL_SetSurfaceBlendMode(surface, texture->scaleMode);
 }
 
 static int
@@ -629,60 +580,18 @@
                                 data->surface.pixels, data->surface.pitch);
     } else {
         SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-        SDL_RenderCopyFunc copyfunc = (SDL_RenderCopyFunc) surface->userdata;
-
-        if (copyfunc) {
-            SDL_RenderCopyData copydata;
+        SDL_Rect real_srcrect = *srcrect;
+        SDL_Rect real_dstrect;
 
-            copydata.src =
-                (Uint8 *) surface->pixels + srcrect->y * surface->pitch +
-                srcrect->x * surface->format->BytesPerPixel;
-            copydata.src_w = srcrect->w;
-            copydata.src_h = srcrect->h;
-            copydata.src_pitch = surface->pitch;
-            copydata.dst = (Uint8 *) data->surface.pixels;
-            copydata.dst_w = dstrect->w;
-            copydata.dst_h = dstrect->h;
-            copydata.dst_pitch = data->surface.pitch;
-            copydata.flags = 0;
-            if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
-                copydata.flags |= SDL_RENDERCOPY_MODULATE_COLOR;
-                copydata.r = texture->r;
-                copydata.g = texture->g;
-                copydata.b = texture->b;
-            }
-            if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
-                copydata.flags |= SDL_RENDERCOPY_MODULATE_ALPHA;
-                copydata.a = texture->a;
-            }
-            if (texture->blendMode & SDL_TEXTUREBLENDMODE_MASK) {
-                copydata.flags |= SDL_RENDERCOPY_MASK;
-            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_BLEND) {
-                copydata.flags |= SDL_RENDERCOPY_BLEND;
-            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_ADD) {
-                copydata.flags |= SDL_RENDERCOPY_ADD;
-            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_MOD) {
-                copydata.flags |= SDL_RENDERCOPY_MOD;
-            }
-            if (texture->scaleMode) {
-                copydata.flags |= SDL_RENDERCOPY_NEAREST;
-            }
-            copyfunc(&copydata);
-            status = 0;
-        } else {
-            SDL_Rect real_srcrect = *srcrect;
-            SDL_Rect real_dstrect;
+        data->surface.w = dstrect->w;
+        data->surface.h = dstrect->h;
+        data->surface.clip_rect.w = dstrect->w;
+        data->surface.clip_rect.h = dstrect->h;
+        real_dstrect = data->surface.clip_rect;
 
-            data->surface.w = dstrect->w;
-            data->surface.h = dstrect->h;
-            data->surface.clip_rect.w = dstrect->w;
-            data->surface.clip_rect.h = dstrect->h;
-            real_dstrect = data->surface.clip_rect;
-
-            status =
-                SDL_LowerBlit(surface, &real_srcrect, &data->surface,
-                              &real_dstrect);
-        }
+        status =
+            SDL_LowerBlit(surface, &real_srcrect, &data->surface,
+                          &real_dstrect);
     }
     data->renderer->UnlockTexture(data->renderer,
                                   data->texture[data->current_texture]);
--- a/src/video/SDL_surface.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_surface.c	Sat Aug 18 05:39:09 2007 +0000
@@ -53,9 +53,6 @@
         SDL_FreeSurface(surface);
         return NULL;
     }
-    if (Amask) {
-        surface->flags |= SDL_SRCALPHA;
-    }
     surface->w = width;
     surface->h = height;
     surface->pitch = SDL_CalculatePitch(surface);
@@ -138,6 +135,11 @@
     }
     SDL_FormatChanged(surface);
 
+    /* By default surface with an alpha mask are set up for blending */
+    if (Amask) {
+        SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_BLEND);
+    }
+
     /* The surface is ready to go */
     surface->refcount = 1;
 #ifdef CHECK_LEAKS
@@ -212,26 +214,29 @@
     return 0;
 }
 
-int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
+int
+SDL_SetSurfaceRLE(SDL_Surface * surface, int flag)
 {
-    Uint32 flags;
+    int flags;
 
     if (!surface) {
         return -1;
     }
 
+    flags = surface->map->info.flags;
     if (flag) {
-        surface->flags |= SDL_RLEACCELOK;
+        surface->map->info.flags |= SDL_COPY_RLE_DESIRED;
     } else {
-        surface->flags &= ~SDL_RLEACCELOK;
+        surface->map->info.flags &= ~SDL_COPY_RLE_DESIRED;
     }
-    if (surface->flags != flags) {
+    if (surface->map->info.flags != flags) {
         SDL_InvalidateMap(surface->map);
     }
     return 0;
 }
 
-int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key)
+int
+SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key)
 {
     int flags;
 
@@ -253,10 +258,19 @@
     if (surface->map->info.flags != flags) {
         SDL_InvalidateMap(surface->map);
     }
+
+    /* Compatibility mode */
+    if (surface->map->info.flags & SDL_COPY_COLORKEY) {
+        surface->flags |= SDL_SRCCOLORKEY;
+    } else {
+        surface->flags &= ~SDL_SRCCOLORKEY;
+    }
+
     return 0;
 }
 
-int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
+int
+SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b)
 {
     int flags;
 
@@ -281,7 +295,8 @@
 }
 
 
-int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 * r, Uint8 * g, Uint8 * b)
+int
+SDL_GetSurfaceColorMod(SDL_Surface * surface, Uint8 * r, Uint8 * g, Uint8 * b)
 {
     if (!surface) {
         return -1;
@@ -299,7 +314,8 @@
     return 0;
 }
 
-int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
+int
+SDL_SetSurfaceAlphaMod(SDL_Surface * surface, Uint8 alpha)
 {
     int flags;
 
@@ -321,7 +337,8 @@
     return 0;
 }
 
-int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 * alpha)
+int
+SDL_GetSurfaceAlphaMod(SDL_Surface * surface, Uint8 * alpha)
 {
     if (!surface) {
         return -1;
@@ -333,7 +350,8 @@
     return 0;
 }
 
-int SDL_SetSurfaceBlendMode(SDL_Surface *surface, int blendMode)
+int
+SDL_SetSurfaceBlendMode(SDL_Surface * surface, int blendMode)
 {
     int flags, status;
 
@@ -343,7 +361,8 @@
 
     status = 0;
     flags = surface->map->info.flags;
-    surface->map->info.flags &= ~(SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD);
+    surface->map->info.flags &=
+        ~(SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD);
     switch (blendMode) {
     case SDL_TEXTUREBLENDMODE_NONE:
         break;
@@ -368,10 +387,19 @@
     if (surface->map->info.flags != flags) {
         SDL_InvalidateMap(surface->map);
     }
+
+    /* Compatibility mode */
+    if (surface->map->info.flags & SDL_COPY_BLEND) {
+        surface->flags |= SDL_SRCALPHA;
+    } else {
+        surface->flags &= ~SDL_SRCALPHA;
+    }
+
     return status;
 }
 
-int SDL_GetSurfaceBlendMode(SDL_Surface *surface, int *blendMode)
+int
+SDL_GetSurfaceBlendMode(SDL_Surface * surface, int *blendMode)
 {
     if (!surface) {
         return -1;
@@ -381,27 +409,30 @@
         return 0;
     }
 
-    switch(surface->map->info.flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
+    switch (surface->map->info.
+            flags & (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD |
+                     SDL_COPY_MOD)) {
     case SDL_COPY_MASK:
-        *blendMode = SDL_TEXTUREBLENDMODE_MASK:
+        *blendMode = SDL_TEXTUREBLENDMODE_MASK;
         break;
     case SDL_COPY_BLEND:
-        *blendMode = SDL_TEXTUREBLENDMODE_BLEND:
+        *blendMode = SDL_TEXTUREBLENDMODE_BLEND;
         break;
     case SDL_COPY_ADD:
-        *blendMode = SDL_TEXTUREBLENDMODE_ADD:
+        *blendMode = SDL_TEXTUREBLENDMODE_ADD;
         break;
     case SDL_COPY_MOD:
-        *blendMode = SDL_TEXTUREBLENDMODE_MOD:
+        *blendMode = SDL_TEXTUREBLENDMODE_MOD;
         break;
     default:
-        *blendMode = SDL_TEXTUREBLENDMODE_NONE:
+        *blendMode = SDL_TEXTUREBLENDMODE_NONE;
         break;
     }
     return 0;
 }
 
-int SDL_SetSurfaceScaleMode(SDL_Surface *surface, int scaleMode)
+int
+SDL_SetSurfaceScaleMode(SDL_Surface * surface, int scaleMode)
 {
     int flags, status;
 
@@ -436,7 +467,8 @@
     return status;
 }
 
-int SDL_GetSurfaceScaleMode(SDL_Surface *surface, int *scaleMode)
+int
+SDL_GetSurfaceScaleMode(SDL_Surface * surface, int *scaleMode)
 {
     if (!surface) {
         return -1;
@@ -446,12 +478,12 @@
         return 0;
     }
 
-    switch(surface->map->info.flags & (SDL_COPY_LINEAR)) {
-    case SDL_COPY_LINEAR:
-        *scaleMode = SDL_TEXTURESCALEMODE_FAST:
+    switch (surface->map->info.flags & (SDL_COPY_NEAREST)) {
+    case SDL_COPY_NEAREST:
+        *scaleMode = SDL_TEXTURESCALEMODE_FAST;
         break;
     default:
-        *scaleMode = SDL_TEXTURESCALEMODE_NONE:
+        *scaleMode = SDL_TEXTURESCALEMODE_NONE;
         break;
     }
     return 0;
@@ -706,7 +738,8 @@
     if (copy_flags & SDL_COPY_COLORKEY) {
         Uint8 keyR, keyG, keyB, keyA;
 
-        SDL_GetRGBA(colorkey, surface->format, &keyR, &keyG, &keyB, &keyA);
+        SDL_GetRGBA(surface->map->info.colorkey, surface->format, &keyR,
+                    &keyG, &keyB, &keyA);
         SDL_SetColorKey(convert, 1,
                         SDL_MapRGBA(convert->format, keyR, keyG, keyB, keyA));
     }
--- a/src/video/SDL_video.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/SDL_video.c	Sat Aug 18 05:39:09 2007 +0000
@@ -1552,7 +1552,9 @@
             return 0;
         }
     } else {
-        if (surface->format->Amask || !(flags & (SDL_COPY_COLORKEY|SDL_COPY_MASK|SDL_COPY_BLEND))) {
+        if (surface->format->Amask
+            || !(surface->map->info.flags &
+                 (SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) {
             bpp = fmt->BitsPerPixel;
             Rmask = fmt->Rmask;
             Gmask = fmt->Gmask;
@@ -1602,31 +1604,34 @@
         dst_fmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
         if (dst_fmt) {
             if (SDL_ISPIXELFORMAT_INDEXED(format)) {
-                dst_fmt->palette = SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
+                dst_fmt->palette =
+                    SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
                 if (dst_fmt->palette) {
-                    if (fmt->palette) {
-fixme
-                    } else {
-                        SDL_DitherColors(dst_fmt->palette->colors, SDL_BITSPERPIXEL(format));
-                    }
-                }
-                if (fmt->palette) {
-                    dst_fmt->palette = fmt->palette;
-                } else {
+                    /* FIXME: Should we try to copy fmt->palette? */
+                    SDL_DitherColors(dst_fmt->palette->colors,
+                                     SDL_BITSPERPIXEL(format));
                 }
             }
 
-            cvt = SDL_ConvertSurface(surface, fmt, 0);
-            if (cvt) {
-                SDL_UpdateTexture(textureID, NULL, cvt->pixels, cvt->pitch);
-                SDL_FreeSurface(cvt);
+            dst = SDL_ConvertSurface(surface, dst_fmt, 0);
+            if (dst) {
+                SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch);
+                SDL_FreeSurface(dst);
             }
-            SDL_FreeFormat(fmt);
+            if (dst_fmt->palette) {
+                SDL_FreePalette(dst_fmt->palette);
+            }
+            SDL_FreeFormat(dst_fmt);
+        }
+        if (!dst) {
+            SDL_DestroyTexture(textureID);
+            return 0;
         }
     }
 
     if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) {
-        SDL_SetTexturePalette(textureID, fmt->palette->colors, 0, fmt->palette->ncolors);
+        SDL_SetTexturePalette(textureID, fmt->palette->colors, 0,
+                              fmt->palette->ncolors);
     }
 
     return textureID;
--- a/src/video/dummy/SDL_nullrender.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/dummy/SDL_nullrender.c	Sat Aug 18 05:39:09 2007 +0000
@@ -25,7 +25,6 @@
 #include "../SDL_sysvideo.h"
 #include "../SDL_yuv_sw_c.h"
 #include "../SDL_renderer_sw.h"
-#include "../SDL_rendercopy.h"
 
 
 /* SDL surface based renderer implementation */
@@ -160,55 +159,10 @@
     } else {
         SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
         SDL_Surface *target = data->screens[data->current_screen];
-        SDL_RenderCopyFunc copyfunc = (SDL_RenderCopyFunc) surface->userdata;
-
-        if (copyfunc) {
-            SDL_RenderCopyData copydata;
+        SDL_Rect real_srcrect = *srcrect;
+        SDL_Rect real_dstrect = *dstrect;
 
-            copydata.src =
-                (Uint8 *) surface->pixels + srcrect->y * surface->pitch +
-                srcrect->x * surface->format->BytesPerPixel;
-            copydata.src_w = srcrect->w;
-            copydata.src_h = srcrect->h;
-            copydata.src_pitch = surface->pitch;
-            copydata.dst =
-                (Uint8 *) target->pixels + dstrect->y * target->pitch +
-                dstrect->x * target->format->BytesPerPixel;
-            copydata.dst_w = dstrect->w;
-            copydata.dst_h = dstrect->h;
-            copydata.dst_pitch = target->pitch;
-            copydata.flags = 0;
-            if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
-                copydata.flags |= SDL_RENDERCOPY_MODULATE_COLOR;
-                copydata.r = texture->r;
-                copydata.g = texture->g;
-                copydata.b = texture->b;
-            }
-            if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
-                copydata.flags |= SDL_RENDERCOPY_MODULATE_ALPHA;
-                copydata.a = texture->a;
-            }
-            if (texture->blendMode & SDL_TEXTUREBLENDMODE_MASK) {
-                copydata.flags |= SDL_RENDERCOPY_MASK;
-            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_BLEND) {
-                copydata.flags |= SDL_RENDERCOPY_BLEND;
-            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_ADD) {
-                copydata.flags |= SDL_RENDERCOPY_ADD;
-            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_MOD) {
-                copydata.flags |= SDL_RENDERCOPY_MOD;
-            }
-            if (texture->scaleMode) {
-                copydata.flags |= SDL_RENDERCOPY_NEAREST;
-            }
-            copyfunc(&copydata);
-            return 0;
-        } else {
-            SDL_Rect real_srcrect = *srcrect;
-            SDL_Rect real_dstrect = *dstrect;
-
-            return SDL_LowerBlit(surface, &real_srcrect, target,
-                                 &real_dstrect);
-        }
+        return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
     }
 }
 
--- a/src/video/sdlgenblit.pl	Sat Aug 18 01:44:21 2007 +0000
+++ b/src/video/sdlgenblit.pl	Sat Aug 18 05:39:09 2007 +0000
@@ -384,7 +384,7 @@
 sub output_copyfunctable
 {
     print FILE <<__EOF__;
-static SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
+SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
 __EOF__
     for (my $i = 0; $i <= $#src_formats; ++$i) {
         my $src = $src_formats[$i];
--- a/test/testalpha.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/test/testalpha.c	Sat Aug 18 05:39:09 2007 +0000
@@ -253,7 +253,7 @@
 MoveSprite(SDL_Surface * screen, SDL_Surface * light)
 {
     SDL_Rect updates[2];
-    int alpha;
+    Uint8 alpha;
 
     /* Erase the sprite if it was visible */
     if (sprite_visible) {
@@ -290,10 +290,10 @@
     }
 
     /* Update transparency (fade in and out) */
-    alpha = sprite->format->alpha;
-    if ((alpha + alpha_vel) < 0) {
+    SDL_GetSurfaceAlphaMod(sprite, &alpha);
+    if (((int) alpha + alpha_vel) < 0) {
         alpha_vel = -alpha_vel;
-    } else if ((alpha + alpha_vel) > 255) {
+    } else if (((int) alpha + alpha_vel) > 255) {
         alpha_vel = -alpha_vel;
     }
     SDL_SetAlpha(sprite, SDL_SRCALPHA, (Uint8) (alpha + alpha_vel));
--- a/test/testblitspeed.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/test/testblitspeed.c	Sat Aug 18 05:39:09 2007 +0000
@@ -91,9 +91,6 @@
         printf("  depth      : %d bits per pixel\n",
                surface->format->BitsPerPixel);
         printf("  pitch      : %d\n", (int) surface->pitch);
-        printf("  alpha      : %d\n", (int) surface->format->alpha);
-        printf("  colorkey   : 0x%X\n",
-               (unsigned int) surface->format->colorkey);
 
         printf("  red bits   : 0x%08X mask, %d shift, %d loss\n",
                (int) surface->format->Rmask,
@@ -216,8 +213,10 @@
     Uint32 origdstalphaflags = 0;
     Uint32 srcalphaflags = 0;
     Uint32 dstalphaflags = 0;
-    int srcalpha = 255;
-    int dstalpha = 255;
+    Uint8 origsrcalpha = 255;
+    Uint8 origdstalpha = 255;
+    Uint8 srcalpha = 255;
+    Uint8 dstalpha = 255;
     int screenSurface = 0;
     int i = 0;
 
@@ -313,8 +312,10 @@
         (dest->flags & SDL_SRCALPHA) | (dest->flags & SDL_RLEACCEL);
     origsrcalphaflags = srcalphaflags;
     origdstalphaflags = dstalphaflags;
-    srcalpha = src->format->alpha;
-    dstalpha = dest->format->alpha;
+    SDL_GetSurfaceAlphaMod(src, &srcalpha);
+    SDL_GetSurfaceAlphaMod(dest, &dstalpha);
+    origsrcalpha = srcalpha;
+    origdstalpha = dstalpha;
     for (i = 1; i < argc; i++) {
         const char *arg = argv[i];
 
@@ -339,12 +340,10 @@
         else if (strcmp(arg, "--dstnorleaccel") == 0)
             dstalphaflags &= ~SDL_RLEACCEL;
     }
-    if ((dstalphaflags != origdstalphaflags)
-        || (dstalpha != dest->format->alpha))
-        SDL_SetAlpha(dest, dstalphaflags, (Uint8) dstalpha);
-    if ((srcalphaflags != origsrcalphaflags)
-        || (srcalpha != src->format->alpha))
-        SDL_SetAlpha(src, srcalphaflags, (Uint8) srcalpha);
+    if ((dstalphaflags != origdstalphaflags) || (origdstalpha != dstalpha))
+        SDL_SetAlpha(dest, dstalphaflags, dstalpha);
+    if ((srcalphaflags != origsrcalphaflags) || (origsrcalpha != srcalpha))
+        SDL_SetAlpha(src, srcalphaflags, srcalpha);
 
     /* set some sane defaults so we can see if the blit code is broken... */
     SDL_FillRect(dest, NULL, SDL_MapRGB(dest->format, 0, 0, 0));
--- a/test/testgl.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/test/testgl.c	Sat Aug 18 05:39:09 2007 +0000
@@ -201,7 +201,7 @@
 
     /* Save the alpha blending attributes */
     saved_flags = surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
-    saved_alpha = surface->format->alpha;
+    SDL_GetSurfaceAlphaMod(surface, &saved_alpha);
     if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
         SDL_SetAlpha(surface, 0, 0);
     }
--- a/test/testoverlay.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/test/testoverlay.c	Sat Aug 18 05:39:09 2007 +0000
@@ -487,8 +487,6 @@
         format.Gloss = 0;
         format.Bloss = 0;
         format.Aloss = 8;
-        format.colorkey = 0;
-        format.alpha = 0;
 
         newsurf = SDL_ConvertSurface(pic, &format, SDL_SWSURFACE);
         if (!newsurf) {
--- a/test/testoverlay2.c	Sat Aug 18 01:44:21 2007 +0000
+++ b/test/testoverlay2.c	Sat Aug 18 05:39:09 2007 +0000
@@ -521,8 +521,6 @@
             format.Gloss = 0;
             format.Bloss = 0;
             format.Aloss = 8;
-            format.colorkey = 0;
-            format.alpha = 0;
 
             newsurf =
                 SDL_ConvertSurface(MooseFrame[i], &format, SDL_SWSURFACE);