From 224f95537b578bb2e3ccbf031b236bdcf7febf9f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 11 Sep 2008 12:04:45 +0000 Subject: Code optimizations from Fingolfin svn-id: r34491 --- engines/drascula/graphics.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/engines/drascula/graphics.cpp b/engines/drascula/graphics.cpp index 29f984c2b4..37759c7119 100644 --- a/engines/drascula/graphics.cpp +++ b/engines/drascula/graphics.cpp @@ -167,8 +167,18 @@ void DrasculaEngine::copyBackground(int xorg, int yorg, int xdes, int ydes, int int height, byte *src, byte *dest) { dest += xdes + ydes * 320; src += xorg + yorg * 320; + /* Unoptimized code for (int x = 0; x < height; x++) { memcpy(dest + 320 * x, src + 320 * x, width); + } */ + + // A bit more optimized code, thanks to Fingolfin + // Uses 2 less registers and performs 2 less multiplications + int x = height; + while (x--) { + memcpy(dest, src, width); + dest += 320; + src += 320; } } @@ -223,8 +233,19 @@ void DrasculaEngine::updateScreen(int xorg, int yorg, int xdes, int ydes, int wi ptr += xdes + ydes * 320; buffer += xorg + yorg * 320; + + /* Unoptimized code for (int x = 0; x < height; x++) { memcpy(ptr + 320 * x, buffer + 320 * x, width); + } */ + + // A bit more optimized code, thanks to Fingolfin + // Uses 2 less registers and performs 2 less multiplications + int x = height; + while (x--) { + memcpy(ptr, buffer, width); + ptr += 320; + buffer += 320; } _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); -- cgit v1.2.3