changeset 1927:1b55bcf548de

Cleanup.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 28 Jun 2018 13:39:18 +0300
parents f4fa11ecdc6f
children 0b2a2da4c7e7
files tools/lib64gfx.c
diffstat 1 files changed, 12 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Thu Jun 28 01:28:28 2018 +0300
+++ b/tools/lib64gfx.c	Thu Jun 28 13:39:18 2018 +0300
@@ -1264,28 +1264,28 @@
         Uint8 *dp = dst->data + (yc * dst->pitch);
         const int y = yc / 8, yb = yc & 7;
         const int scroffsy = y * src->chWidth;
+        const int bmoffsy = y * src->chWidth * 8 + yb;
 
+        for (int xc = 0; xc < rwidth; xc++)
         if (src->type & D64_FMT_CHAR)
         {
             // Charmode conversion
             if ((src->type & D64_FMT_MC) == D64_FMT_HIRES)
-            // Hi-res charmap
-            for (int xc = 0; xc < rwidth; xc++)
             {
+                // Hi-res charmap
                 const int x = xc / 8;
                 const int scroffs = scroffsy + x;
                 const int chr = src->screen[0].data[scroffs];
-                const int v = 7 - (xc & 7);
+                const int vshift = 7 - (xc & 7);
 
-                if ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> v) & 1)
+                if ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> vshift) & 1)
                     *dp++ = src->color[0].data[scroffs];
                 else
                     *dp++ = src->bgcolor;
             }
             else
-            // Multicolor variants
-            for (int xc = 0; xc < rwidth; xc++)
             {
+                // Multicolor variants
                 const int x = xc / 4;
                 const int scroffs = scroffsy + x;
                 const int chr = src->screen[0].data[scroffs];
@@ -1293,8 +1293,8 @@
 
                 if (col & 8)
                 {
-                    const int v = 6 - ((xc * 2) & 6);
-                    switch ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> v) & 3)
+                    const int vshift = 6 - ((xc * 2) & 6);
+                    switch ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> vshift) & 3)
                     {
                         case 0: *dp++ = src->bgcolor; break;
                         case 1: *dp++ = src->d022; break;
@@ -1304,8 +1304,8 @@
                 }
                 else
                 {
-                    const int v = 7 - (xc & 7);
-                    if ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> v) & 1)
+                    const int vshift = 7 - (xc & 7);
+                    if ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> vshift) & 1)
                         *dp++ = src->color[0].data[scroffs];
                     else
                         *dp++ = src->bgcolor;
@@ -1315,12 +1315,9 @@
         else
         {
             // Perform generic BITMAP conversion
-            const int bmoffsy = y * src->chWidth * 8 + yb;
-
             if ((src->type & D64_FMT_MC) == D64_FMT_HIRES)
-            // Hi-res bitmap
-            for (int xc = 0; xc < rwidth; xc++)
             {
+                // Hi-res bitmap
                 const int x = xc / 8;
                 const int scroffs = scroffsy + x;
                 const int bmoffs = bmoffsy + (x * 8);
@@ -1329,9 +1326,8 @@
                 *dp++ = getPixel(src, bmoffs, scroffs, vshift, 0, xc, yc);
             }
             else
-            // Multicolor bitmap and variants
-            for (int xc = 0; xc < rwidth; xc++)
             {
+                // Multicolor bitmap and variants
                 const int x = xc / 4;
                 const int scroffs = scroffsy + x;
                 const int bmoffs = bmoffsy + (x * 8);