Fixed bug 5510 - simplify the scaling functions
diff --git a/src/video/SDL_blit_slow.c b/src/video/SDL_blit_slow.c
index c0c1856..3ef3319 100644
--- a/src/video/SDL_blit_slow.c
+++ b/src/video/SDL_blit_slow.c
@@ -40,7 +40,7 @@
     Uint32 dstpixel;
     Uint32 dstR, dstG, dstB, dstA;
     int srcy, srcx;
-    int posy, posx;
+    Uint32 posy, posx;
     int incy, incx;
     SDL_PixelFormat *src_fmt = info->src_fmt;
     SDL_PixelFormat *dst_fmt = info->dst_fmt;
@@ -49,7 +49,6 @@
     Uint32 rgbmask = ~src_fmt->Amask;
     Uint32 ckey = info->colorkey & rgbmask;
 
-    srcy = 0;
     posy = 0;
     incy = (info->src_h << 16) / info->dst_h;
     incx = (info->src_w << 16) / info->dst_w;
@@ -58,21 +57,11 @@
         Uint8 *src = 0;
         Uint8 *dst = info->dst;
         int n = info->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
+        posx = 0;
+        srcy = posy >> 16;
         while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src =
-                    (info->src + (srcy * info->src_pitch) + (srcx * srcbpp));
-            }
+            srcx = posx >> 16;
+            src = (info->src + (srcy * info->src_pitch) + (srcx * srcbpp));
             if (src_fmt->Amask) {
                 DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
                               srcB, srcA);
diff --git a/src/video/sdlgenblit.pl b/src/video/sdlgenblit.pl
index e267302..63d6dc9 100755
--- a/src/video/sdlgenblit.pl
+++ b/src/video/sdlgenblit.pl
@@ -452,13 +452,12 @@
     if ( $scale ) {
         print FILE <<__EOF__;
     int srcy, srcx;
-    int posy, posx;
+    Uint32 posy, posx;
     int incy, incx;
 __EOF__
 
     print FILE <<__EOF__;
 
-    srcy = 0;
     posy = 0;
     incy = (info->src_h << 16) / info->dst_h;
     incx = (info->src_w << 16) / info->dst_w;
@@ -467,22 +466,14 @@
         $format_type{$src} *src = 0;
         $format_type{$dst} *dst = ($format_type{$dst} *)info->dst;
         int n = info->dst_w;
-        srcx = -1;
-        posx = 0x10000L;
-        while (posy >= 0x10000L) {
-            ++srcy;
-            posy -= 0x10000L;
-        }
+        posx = 0;
+
+        srcy = posy >> 16;
         while (n--) {
-            if (posx >= 0x10000L) {
-                while (posx >= 0x10000L) {
-                    ++srcx;
-                    posx -= 0x10000L;
-                }
-                src = ($format_type{$src} *)(info->src + (srcy * info->src_pitch) + (srcx * $format_size{$src}));
+            srcx = posx >> 16;
+            src = ($format_type{$src} *)(info->src + (srcy * info->src_pitch) + (srcx * $format_size{$src}));
 __EOF__
         print FILE <<__EOF__;
-            }
 __EOF__
         output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF);
         print FILE <<__EOF__;