diff --git a/sc2/src/sc2code/libs/graphics/sdl/pure.c b/sc2/src/sc2code/libs/graphics/sdl/pure.c index dc7837332..7630924c1 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/pure.c +++ b/sc2/src/sc2code/libs/graphics/sdl/pure.c @@ -139,29 +139,25 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp) static void Scale_Nearest (SDL_Surface *src, SDL_Surface *dst) { int x, y; - const int w = src->w, h = src->h; + const int w = src->w, h = src->h, dw = dst->w; switch (dst->format->BytesPerPixel) { case 2: { - Uint16 *src_p = (Uint16 *)src->pixels, *dst_p = (Uint16 *)dst->pixels, *src_p2; + Uint16 *src_p = (Uint16 *)src->pixels, *dst_p = (Uint16 *)dst->pixels; Uint16 pixval_16; for (y = 0; y < h; ++y) { - src_p2 = dst_p; for (x = 0; x < w; ++x) { pixval_16 = *src_p++; + dst_p[dw] = pixval_16; *dst_p++ = pixval_16; + dst_p[dw] = pixval_16; *dst_p++ = pixval_16; } - for (x = 0; x < w; ++x) - { - *(Uint32*)dst_p = *(Uint32*)src_p2; - dst_p += 2; - src_p2 += 2; - } + dst_p += dw; } break; } @@ -196,24 +192,19 @@ static void Scale_Nearest (SDL_Surface *src, SDL_Surface *dst) } case 4: { - Uint32 *src_p = (Uint32 *)src->pixels, *dst_p = (Uint32 *)dst->pixels, *src_p2; + Uint32 *src_p = (Uint32 *)src->pixels, *dst_p = (Uint32 *)dst->pixels; Uint32 pixval_32; for (y = 0; y < h; ++y) { - src_p2 = src_p; - for (x = 0; x < w; ++x) - { - pixval_32 = *src_p++; - *dst_p++ = pixval_32; - *dst_p++ = pixval_32; - } - src_p = src_p2; for (x = 0; x < w; ++x) { pixval_32 = *src_p++; + dst_p[dw] = pixval_32; *dst_p++ = pixval_32; + dst_p[dw] = pixval_32; *dst_p++ = pixval_32; } + dst_p += dw; } break; }