changeset 225:1c9deae71fb1

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 05 Sep 2018 20:28:23 +0300
parents 33a5c7670e66
children caefc3c9e78c
files draw_inputs.pde draw_outputs.pde draw_smart.pde events.pde exporters.pde files.pde interface.pde
diffstat 7 files changed, 927 insertions(+), 452 deletions(-) [+]
line wrap: on
line diff
--- a/draw_inputs.pde	Wed Sep 05 20:08:57 2018 +0300
+++ b/draw_inputs.pde	Wed Sep 05 20:28:23 2018 +0300
@@ -52,7 +52,8 @@
     ad = 1024 + xc + yc * X;
     looks = 65536 + int(xc / 8) + int(yc / 8) * MX;
     mmc = g_brush[ad] + g_brush[ad + 1] * 2;
-    switch (mmc) {
+    switch (mmc)
+    {
         case 0:
             return g_map[1];
         case 1:
@@ -185,19 +186,26 @@
 
     if (ssap == 1)
     {
-        if (mode == 0) {
+        if (mode == 0)
+        {
             val = g_map[ad];
-        } else {
+        }
+        else
+        {
             val = g_brush[ad];
         }
         if (g_britemode == 1 && val == 8) return 0;
         return val;
     }
     else
-    if (ssap == 0) {
-        if (mode == 0) {
+    if (ssap == 0)
+    {
+        if (mode == 0)
+        {
             val = g_map[ad + (MX * MY) * 8];
-        } else {
+        }
+        else
+        {
             val = g_brush[ad + (MX * MY) * 8];
         }
         if (g_britemode == 1 && val == 8) return 0;
@@ -229,25 +237,34 @@
     xx = 0;
     okay = 0;
     cp = easygetcolor(0, 0);
-    for (xx = 0; xx < X; xx = xx + g_pixelw) {
-        if (easygetcolor(xx, 0) == cp && okay == 0) {
+    for (xx = 0; xx < X; xx = xx + g_pixelw)
+    {
+        if (easygetcolor(xx, 0) == cp && okay == 0)
+        {
             g_animx = xx;
-        } else {
+        }
+        else
+        {
             okay = 1;
         }
     }
     okay = 0;
-    for (yy = 0; yy < Y; yy++) {
-        if (easygetcolor(0, yy) == cp && okay == 0) {
+    for (yy = 0; yy < Y; yy++)
+    {
+        if (easygetcolor(0, yy) == cp && okay == 0)
+        {
             g_animy = yy;
-        } else {
+        }
+        else
+        {
             okay = 1;
         }
     }
 
     g_animx = g_animx + g_pixelw;
     g_animy = g_animy + 1;
-    if (g_animx > 63 || g_animy > 63 || g_animx <= 2 || g_animy <= 2) {
+    if (g_animx > 63 || g_animy > 63 || g_animx <= 2 || g_animy <= 2)
+    {
         message("BAD SIZE|See manual");
         restoreparameters();
         g_data[int('n')] = 0;
@@ -265,11 +282,15 @@
     g_animframes = 0;
     g_animno = 1;
     int raamit = -1;
-    for (yy = 0; yy <= Y; yy = yy + g_animy) {
-        for (xx = 0; xx <= X; xx = xx + g_animx) {
+    for (yy = 0; yy <= Y; yy = yy + g_animy)
+    {
+        for (xx = 0; xx <= X; xx = xx + g_animx)
+        {
             okay = 1;
-            for (bx = 0; bx < g_animx; bx = bx + g_pixelw) {
-                for (by = 0; by < g_animy; by++) {
+            for (bx = 0; bx < g_animx; bx = bx + g_pixelw)
+            {
+                for (by = 0; by < g_animy; by++)
+                {
                     if (easygetcolor(xx + bx, yy + by) != cp) okay = 0;
                 }
             }
@@ -277,7 +298,8 @@
             if (xx + g_animx < X || xx + g_animx == X) raamit++;
         }
     }
-    if (g_animframes <= 0) {
+    if (g_animframes <= 0)
+    {
         message("BAD BOOKEND|See manual");
         restoreparameters();
         g_data[int('n')] = 0;
@@ -291,7 +313,8 @@
 }
 
 
-void animbrush_do() {
+void animbrush_do()
+{
     int bx, by;
     int horisize;
     horisize = int(X / g_animx);
@@ -305,16 +328,20 @@
     g_bsourcey2 = g_bsourcey + g_animy - 1;
 }
 
-void set_fixed_raster(int set) {
-    for (int i = 0; i < 64; i++) {
+void set_fixed_raster(int set)
+{
+    for (int i = 0; i < 64; i++)
+    {
         g_fixedraster[i] = g_rasterpatterns[set * 64 + i];
     }
 }
 
-int get_raster(int xx, int yy) {
+int get_raster(int xx, int yy)
+{
     xx = xx + g_raster_offset_x * g_pixelw;
     yy = yy + g_raster_offset_y;
-    if (g_pixelw == 2) {
+    if (g_pixelw == 2)
+    {
         xx = int(xx / 2);
     }
     int mx = chop8(xx);
@@ -324,10 +351,12 @@
     return g_fixedraster[xx + yy * 8];
 }
 
-void refreshpalette() {
+void refreshpalette()
+{
     //relevant for alterable palettes, such as amiga or cpc
     if (g_palsteps == 0) return;
-    for (int i = 0; i < g_maxcolors; i++) {
+    for (int i = 0; i < g_maxcolors; i++)
+    {
         makecolor(i, int(g_map[256 + i * 3]), int(g_map[256 + i * 3 + 1]), int(g_map[256 + i * 3 + 2]));
     }
 }
--- a/draw_outputs.pde	Wed Sep 05 20:08:57 2018 +0300
+++ b/draw_outputs.pde	Wed Sep 05 20:28:23 2018 +0300
@@ -8,17 +8,17 @@
 
 int chop2(int v)
 {
-  return int(v / 2) * 2;
+    return int(v / 2) * 2;
 }
 
 int chop8(int v)
 {
-  return int(v / 8) * 8;
+    return int(v / 8) * 8;
 }
 
 int chopv(int v, int qv)
 {
-  return int(v / qv) * qv;
+    return int(v / qv) * qv;
 }
 
 
@@ -44,9 +44,12 @@
     //circle for brush drawing
     float prop, fh = hh, fv = vv;
 
-    if (vv > 0) {
+    if (vv > 0)
+    {
         prop = fh / fv;
-    } else {
+    }
+    else
+    {
         prop = 1;
     }
     hh++;
@@ -69,36 +72,44 @@
     ofx = x;
     ofy = y;
     mb = g_button;
-    if (g_btype == 1) {
-        if (g_bsize < 4) {
+    if (g_btype == 1)
+    {
+        if (g_bsize < 4)
+        {
             //some hardcoded brushes
-            switch (g_bsize) {
+            switch (g_bsize)
+            {
                 case 0:
                     doborx(ofx, ofy, ofx + 1, ofy + 1);
                     break;
                 case 1:
-                    if (g_data[int('c')] == 1 || g_shift == true) {
+                    if (g_data[int('c')] == 1 || g_shift == true)
+                    {
                         ofx = ofx + 1;
                         ofy = ofy + 1;
                     }
                     doborx(ofx - 1, ofy - 1, ofx + 1, ofy + 1);
                     break;
                 case 2:
-                    if (g_data[int('c')] == 1 || g_shift == true) {
+                    if (g_data[int('c')] == 1 || g_shift == true)
+                    {
                         ofx = ofx + 2;
                         ofy = ofy + 2;
                     }
                     doborx(ofx - 2, ofy - 2, ofx + 1, ofy + 1);
                     break;
                 case 3:
-                    if (g_data[int('c')] == 1 || g_shift == true) {
+                    if (g_data[int('c')] == 1 || g_shift == true)
+                    {
                         ofx = ofx + 3;
                         ofy = ofy + 3;
                     }
                     doborx(ofx - 3, ofy - 3, ofx + 4, ofy + 4);
                     break;
             }
-        } else { //larger size brushes
+        }
+        else
+        { //larger size brushes
             calc = g_bsize - 3;
             calc = calc * calc;
             calc = calc + 4;
@@ -107,7 +118,8 @@
         return;
     }
 
-    if (g_btype == 9) { //bitmap brush
+    if (g_btype == 9)
+    { //bitmap brush
         passes = 2;
         int tempox, tempoy, tempx, tempy, moloy;
         moloy = 1;
@@ -115,36 +127,45 @@
         tempoy = g_bsourcey;
         tempx = g_bsourcex2;
         tempy = g_bsourcey2;
-        if (g_data[int('t')] == 1) {
+        if (g_data[int('t')] == 1)
+        {
             if (tempx > g_bsourcex + 16) tempx = g_bsourcex + 16;
             if (tempy > g_bsourcey + 16) tempy = g_bsourcey + 16;
         }
         midx = int((g_bsourcex2 - g_bsourcex) / 2);
         midy = int((g_bsourcey2 - g_bsourcey) / 2);
-        if (g_data[int('c')] == 1 || g_shift == true) {
-            if (g_data[int('q')] == 1) {
+        if (g_data[int('c')] == 1 || g_shift == true)
+        {
+            if (g_data[int('q')] == 1)
+            {
                 // XXX is this g_gridx an error?
                 midy = chopv(midy, g_gridx);
                 midx = chopv(midx, g_gridx);
             }
         }
         int orient = g_data[int('x')] * 100 + g_data[int('y')] * 10 + g_data[int('q')];
-        if (g_pixelw == 2) {
+        if (g_pixelw == 2)
+        {
             x = chop2(x);
             passes = 1;
         }
 
-        for (int pp = 1; pp <= passes; pp++) {
-            for (int yy = tempoy; yy <= tempy; yy = yy + moloy) {
-                for (int xx = tempox; xx <= tempx; xx = xx + g_pixelw) {
+        for (int pp = 1; pp <= passes; pp++)
+        {
+            for (int yy = tempoy; yy <= tempy; yy = yy + moloy)
+            {
+                for (int xx = tempox; xx <= tempx; xx = xx + g_pixelw)
+                {
                     s1 = int(g_brush[1024 + xx + yy * X]);
                     if (g_multic == 0) s1 = getabsa(xx, yy, 1);
                     if (g_multic > 0) s1 = getmultibrush(xx, yy);
-                    if (s1 != g_backg) {
+                    if (s1 != g_backg)
+                    {
                         x0 = x + xx - g_bsourcex;
                         y0 = y + yy - g_bsourcey;
 
-                        if (g_data[int('q')] == 1) {
+                        if (g_data[int('q')] == 1)
+                        {
                             x0 = x - (yy - g_bsourcey2);
                             y0 = y + (xx - g_bsourcex);
                             x0 = x0 + midx;
@@ -153,67 +174,89 @@
                             y0 = y0 - midx;
                         }
 
-                        if (g_data[int('x')] == 1) {
+                        if (g_data[int('x')] == 1)
+                        {
                             x0 = x0 - (x + midx);
                             x0 = -x0;
                             x0 = x0 + (x + midx);
                         }
 
-                        if (g_data[int('y')] == 1) {
+                        if (g_data[int('y')] == 1)
+                        {
                             y0 = y0 - (y + midy);
                             y0 = -y0;
                             y0 = y0 + (y + midy);
                         }
 
-                        if (g_data[int('c')] == 1 || g_shift) {
+                        if (g_data[int('c')] == 1 || g_shift)
+                        {
                             if (orient == 10) y0 = y0 + 1;
                             if (orient == 11) y0 = y0 + g_gridy - g_pixelw;
                             if (orient == 100) x0 = x0 + 1;
                             if (orient == 101) x0 = x0 + g_gridx - 1;
-                            if (orient == 110) {
+                            if (orient == 110)
+                            {
                                 x0 = x0 + 1;
                                 y0 = y0 + 1;
                             }
-                            if (orient == 111) {
+                            if (orient == 111)
+                            {
                                 x0 = x0 + g_gridx - 1;
                                 y0 = y0 + g_gridy - g_pixelw;
                             }
                         }
 
-                        if (mb == LEFT) {
-                            if (g_multic > 0) {
+                        if (mb == LEFT)
+                        {
+                            if (g_multic > 0)
+                            {
                                 g_farge = s1;
                                 if (g_data[int('p')] == 1) g_farge = g_ofarge;
-                                if (g_pixelw == 2) {
+                                if (g_pixelw == 2)
+                                {
                                     if (g_data[int('q')] == 0) makepoint(x0, y0);
-                                    if (g_data[int('q')] == 1) {
+                                    if (g_data[int('q')] == 1)
+                                    {
                                         makepoint(x0 - x + x0, y + (y0 - y));
                                         makepoint(x0 - x + x0, y + (y0 - y) + 1);
                                     }
-                                } else {
+                                }
+                                else
+                                {
                                     makepoint(x0, y0);
                                 }
-                            } else {
+                            }
+                            else
+                            {
                                 g_farge = s1;
-                                if (zxcolor(g_farge) != zxcolor(g_backg)) {
+                                if (zxcolor(g_farge) != zxcolor(g_backg))
+                                {
                                     if (g_data[int('p')] == 1) g_farge = g_ofarge;
                                     makepoint(x0, y0);
                                 }
                             }
                         }
 
-                        if (mb == RIGHT) {
-                            if (g_multic > 0) {
-                                if (g_pixelw == 2) {
+                        if (mb == RIGHT)
+                        {
+                            if (g_multic > 0)
+                            {
+                                if (g_pixelw == 2)
+                                {
                                     if (g_data[int('q')] == 0) clearpoint(x0, y0);
-                                    if (g_data[int('q')] == 1) {
+                                    if (g_data[int('q')] == 1)
+                                    {
                                         clearpoint(x0 - x + x0, y + (y0 - y));
                                         clearpoint(x0 - x + x0, y + (y0 - y) + 1);
                                     }
-                                } else {
+                                }
+                                else
+                                {
                                     clearpoint(x0, y0);
                                 }
-                            } else {
+                            }
+                            else
+                            {
                                 clearpoint(x0, y0);
                             }
                         }
@@ -225,8 +268,10 @@
         return;
     }
 
-    if (g_bsize < 4) {
-        switch (g_bsize) {
+    if (g_bsize < 4)
+    {
+        switch (g_bsize)
+        {
             case 0:
                 createpoint(x, y, g_button);
                 break;
@@ -247,7 +292,9 @@
                 doborx(x - 2, y - 2, x + 2, y + 2);
                 break;
         }
-    } else {
+    }
+    else
+    {
         calc = g_bsize - 3;
         calc = calc * calc;
         calc = calc + 4;
@@ -262,7 +309,8 @@
     int swap, pex, pey;
     boolean steep;
     //multicolor 160 pixel reso
-    if (g_pixelw == 2) {
+    if (g_pixelw == 2)
+    {
         xfrom = chop2(xfrom);
         xto = chop2(xto);
     }
@@ -273,7 +321,8 @@
 
     if (prevent == 0) craft(xto, yto, 0);
 
-    if (g_pixelw == 2) {
+    if (g_pixelw == 2)
+    {
         xfrom = int(xfrom / 2);
         xto = int(xto / 2);
     }
@@ -285,7 +334,8 @@
 
     steep = abs(y1 - y0) > abs(x1 - x0);
 
-    if (steep) {
+    if (steep)
+    {
         swap = x0;
         x0 = y0;
         y0 = swap;
@@ -304,27 +354,39 @@
     int y = y0;
     int inc;
 
-    if (x0 < x1) {
+    if (x0 < x1)
+    {
         inc = 1;
-    } else {
+    }
+    else
+    {
         inc = -1;
     }
-    if (y0 < y1) {
+    if (y0 < y1)
+    {
         ystep = 1;
-    } else {
+    }
+    else
+    {
         ystep = -1;
     }
     int x;
     x = x0;
-    while (x != x1) {
-        if (steep) {
-            if (y * g_pixelw != pex || x != pey) {
+    while (x != x1)
+    {
+        if (steep)
+        {
+            if (y * g_pixelw != pex || x != pey)
+            {
                 craft(y * g_pixelw, x, 0);
                 pex = y * g_pixelw;
                 pey = x;
             }
-        } else {
-            if (x * g_pixelw != pex || y != pey) {
+        }
+        else
+        {
+            if (x * g_pixelw != pex || y != pey)
+            {
                 craft(x * g_pixelw, y, 0);
                 pex = x * g_pixelw;
                 pey = y;
@@ -332,7 +394,8 @@
         }
 
         error = error - deltay;
-        if (error < 0) {
+        if (error < 0)
+        {
             y = y + ystep;
             error = error + deltax;
         }
@@ -356,9 +419,12 @@
     vv = y2 - y1;
     fh = hh;
     fv = vv;
-    if (vv > 0) {
+    if (vv > 0)
+    {
         prop = fh / fv;
-    } else {
+    }
+    else
+    {
         prop = 1;
     }
     hh++;
@@ -388,8 +454,10 @@
     if (g_data[int('t')] == 1 && x2 > x1 + 15) x2 = x1 + 16;
     if (g_data[int('t')] == 1 && y2 > y1 + 15) y2 = y1 + 16;
 
-    if (g_data[int('f')] == 1 && g_btype != 9) {
-        if (g_multic == 1 && g_data[int('d')] == 0) {
+    if (g_data[int('f')] == 1 && g_btype != 9)
+    {
+        if (g_multic == 1 && g_data[int('d')] == 0)
+        {
             g_farge = g_map[1];
             docircx(x1, y1, abs(x2 - int(x1)), abs(y2 - int(y1)));
             g_farge = g_ofarge;
@@ -399,7 +467,8 @@
 
     prex = 0;
     prey = 0;
-    for (t = 0; t <= (gear2); t++) {
+    for (t = 0; t <= (gear2); t++)
+    {
         a = t / (gear1) * PI;
         sx = (x2 - x1) * sin(a);
         sy = (y1 - y2) * cos(a);
@@ -423,12 +492,14 @@
     yt = yt + 7;
     xt = xt + 6;
 
-    if (x2 < x1) {
+    if (x2 < x1)
+    {
         x0 = x2;
         x2 = x1;
         x1 = x0;
     }
-    if (y2 < y1) {
+    if (y2 < y1)
+    {
         y0 = y2;
         y2 = y1;
         y1 = y0;
@@ -437,19 +508,26 @@
     if (g_data[int('t')] == 1 && x2 > x1 + 15) x2 = x1 + 16;
     if (g_data[int('t')] == 1 && y2 > y1 + 15) y2 = y1 + 16;
 
-    if (g_btype != 9) {
-        if (g_data[int('c')] == 1 || g_shift) {
+    if (g_btype != 9)
+    {
+        if (g_data[int('c')] == 1 || g_shift)
+        {
             if (x2 > x1) x2--;
             if (y2 > y1) y2--;
         }
     }
 
-    if (g_data[int('f')] == 1 && g_btype != 9) {
-        if (g_multic == 1 && g_data[int('d')] == 0) {
+    if (g_data[int('f')] == 1 && g_btype != 9)
+    {
+        if (g_multic == 1 && g_data[int('d')] == 0)
+        {
             g_farge = g_map[1];
-            for (int y = y1; y <= y2; y++) {
-                for (int x = x1; x <= x2; x = x + g_pixelw) {
-                    if (x >= xf && y >= yf && x <= xt && y <= yt) {
+            for (int y = y1; y <= y2; y++)
+            {
+                for (int x = x1; x <= x2; x = x + g_pixelw)
+                {
+                    if (x >= xf && y >= yf && x <= xt && y <= yt)
+                    {
                         makepoint(x, y);
                     }
                 }
@@ -457,21 +535,27 @@
         }
         g_farge = g_ofarge;
         if (g_button == RIGHT) g_farge = g_backg;
-        for (int y = y1; y <= y2; y++) {
-            for (int x = x1; x <= x2; x = x + g_pixelw) {
+        for (int y = y1; y <= y2; y++)
+        {
+            for (int x = x1; x <= x2; x = x + g_pixelw)
+            {
                 makepoint(x, y);
             }
         }
     }
-    if (g_data[int('f')] == 0 || g_btype == 9) {
-        if (g_data[int('c')] == 1 && g_btype == 1) {
-            if (x2 > x1) {
+    if (g_data[int('f')] == 0 || g_btype == 9)
+    {
+        if (g_data[int('c')] == 1 && g_btype == 1)
+        {
+            if (x2 > x1)
+            {
                 if (g_bsize == 0) x2--;
                 if (g_bsize == 1) x2 = x2 - 2;
                 if (g_bsize == 2) x2 = x2 - 3;
                 if (g_bsize == 3) x2++;
             }
-            if (y2 > y1) {
+            if (y2 > y1)
+            {
                 if (g_bsize == 0) y2--;
                 if (g_bsize == 1) y2 = y2 - 2;
                 if (g_bsize == 2) y2 = y2 - 3;
@@ -501,18 +585,21 @@
 
     //for the X/Y mirrors & tiler, the function calls itself with x+10000 or y+10000
     //resolved here
-    if (xx >= 20000) {
+    if (xx >= 20000)
+    {
         xx = xx - 20000;
         mirrix = 0;
         mirriy = 0;
         tiler = 1;
     }
-    if (xx >= 10000) {
+    if (xx >= 10000)
+    {
         xx = xx - 10000;
         mirrix = 1;
         mirriy = 1;
     }
-    if (yy >= 10000) {
+    if (yy >= 10000)
+    {
         yy = yy - 10000;
         mirriy = 1;
         mirrix = 1;
@@ -544,16 +631,20 @@
         }
     }
 
-    if (g_pixelw == 2) {
+    if (g_pixelw == 2)
+    {
         xx = chop2(xx);
     }
 
-    if (g_data[int('r')] == 1) { //simple raster
+    if (g_data[int('r')] == 1)
+    { //simple raster
         if (get_raster(xx, yy) == 0) ignore = 1;
     }
 
-    if (g_data[int('R')] == 1) { //user defined raster
-        if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey) {
+    if (g_data[int('R')] == 1)
+    { //user defined raster
+        if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey)
+        {
 
             int x0 = int(xx / ((g_bsourcex2 + 1) - g_bsourcex));
             int y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey));
@@ -561,7 +652,8 @@
             int y1 = yy - y0 * ((g_bsourcey2 + 1) - g_bsourcey);
             int xr = g_bsourcex + x1;
             int yr = g_bsourcey + y1;
-            if (g_pixelw == 2) {
+            if (g_pixelw == 2)
+            {
                 x0 = int(xx / ((g_bsourcex2 + 2) - g_bsourcex));
                 y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey));
                 x1 = xx - x0 * ((g_bsourcex2 + 2) - g_bsourcex);
@@ -571,7 +663,9 @@
                 xr = chop2(xr);
                 yr = g_bsourcey + y1;
                 if (getmultic(xr, yr, 1) == g_backg) ignore = 1;
-            } else {
+            }
+            else
+            {
                 if (getabsa(xr, yr, 1) == g_backg) ignore = 1;
             }
             //    if(g_brush[1024+xr+yr*X]==0){ignore=1;}
@@ -580,17 +674,20 @@
 
     int xc, yc;
 
-    if (ignore == 0 && g_data[int('d')] == 1 && g_attrimode <= 1) {
+    if (ignore == 0 && g_data[int('d')] == 1 && g_attrimode <= 1)
+    {
         int aba, baba, ii, jj, miny, maxy, ojox, ojoy;
         aba = getattra(xx, yy, 0);
         baba = getattra(xx, yy, 1);
-        if (g_multic == 0) {
+        if (g_multic == 0)
+        {
             ojox = chop8(xx);
             ojoy = chop8(yy);
             miny = yy - ojoy;
             maxy = miny;
 
-            if (g_attrimode == 1) {
+            if (g_attrimode == 1)
+            {
                 miny = 0;
                 maxy = 7;
             }
@@ -598,17 +695,25 @@
             if (baba == g_backg) simplepaint(xx, yy, 1, g_farge);
             if (aba == g_backg) simplepaint(xx, yy, 0, g_farge);
             ignore = 1;
-            if (g_farge == baba && g_farge == aba) {
-                for (jj = miny; jj <= maxy; jj++) {
-                    for (ii = 0; ii < 8; ii++) {
+            if (g_farge == baba && g_farge == aba)
+            {
+                for (jj = miny; jj <= maxy; jj++)
+                {
+                    for (ii = 0; ii < 8; ii++)
+                    {
                         g_map[1024 + ojox + ojoy * X + ii + jj * X] = 0;
                     }
                 }
             }
-        } else {
-            if (aba == g_backg) {
+        }
+        else
+        {
+            if (aba == g_backg)
+            {
                 ignore = 0;
-            } else {
+            }
+            else
+            {
                 ignore = 1;
             }
         }
@@ -618,24 +723,32 @@
         g_remdo[xc + yc * MX] = byte(1); //block update
     }
 
-    if (ignore == 0) {
+    if (ignore == 0)
+    {
         xc = int(xx / 8);
         yc = int(yy / 8);
         g_redo[xc + yc * MX] = byte(0); //block update
         g_remdo[xc + yc * MX] = byte(1); //block update
 
-        switch (g_multic) {
+        switch (g_multic)
+        {
             case 0: //1-bit + attribute i.e. spectrum
                 fari = g_farge;
                 if (g_machine == MSX && fari == int(g_map[1])) fari = 0;
                 if (g_britemode == 1 && fari == 8) fari = 0;
 
-                if (getattra(xx, yy, 1) == 0 && fari == g_map[1]) {
+                if (getattra(xx, yy, 1) == 0 && fari == g_map[1])
+                {
                     g_map[1024 + xx + yy * X] = byte(0);
-                } else {
-                    if (getattra(xx, yy, 1) == fari) {
+                }
+                else
+                {
+                    if (getattra(xx, yy, 1) == fari)
+                    {
                         g_map[1024 + xx + yy * X] = byte(0);
-                    } else {
+                    }
+                    else
+                    {
                         int ojox = chop8(xx);
                         int ojoy = chop8(yy);
                         int mac, macpre, maxos;
@@ -645,32 +758,42 @@
                         miny = 0;
                         maxy = 7;
                         maxos = 64;
-                        if (g_attrimode == 0) {
+                        if (g_attrimode == 0)
+                        {
                             miny = (yy - ojoy);
                             maxy = miny;
                             maxos = 8;
                         } //MSX
-                        for (int j = miny; j <= maxy; j++) {
-                            for (int i = 0; i < 8; i++) {
+                        for (int j = miny; j <= maxy; j++)
+                        {
+                            for (int i = 0; i < 8; i++)
+                            {
                                 if (g_map[1024 + ojox + ojoy * X + j * X] == 1) macpre++;
                             }
                         }
                         g_map[1024 + xx + yy * X] = byte(1);
-                        for (int j = miny; j <= maxy; j++) {
-                            for (int i = 0; i < 8; i++) {
+                        for (int j = miny; j <= maxy; j++)
+                        {
+                            for (int i = 0; i < 8; i++)
+                            {
                                 if (g_map[1024 + ojox + ojoy * X + i + j * X] == 1) mac++;
                             }
                         }
-                        if (mac == maxos) {
-                            for (int j = miny; j <= maxy; j++) {
+                        if (mac == maxos)
+                        {
+                            for (int j = miny; j <= maxy; j++)
+                            {
                                 int vad = 1024 + ojox + (ojoy + j) * X;
-                                for (int i = 0; i < 8; i++) {
+                                for (int i = 0; i < 8; i++)
+                                {
                                     g_map[vad] = 0;
                                     vad++;
                                 }
                             }
                             simplepaint(xx, yy, 1, fari);
-                        } else {
+                        }
+                        else
+                        {
                             simplepaint(xx, yy, 0, fari);
                         }
                     }
@@ -686,24 +809,31 @@
                 int zeroc = int(g_map[1]);
                 int zeroc2 = int(g_map[2]);
                 boolean cut = false;
-                if (fari == zeroc) { //shortcut
+                if (fari == zeroc)
+                { //shortcut
                     g_map[1024 + xx + yy * X] = byte(0);
                     g_map[1024 + xx + yy * X + 1] = byte(0);
                     cut = true;
                 }
-                if (g_machine == PLUS4M && fari == zeroc2) { //shortcut
+                if (g_machine == PLUS4M && fari == zeroc2)
+                { //shortcut
                     g_map[1024 + xx + yy * X] = byte(1);
                     g_map[1024 + xx + yy * X + 1] = byte(1);
                     cut = true;
                 }
-                if (cut) {
+                if (cut)
+                {
                     // X Y mirrors
-                    if (g_data[int('t')] == 1) {
-                        if (tiler == 0) {
+                    if (g_data[int('t')] == 1)
+                    {
+                        if (tiler == 0)
+                        {
                             int ex = int(X / g_gridx);
                             int ey = int(Y / g_gridy);
-                            for (int tilx = -ex; tilx <= ex; tilx++) {
-                                for (int tily = -ey; tily <= ey; tily++) {
+                            for (int tilx = -ex; tilx <= ex; tilx++)
+                            {
+                                for (int tily = -ey; tily <= ey; tily++)
+                                {
                                     makepoint(20000 + xx + int(X / ex) * tilx, yy + int(Y / ey) * tily);
                                 }
                             }
@@ -712,8 +842,10 @@
                     }
                     if (g_data[int('X')] == 1 && mirrix == 0) makepoint(10000 + (X - 1) - xx, yy);
                     if (g_data[int('Y')] == 1 && mirriy == 0) makepoint(xx, 10000 + (Y - 1) - yy);
-                    if (g_data[int('X')] == 1 && g_data[int('Y')] == 1) {
-                        if (mirrix == 0) {
+                    if (g_data[int('X')] == 1 && g_data[int('Y')] == 1)
+                    {
+                        if (mirrix == 0)
+                        {
                             makepoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy);
                         }
                     }
@@ -735,14 +867,17 @@
                 mey = int(mey * 8);
                 int saps = 1024 + mex + mey * X;
 
-                for (metay = 0; metay <= 7; metay++) {
-                    for (metax = 0; metax <= 3; metax++) {
+                for (metay = 0; metay <= 7; metay++)
+                {
+                    for (metax = 0; metax <= 3; metax++)
+                    {
                         int pars = g_map[saps] + g_map[saps + 1] * 2;
                         uses[pars] = 1;
                         if (pars == 0) fars[0] = zeroc;
                         if (pars == 1) fars[1] = int(g_map[looks]);
                         if (pars == 2) fars[2] = int(g_map[looks + 1000]);
-                        if (pars == 3) {
+                        if (pars == 3)
+                        {
                             if (g_machine == C64M) fars[3] = int(g_map[looks + 2000]);
                             if (g_machine == PLUS4M) fars[3] = zeroc2;
                         }
@@ -756,31 +891,39 @@
                 skippo = 0;
 
                 // mega-escape, if it's not possible to draw at all don't bother
-                if (uses[0] == 1 && uses[1] == 1 && uses[2] == 1 && uses[3] == 1) {
+                if (uses[0] == 1 && uses[1] == 1 && uses[2] == 1 && uses[3] == 1)
+                {
                     if (fari != fars[0] && fari != fars[1] && fari != fars[2] && fari != fars[3]) skippo = 100;
                 }
 
-                if (skippo == 0) {
+                if (skippo == 0)
+                {
                     int okay = 0;
                     metamax = 3;
                     if (g_machine == PLUS4M) metamax = 2;
 
                     // if the color is already in the 4x8 area?
 
-                    for (metay = 0; metay <= metamax; metay++) {
-                        if (uses[metay] == 1) {
-                            if (fars[metay] == fari) {
-                                if (metay == 1) {
+                    for (metay = 0; metay <= metamax; metay++)
+                    {
+                        if (uses[metay] == 1)
+                        {
+                            if (fars[metay] == fari)
+                            {
+                                if (metay == 1)
+                                {
                                     bit1 = 1;
                                     bit2 = 0;
                                     g_map[looks] = byte(fari);
                                 }
-                                if (metay == 2) {
+                                if (metay == 2)
+                                {
                                     bit1 = 0;
                                     bit2 = 1;
                                     g_map[looks + 1000] = byte(fari);
                                 }
-                                if (metay == 3) {
+                                if (metay == 3)
+                                {
                                     bit1 = 1;
                                     bit2 = 1;
                                     if (g_machine == C64M) g_map[looks + 2000] = byte(fari);
@@ -795,23 +938,29 @@
 
                     //if the color is not in the 4x8 area
 
-                    if (okay == 0) {
-                        for (metay = 1; metay <= metamax; metay++) {
-                            if (uses[metay] == 0) {
+                    if (okay == 0)
+                    {
+                        for (metay = 1; metay <= metamax; metay++)
+                        {
+                            if (uses[metay] == 0)
+                            {
                                 uses[metay] = 1;
-                                if (metay == 1) {
+                                if (metay == 1)
+                                {
                                     bit1 = 1;
                                     bit2 = 0;
                                     g_map[looks] = byte(fari);
                                     uses[2] = 1;
                                 }
-                                if (metay == 2) {
+                                if (metay == 2)
+                                {
                                     bit1 = 0;
                                     bit2 = 1;
                                     g_map[looks + 1000] = byte(fari);
                                     uses[3] = 1;
                                 }
-                                if (metay == 3) {
+                                if (metay == 3)
+                                {
                                     bit1 = 1;
                                     bit2 = 1;
                                     if (g_machine == C64M) g_map[looks + 2000] = byte(fari);
@@ -830,12 +979,16 @@
             case 2: // VGA style i.e. Amiga, CPC
                 fari = g_farge;
 
-                if (g_data[int('d')] == 1) {
-                    if (g_map[1024 + xx + yy * X] == byte(g_backg)) {
+                if (g_data[int('d')] == 1)
+                {
+                    if (g_map[1024 + xx + yy * X] == byte(g_backg))
+                    {
                         g_map[1024 + xx + yy * X] = byte(g_farge);
                         if (g_hzoomer == 2) g_map[1024 + xx + yy * X + 1] = byte(g_farge);
                     }
-                } else {
+                }
+                else
+                {
                     g_map[1024 + xx + yy * X] = byte(g_farge);
                     if (g_hzoomer == 2) g_map[1024 + xx + yy * X + 1] = byte(g_farge);
                 }
@@ -847,12 +1000,16 @@
 
     // X Y mirrors & tiler
 
-    if (g_data[int('t')] == 1) {
-        if (tiler == 0) {
+    if (g_data[int('t')] == 1)
+    {
+        if (tiler == 0)
+        {
             int ex = int(X / g_gridx);
             int ey = int(Y / g_gridy);
-            for (int tilx = -(ex); tilx <= ex; tilx++) {
-                for (int tily = -(ey); tily <= ey; tily++) {
+            for (int tilx = -(ex); tilx <= ex; tilx++)
+            {
+                for (int tily = -(ey); tily <= ey; tily++)
+                {
                     makepoint(20000 + xx + int(X / ex) * tilx, yy + int(Y / ey) * tily);
                 }
             }
@@ -861,8 +1018,10 @@
     }
     if (g_data[int('X')] == 1 && mirrix == 0) makepoint(10000 + (X - 1) - xx, yy);
     if (g_data[int('Y')] == 1 && mirriy == 0) makepoint(xx, 10000 + (Y - 1) - yy);
-    if (g_data[int('X')] == 1 && g_data[int('Y')] == 1) {
-        if (mirrix == 0) {
+    if (g_data[int('X')] == 1 && g_data[int('Y')] == 1)
+    {
+        if (mirrix == 0)
+        {
             makepoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy);
         }
     }
@@ -870,13 +1029,15 @@
 
 void clearpoint(int xx, int yy)
 {
-    if (g_multic == 2) {
+    if (g_multic == 2)
+    {
         g_farge = g_backg;
         makepoint(xx, yy);
         g_farge = g_ofarge;
         return;
     }
-    if (g_multic == 1) {
+    if (g_multic == 1)
+    {
         xx = chop2(xx);
     }
     g_farge = g_backg;
@@ -890,12 +1051,14 @@
     int mirrix = 0;
     int mirriy = 0;
     int ignore = 0;
-    if (xx >= 10000) {
+    if (xx >= 10000)
+    {
         xx = xx - 10000;
         mirrix = 1;
         mirriy = 1;
     }
-    if (yy >= 10000) {
+    if (yy >= 10000)
+    {
         yy = yy - 10000;
         mirriy = 1;
         mirrix = 1;
@@ -904,23 +1067,28 @@
     if (xx < 0 || yy < 0 || xx >= X || yy >= Y)
         return;
 
-    if (g_multic == 2 && g_hzoomer != 2) {
+    if (g_multic == 2 && g_hzoomer != 2)
+    {
         g_farge = g_backg;
         makepoint(xx, yy);
         g_farge = g_ofarge;
         return;
     }
-    if (g_pixelw == 2) {
+    if (g_pixelw == 2)
+    {
         xx = chop2(xx);
     }
     if (g_data[int('b')] == 1) return;
 
-    if (g_data[int('r')] == 1) { //raster
+    if (g_data[int('r')] == 1)
+    { //raster
         if (get_raster(xx, yy) == 0) ignore = 1;
     }
 
-    if (g_data[int('R')] == 1) { //user defined raster
-        if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey) {
+    if (g_data[int('R')] == 1)
+    { //user defined raster
+        if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey)
+        {
             int x0 = int(xx / ((g_bsourcex2 + 1) - g_bsourcex));
             int y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey));
             int x1 = xx - x0 * ((g_bsourcex2 + 1) - g_bsourcex);
@@ -931,7 +1099,8 @@
         }
     }
 
-    if (ignore == 0) {
+    if (ignore == 0)
+    {
         g_map[1024 + xx + yy * X] = byte(0);
         if (g_pixelw == 2) g_map[1024 + xx + yy * X + 1] = byte(0);
         int xc = int(xx / 8);
@@ -942,7 +1111,8 @@
 
     if (g_data[int('X')] == 1 && mirrix == 0) clearpoint(10000 + (X - 1) - xx, yy);
     if (g_data[int('Y')] == 1 && mirriy == 0) clearpoint(xx, 10000 + (Y - 1) - yy);
-    if (g_data[int('X')] == 1 && g_data[int('Y')] == 1) {
+    if (g_data[int('X')] == 1 && g_data[int('Y')] == 1)
+    {
         if (mirrix == 0) clearpoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy);
     }
 }
@@ -967,17 +1137,21 @@
 
     for (int j = miny; j <= maxy; j++)
     {
-        if (mode == 0) {
+        if (mode == 0)
+        {
             ad = 65536 + xx + (ojyx + j) * MX;
             swad = 65536 + xx + (ojyx + j) * MX + (MX * MY) * 8;
         }
-        if (mode == 1) {
+        if (mode == 1)
+        {
             ad = 65536 + xx + (ojyx + j) * MX + (MX * MY) * 8;
             swad = 65536 + xx + (ojyx + j) * MX;
         }
-        if (g_britemode == 1) {
+        if (g_britemode == 1)
+        {
             if (attr == 8) attr = 0;
-            if (attr > 0) {
+            if (attr > 0)
+            {
                 if (attr >= 8 && g_map[swad] <= 7) g_map[swad] = byte(g_map[swad] + 8);
                 if (attr <= 7 && g_map[swad] >= 8) g_map[swad] = byte(g_map[swad] - 8);
             }
@@ -1061,16 +1235,20 @@
         return;
     }
     else
-    if (mbut == 255) { // color picker
-        if (g_multic == 2) {
-            if (g_hzoomer == 2) {
+    if (mbut == 255)
+    { // color picker
+        if (g_multic == 2)
+        {
+            if (g_hzoomer == 2)
+            {
                 ox = chop2(ox);
             }
             selectcolor(0, getmultic(ox, oy, 0));
             return;
         }
         selectcolor(0, getabsa(ox, oy, 0));
-        if (g_pixelw == 2) {
+        if (g_pixelw == 2)
+        {
             ox = chop2(ox);
             selectcolor(0, getattra(ox, oy, 0));
         }
@@ -1100,9 +1278,12 @@
         {
             int rx = x - 10 + int(random((10) * 2));
             int ry = y - 10 + int(random((10) * 2));
-            if (mbut == LEFT) {
+            if (mbut == LEFT)
+            {
                 if (dist(x, y, rx, ry) < 10) craft(rx, ry, 0);
-            } else {
+            }
+            else
+            {
                 if (dist(x, y, rx, ry) < 10) craft(rx, ry, 0);
             }
         }
@@ -1198,7 +1379,8 @@
     if (tt == 4)
     {
         //brush grabber grab brush
-        if (g_phase == 0) {
+        if (g_phase == 0)
+        {
             g_rx = x;
             g_orx = x;
             g_ry = y;
@@ -1207,20 +1389,24 @@
             g_ry2 = y;
         }
         else
-        if (g_phase == 1) {
+        if (g_phase == 1)
+        {
             g_rx2 = x;
             g_rx = g_orx;
             g_ry2 = y;
             g_ry = g_ory;
-            if (x < g_orx) {
+            if (x < g_orx)
+            {
                 g_rx2 = g_orx;
                 g_rx = x;
             }
-            if (y < g_ory) {
+            if (y < g_ory)
+            {
                 g_ry2 = g_ory;
                 g_ry = y;
             }
-            if (g_data[int('c')] == 1 || g_shift) {
+            if (g_data[int('c')] == 1 || g_shift)
+            {
                 g_rx2--;
                 g_ry2--;
                 if (g_pixelw == 2) g_rx2--;
@@ -1231,12 +1417,15 @@
 
     if (tt == 0 || tt == 4)
     {
-        if (g_rubbermode == 1) {
-            for (int xx = g_rx; xx <= g_rx2 + 2; xx++) {
+        if (g_rubbermode == 1)
+        {
+            for (int xx = g_rx; xx <= g_rx2 + 2; xx++)
+            {
                 updatepoint(xx, g_ry);
                 updatepoint(xx, g_ry2);
             }
-            for (int yy = g_ry; yy <= g_ry2; yy++) {
+            for (int yy = g_ry; yy <= g_ry2; yy++)
+            {
                 updatepoint(g_rx, yy);
                 updatepoint(g_rx2, yy);
             }
--- a/draw_smart.pde	Wed Sep 05 20:08:57 2018 +0300
+++ b/draw_smart.pde	Wed Sep 05 20:28:23 2018 +0300
@@ -9,7 +9,8 @@
     if (g_multic == 1 || g_multic == 2)
         return;
 
-    if (g_attrimode == 0) {
+    if (g_attrimode == 0)
+    {
         mat = 8;
         mulu = 1;
         maxxy = Y;
@@ -64,12 +65,14 @@
     yb = 0;
     xx = int(xx / 8);
 
-    if (g_attrimode == 1) {
+    if (g_attrimode == 1)
+    {
         yy = chop8(yy);
         ya = 0;
         yb = 7;
     } //zx spec etc
-    if (g_attrimode == 0) {
+    if (g_attrimode == 0)
+    {
         ya = 0;
         yb = 0;
     } //msx
@@ -309,10 +312,12 @@
 //reasons the background color for each char as you draw
 //=changed
 
-void fixattr(int x, int y, int foreg, int backg) {
+void fixattr(int x, int y, int foreg, int backg)
+{
     int bad, cad, miny, maxy;
 
-    if (g_britemode == 1) {
+    if (g_britemode == 1)
+    {
         if (foreg == 8 || backg == 8 || foreg == 0 || backg == 0) return;
     }
 
@@ -321,20 +326,24 @@
     miny = maxy;
     y = chop8(y);
 
-    if (g_attrimode == 1) {
+    if (g_attrimode == 1)
+    {
         miny = 0;
         maxy = 7;
     }
 
-    for (int i = miny; i <= maxy; i++) {
+    for (int i = miny; i <= maxy; i++)
+    {
         bad = 65536 + int(x / 8) + (y + i) * MX;
         cad = bad + MX * (MY * 8);
-        if (foreg >= 0) {
+        if (foreg >= 0)
+        {
             g_map[bad] = byte(foreg);
             if (foreg >= 8 && g_map[cad] < 8) g_map[cad] = byte(g_map[cad] + 8);
             if (foreg < 8 && g_map[cad] >= 8) g_map[cad] = byte(g_map[cad] - 8);
         }
-        if (backg >= 0) {
+        if (backg >= 0)
+        {
             g_map[cad] = byte(backg);
             if (backg >= 8 && g_map[bad] < 8) g_map[bad] = byte(g_map[bad] + 8);
             if (backg < 8 && g_map[bad] >= 8) g_map[bad] = byte(g_map[bad] - 8);
@@ -349,16 +358,20 @@
 //or if forcecolor is pressed.
 //bit different for C64 and PLUS4M
 
-void skaveri(int x, int y, int foreg, int backg) {
+void skaveri(int x, int y, int foreg, int backg)
+{
     int mx = int(x / 8);
     int my = int(y / 8);
     if (g_control == false) return;
     int cc = easygetcolor(x, y);
     mx = mx * 8;
     my = my * 8;
-    for (int xx = 0; xx <= 7; xx++) {
-        for (int yy = 0; yy <= 7; yy++) {
-            if (easygetcolor(mx + xx, my + yy) == cc) {
+    for (int xx = 0; xx <= 7; xx++)
+    {
+        for (int yy = 0; yy <= 7; yy++)
+        {
+            if (easygetcolor(mx + xx, my + yy) == cc)
+            {
                 g_map[1024 + mx + xx + (my + yy) * X] = byte(foreg);
             }
         }
@@ -367,7 +380,8 @@
 }
 
 
-void mkaveri(int x, int y, int foreg, int backg) {
+void mkaveri(int x, int y, int foreg, int backg)
+{
     int mx = int(x / 8);
     int my = int(y / 8);
     int ad, bad, cad, dad, b0, b1;
@@ -395,7 +409,8 @@
     free2 = 1;
     f3 = int(g_map[cad + 2000]);
     free3 = 1;
-    if (g_machine == PLUS4M) {
+    if (g_machine == PLUS4M)
+    {
         free3 = 0;
         suffocatelimit = 3;
         f3 = int(g_map[2]);
@@ -403,29 +418,38 @@
 
     if (foreg == g_map[1] && g_control == false) return;
 
-    if (foreg != f1 && foreg != f2 && foreg != f3 || g_control == true) {
-        for (int yy = 0; yy <= 7; yy++) {
-            for (int xx = 0; xx <= 3; xx++) {
+    if (foreg != f1 && foreg != f2 && foreg != f3 || g_control == true)
+    {
+        for (int yy = 0; yy <= 7; yy++)
+        {
+            for (int xx = 0; xx <= 3; xx++)
+            {
                 ad = 1024 + (mx * 8 + xx * 2) + (my * 8 + yy) * X;
-                if (g_map[ad] == 0 && g_map[ad + 1] == 0) { //00 = 00
+                if (g_map[ad] == 0 && g_map[ad + 1] == 0)
+                { //00 = 00
                     if (f0 == f) order = 4;
                 }
-                if (g_map[ad] == 1 && g_map[ad + 1] == 0) { //01 = 10
+                if (g_map[ad] == 1 && g_map[ad + 1] == 0)
+                { //01 = 10
                     numb = numb | 1;
                     free1 = 0;
                     if (f1 == f) order = 1;
                 }
-                if (g_map[ad] == 0 && g_map[ad + 1] == 1) { //02 = 01
+                if (g_map[ad] == 0 && g_map[ad + 1] == 1)
+                { //02 = 01
                     numb = numb | 2;
                     free2 = 0;
                     if (f2 == f) order = 2;
                 }
-                if (g_map[ad] == 1 && g_map[ad + 1] == 1) { //03 = 11
-                    if (g_machine == C64M) {
+                if (g_map[ad] == 1 && g_map[ad + 1] == 1)
+                { //03 = 11
+                    if (g_machine == C64M)
+                    {
                         numb = numb | 4;
                         free3 = 0;
                     }
-                    if (f3 == f) {
+                    if (f3 == f)
+                    {
                         order = 3;
                         targetbit0 = 1;
                         targetbit1 = 1;
@@ -438,52 +462,65 @@
         if (order == 4) zoink = true;
         if (order == 3 && g_machine == PLUS4M) zoink = true;
 
-        if ((zoink || numb != suffocatelimit) && g_control == true) {
-            if (zoink) {
+        if ((zoink || numb != suffocatelimit) && g_control == true)
+        {
+            if (zoink)
+            {
                 //println("foreg:"+foreg+" f0:"+f0+" f1:"+f1+" f2:"+f2+" f3:"+f3+" free1:"+free1+" free2:"+free2+" free3:"+free3);
                 b0 = -1;
                 b1 = -1;
-                if (foreg == f1 && free1 == 0) {
+                if (foreg == f1 && free1 == 0)
+                {
                     b0 = 1;
                     b1 = 0;
                 }
-                if (foreg == f2 && free2 == 0) {
+                if (foreg == f2 && free2 == 0)
+                {
                     b0 = 0;
                     b1 = 1;
                 }
-                if (foreg == f3 && g_machine == C64M && free3 == 0) {
+                if (foreg == f3 && g_machine == C64M && free3 == 0)
+                {
                     b0 = 1;
                     b1 = 1;
                 }
-                if (foreg == f3 && g_machine == PLUS4M) {
+                if (foreg == f3 && g_machine == PLUS4M)
+                {
                     b0 = 1;
                     b1 = 1;
                 }
 
-                if (free1 == 1) {
+                if (free1 == 1)
+                {
                     free2 = 0;
                     free3 = 0;
                     b0 = 1;
                     b1 = 0;
                     g_map[cad] = byte(foreg);
                 }
-                if (free2 == 1) {
+                if (free2 == 1)
+                {
                     free3 = 0;
                     b0 = 0;
                     b1 = 1;
                     g_map[cad + 1000] = byte(foreg);
                 }
-                if (free3 == 1) {
+                if (free3 == 1)
+                {
                     b0 = 1;
                     b1 = 1;
                     g_map[cad + 2000] = byte(foreg);
                 }
 
-                for (int yy = 0; yy <= 7; yy++) {
-                    for (int xx = 0; xx <= 3; xx++) {
+                for (int yy = 0; yy <= 7; yy++)
+                {
+                    for (int xx = 0; xx <= 3; xx++)
+                    {
                         ad = 1024 + (mx * 8 + xx * 2) + (my * 8 + yy) * X;
-                        if (g_map[ad] == targetbit0 && g_map[ad + 1] == targetbit1) {
-                            if (b0 >= 0) {
+                        if (g_map[ad] == targetbit0 && g_map[ad + 1] == targetbit1)
+                        {
+                            if (b0 >= 0)
+                            {
                                 g_map[ad] = byte(b0);
                                 g_map[ad + 1] = byte(b1);
                             }
@@ -495,82 +532,109 @@
 
         //if all color positions are filled, we'll just change the existing one
 
-        if (numb == suffocatelimit || g_control == true) {
-            if (order == 1) {
+        if (numb == suffocatelimit || g_control == true)
+        {
+            if (order == 1)
+            {
                 g_map[cad] = byte(foreg);
             } //10==1
-            if (order == 2) {
+            if (order == 2)
+            {
                 g_map[cad + 1000] = byte(foreg);
             } //01==2
-            if (order == 3 && g_machine == C64M) {
+            if (order == 3 && g_machine == C64M)
+            {
                 g_map[cad + 2000] = byte(foreg);
             } //11==3
         }
 
         //color redundancy check
 
-        for (int yy = 0; yy <= 7; yy++) {
-            for (int xx = 0; xx <= 3; xx++) {
+        for (int yy = 0; yy <= 7; yy++)
+        {
+            for (int xx = 0; xx <= 3; xx++)
+            {
                 ad = 1024 + (mx * 8 + xx * 2) + (my * 8 + yy) * X;
 
-                if (g_machine == C64M) {
-                    if (g_map[cad] == g_map[cad + 2000]) {
-                        if (g_map[ad] == 1 && g_map[ad + 1] == 1) {
+                if (g_machine == C64M)
+                {
+                    if (g_map[cad] == g_map[cad + 2000])
+                    {
+                        if (g_map[ad] == 1 && g_map[ad + 1] == 1)
+                        {
                             g_map[ad] = 1;
                             g_map[ad + 1] = 0;
                         }
                     }
-                    if (g_map[cad + 1000] == g_map[cad + 2000]) {
-                        if (g_map[ad] == 1 && g_map[ad + 1] == 1) {
+                    if (g_map[cad + 1000] == g_map[cad + 2000])
+                    {
+                        if (g_map[ad] == 1 && g_map[ad + 1] == 1)
+                        {
                             g_map[ad] = 0;
                             g_map[ad + 1] = 1;
                         }
                     }
                 }
 
-                if (g_map[cad] == g_map[cad + 1000]) {
-                    if (g_map[ad] == 0 && g_map[ad + 1] == 1) {
+                if (g_map[cad] == g_map[cad + 1000])
+                {
+                    if (g_map[ad] == 0 && g_map[ad + 1] == 1)
+                    {
                         g_map[ad] = 1;
                         g_map[ad + 1] = 0;
                     }
                 }
-                if (g_map[1] == g_map[cad]) {
-                    if (g_map[ad] == 1 && g_map[ad + 1] == 0) {
+                if (g_map[1] == g_map[cad])
+                {
+                    if (g_map[ad] == 1 && g_map[ad + 1] == 0)
+                    {
                         g_map[ad] = 0;
                         g_map[ad + 1] = 0;
                     }
                 }
-                if (g_map[1] == g_map[cad + 1000]) {
-                    if (g_map[ad] == 0 && g_map[ad + 1] == 1) {
+                if (g_map[1] == g_map[cad + 1000])
+                {
+                    if (g_map[ad] == 0 && g_map[ad + 1] == 1)
+                    {
                         g_map[ad] = 0;
                         g_map[ad + 1] = 0;
                     }
                 }
 
-                if (g_machine == PLUS4M) {
-                    if (g_map[2] == g_map[cad]) {
-                        if (g_map[ad] == 1 && g_map[ad + 1] == 0) {
+                if (g_machine == PLUS4M)
+                {
+                    if (g_map[2] == g_map[cad])
+                    {
+                        if (g_map[ad] == 1 && g_map[ad + 1] == 0)
+                        {
                             g_map[ad] = 1;
                             g_map[ad + 1] = 1;
                         }
                     }
-                    if (g_map[2] == g_map[cad + 1000]) {
-                        if (g_map[ad] == 0 && g_map[ad + 1] == 1) {
+                    if (g_map[2] == g_map[cad + 1000])
+                    {
+                        if (g_map[ad] == 0 && g_map[ad + 1] == 1)
+                        {
                             g_map[ad] = 1;
                             g_map[ad + 1] = 1;
                         }
                     }
-                    if (g_map[1] == g_map[2]) {
-                        if (g_map[ad] == 1 && g_map[ad + 1] == 1) {
+                    if (g_map[1] == g_map[2])
+                    {
+                        if (g_map[ad] == 1 && g_map[ad + 1] == 1)
+                        {
                             g_map[ad] = 0;
                             g_map[ad + 1] = 0;
                         }
                     }
                 }
 
-                if (g_machine == C64M) {
-                    if (g_map[1] == g_map[cad + 2000]) {
-                        if (g_map[ad] == 1 && g_map[ad + 1] == 1) {
+                if (g_machine == C64M)
+                {
+                    if (g_map[1] == g_map[cad + 2000])
+                    {
+                        if (g_map[ad] == 1 && g_map[ad + 1] == 1)
+                        {
                             g_map[ad] = 0;
                             g_map[ad + 1] = 0;
                         }
@@ -595,11 +659,14 @@
     int mx = int(x / 8);
     int my = int(y / 8);
 
-    if (g_attrimode == 1) {
+    if (g_attrimode == 1)
+    {
         k_max = 64;
         miny = 0;
         maxy = 7;
-    } else {
+    }
+    else
+    {
         k_max = 8;
         miny = chop8(y);
         maxy = y - miny;
@@ -619,7 +686,8 @@
         for (int yy = miny; yy <= maxy; yy++)
         {
             ad = 1024 + (mx * 8) + (my * 8 + yy) * X;
-            for (int xx = 0; xx <= 7; xx++) {
+            for (int xx = 0; xx <= 7; xx++)
+            {
                 val = val + g_map[ad + xx];
             }
         }
@@ -635,27 +703,36 @@
         farge0 = g_map[bad]; //if(g_britemode==1&&farge0==8){farge0=0;}
         farge1 = g_map[cad]; //if(g_britemode==1&&farge1==8){farge1=0;}
 
-        if (g_britemode == 1) {
-            if (farge0 < 8) {
-                if (foreg == farge0 + 8) {
+        if (g_britemode == 1)
+        {
+            if (farge0 < 8)
+            {
+                if (foreg == farge0 + 8)
+                {
                     fixattr(x, y, foreg, -1);
                     return;
                 }
             }
-            if (farge1 < 8) {
-                if (foreg == farge1 + 8) {
+            if (farge1 < 8)
+            {
+                if (foreg == farge1 + 8)
+                {
                     fixattr(x, y, -1, foreg);
                     return;
                 }
             }
-            if (farge0 >= 8) {
-                if (foreg == farge0 - 8) {
+            if (farge0 >= 8)
+            {
+                if (foreg == farge0 - 8)
+                {
                     fixattr(x, y, foreg, -1);
                     return;
                 }
             }
-            if (farge1 >= 8) {
-                if (foreg == farge1 - 8) {
+            if (farge1 >= 8)
+            {
+                if (foreg == farge1 - 8)
+                {
                     fixattr(x, y, -1, foreg);
                     return;
                 }
@@ -674,31 +751,40 @@
     if (g_britemode == 1 && piksuf == 8) piksuf = 0;
     bad = 0;
     cad = 0;
-    for (int yy = miny; yy <= maxy; yy++) {
+    for (int yy = miny; yy <= maxy; yy++)
+    {
         bad = 65536 + mx + (my * 8) * MX + yy * MX;
         cad = bad + MX * (MY * 8);
         fg = g_map[bad];
         if (g_britemode == 1 && fg == 8) fg = 0;
         bg = g_map[cad];
         if (g_britemode == 1 && bg == 8) bg = 0;
-        if (piksuf == fg) {
+        if (piksuf == fg)
+        {
             g_map[bad] = byte(foreg);
-            if (g_britemode == 1) {
-                if (foreg > 7 && g_map[cad] < 8 && g_map[cad] != 0) {
+            if (g_britemode == 1)
+            {
+                if (foreg > 7 && g_map[cad] < 8 && g_map[cad] != 0)
+                {
                     g_map[cad] = byte(g_map[cad] + 8);
                 }
-                if (foreg < 8 && g_map[cad] > 8 && foreg != 0) {
+                if (foreg < 8 && g_map[cad] > 8 && foreg != 0)
+                {
                     g_map[cad] = byte(g_map[cad] - 8);
                 }
             }
         }
-        if (piksuf == bg) {
+        if (piksuf == bg)
+        {
             g_map[cad] = byte(foreg);
-            if (g_britemode == 1) {
-                if (foreg > 7 && g_map[bad] < 8 && g_map[bad] != 0) {
+            if (g_britemode == 1)
+            {
+                if (foreg > 7 && g_map[bad] < 8 && g_map[bad] != 0)
+                {
                     g_map[bad] = byte(g_map[bad] + 8);
                 }
-                if (foreg < 8 && g_map[bad] > 8 && foreg != 0) {
+                if (foreg < 8 && g_map[bad] > 8 && foreg != 0)
+                {
                     g_map[bad] = byte(g_map[bad] - 8);
                 }
             }
@@ -707,9 +793,12 @@
 
     // if the result is same color, zero the pixel data
 
-    if (g_map[bad] == g_map[cad]) {
-        for (int yy = miny; yy <= maxy; yy++) {
-            for (int xx = 0; xx <= 7; xx++) {
+    if (g_map[bad] == g_map[cad])
+    {
+        for (int yy = miny; yy <= maxy; yy++)
+        {
+            for (int xx = 0; xx <= 7; xx++)
+            {
                 ad = 1024 + (mx * 8 + xx) + (my * 8 + yy) * X;
                 g_map[ad] = byte(0);
             }
@@ -719,7 +808,8 @@
 }
 
 
-void kaveri_iq(int x, int y, int f1, int f2) {
+void kaveri_iq(int x, int y, int f1, int f2)
+{
     int k_xx, k_yy, k_ad, k_bad, k_ojox, k_ojoy, k_miny, k_maxy, k_xv, k_yv;
     int k_c1, k_c2, k_v0, k_v1, k_tipping, k_maximum, exist;
     byte k_p;
@@ -729,14 +819,19 @@
 
     exist = getabsa(x, y, 0);
 
-    if (g_britemode == 1) {
-        if (exist == 8) {
-            if (g_farge < 8) {
+    if (g_britemode == 1)
+    {
+        if (exist == 8)
+        {
+            if (g_farge < 8)
+            {
                 exist = 0;
             }
         }
-        if (exist == 0) {
-            if (g_farge > 7) {
+        if (exist == 0)
+        {
+            if (g_farge > 7)
+            {
                 exist = 0;
             }
         }
@@ -755,7 +850,8 @@
     k_maxy = k_miny;
     k_maximum = 8;
 
-    if (g_attrimode == 1) {
+    if (g_attrimode == 1)
+    {
         k_miny = 0;
         k_maxy = 7;
         k_tipping = 32;
@@ -767,7 +863,8 @@
     k_c1 = g_map[k_ad];
     k_c2 = g_map[k_bad];
 
-    if (g_britemode == 1) {
+    if (g_britemode == 1)
+    {
         if (k_c1 == 8) k_c1 = 0;
         if (k_c2 == 8) k_c2 = 0;
     }
@@ -775,12 +872,17 @@
     k_bad = 1024 + k_xx * 8 + k_yy * X;
 
     //do we have more 0's or 1's
-    for (k_yv = k_miny; k_yv <= k_maxy; k_yv++) {
+    for (k_yv = k_miny; k_yv <= k_maxy; k_yv++)
+    {
         k_ad = k_bad + k_yv * X;
-        for (k_xv = 0; k_xv <= 7; k_xv++) {
-            if (g_map[k_ad] == 1) {
+        for (k_xv = 0; k_xv <= 7; k_xv++)
+        {
+            if (g_map[k_ad] == 1)
+            {
                 k_v1++;
-            } else {
+            }
+            else
+            {
                 k_v0++;
             }
             k_ad++;
@@ -789,25 +891,31 @@
 
     //force color
 
-    if (g_control) {
+    if (g_control)
+    {
 
         k_v1 = k_tipping + 1;
 
-        if (k_c1 == exist) {
+        if (k_c1 == exist)
+        {
             k_c1 = g_farge;
             if (k_c1 == 8 && g_britemode == 1) k_c1 = 0;
         }
-        if (k_c2 == exist) {
+        if (k_c2 == exist)
+        {
             k_c2 = g_farge;
             if (k_c2 == 8 && g_britemode == 1) k_c2 = 0;
         }
 
-        if (g_britemode == 1) {
-            if (g_farge >= 8) {
+        if (g_britemode == 1)
+        {
+            if (g_farge >= 8)
+            {
                 if (k_c1 <= 7) k_c1 = k_c1 + 8;
                 if (k_c2 <= 7) k_c2 = k_c2 + 8;
             }
-            if (g_farge <= 7) {
+            if (g_farge <= 7)
+            {
                 if (k_c1 >= 8) k_c1 = k_c1 - 8;
                 if (k_c2 >= 8) k_c2 = k_c2 - 8;
             }
@@ -815,16 +923,20 @@
 
     }
 
-    if (k_v1 > k_tipping) {
-        for (k_yv = k_miny; k_yv <= k_maxy; k_yv++) {
+    if (k_v1 > k_tipping)
+    {
+        for (k_yv = k_miny; k_yv <= k_maxy; k_yv++)
+        {
             k_ad = 65536 + k_xx + (k_yy + k_yv) * MX;
             k_bad = k_ad + MX * (MY * 8);
             g_map[k_ad] = byte(k_c2);
             g_map[k_bad] = byte(k_c1);
         }
-        for (k_yv = k_miny; k_yv <= k_maxy; k_yv++) {
+        for (k_yv = k_miny; k_yv <= k_maxy; k_yv++)
+        {
             k_ad = 1024 + k_xx * 8 + (k_yy + k_yv) * X;
-            for (k_xv = 0; k_xv <= 7; k_xv++) {
+            for (k_xv = 0; k_xv <= 7; k_xv++)
+            {
                 k_p = g_map[k_ad];
                 g_map[k_ad] = byte(1 - k_p);
                 if (k_c1 == k_c2) g_map[k_ad] = byte(0);
--- a/events.pde	Wed Sep 05 20:08:57 2018 +0300
+++ b/events.pde	Wed Sep 05 20:28:23 2018 +0300
@@ -214,7 +214,9 @@
             {
                 msx = g_iconx - g_windowx;
                 msy = g_icony - g_windowy;
-            } else {
+            }
+            else
+            {
                 msx = g_iconx;
                 msy = g_icony;
             }
@@ -262,7 +264,8 @@
 
     if (g_data[int('4')] == 1)
     {
-        if (g_phase == 1) {
+        if (g_phase == 1)
+        {
             g_phase = 0;
             g_rubbermode = 0;
             refresh();
@@ -380,16 +383,22 @@
         g_boxreconstruct = 2;
     }
 
-    if (ckey == TAB) {
-        if (g_shift == false) {
-            if (g_britemode == 1) {
+    if (ckey == TAB)
+    {
+        if (g_shift == false)
+        {
+            if (g_britemode == 1)
+            {
                 if (g_realfront == 7) g_realfront = -1;
                 if (g_realfront == 15) g_realfront = 7;
             }
             selectcolor(0, g_realfront + 1);
             g_repanel = -2;
-        } else {
-            if (g_britemode == 1) {
+        }
+        else
+        {
+            if (g_britemode == 1)
+            {
                 if (g_realfront == 8) g_realfront = 16;
                 if (g_realfront == 0) g_realfront = 8;
             }
@@ -602,15 +611,18 @@
         g_data[ckey]++;
         if (g_data[ckey] > 1) g_data[ckey] = 0;
 
-        if (ckey == 'Q') {
+        if (ckey == 'Q')
+        {
             g_repanel = -2;
             g_msgctr = 0;
             help(int('B'));
             g_msgctr = 50;
         }
-        if (ckey == 'G') {
+        if (ckey == 'G')
+        {
             g_data[int('G')] = 0;
-            switch (g_gridx) {
+            switch (g_gridx)
+            {
                 case 8:
                     g_gridx = 16;
                     g_gridy = 16;
@@ -630,7 +642,8 @@
             g_msgctr = 50;
         }
 
-        if (ckey == 'G') {
+        if (ckey == 'G')
+        {
             if (g_data[int('g')] == 0) g_data[int('g')] = 1;
         }
 
@@ -654,35 +667,43 @@
             }
         }
 
-        if (g_data[int('B')] == 1) {
+        if (g_data[int('B')] == 1)
+        {
             changeborder(LEFT);
             if (g_machine == MSX)
                 g_data[int('C')] = 1;
         }
 
-        if (g_data[int('C')] == 1) {
+        if (g_data[int('C')] == 1)
+        {
             g_data[int('C')] = 0;
-            if (int(g_map[1]) != 255) {
+            if (int(g_map[1]) != 255)
+            {
                 store_undo();
-                if (g_machine == PLUS4M && g_farge == g_map[2]) {
+                if (g_machine == PLUS4M && g_farge == g_map[2])
+                {
                     message("1st and 2nd|can't be|same");
                     refresh();
                     return;
                 }
                 g_map[1] = byte(g_farge);
 
-                if (g_machine == MSX) {
+                if (g_machine == MSX)
+                {
                     g_map[0] = byte(g_farge);
                     sussborder();
                 }
                 message("Set back|color");
             }
         }
-        if (g_data[int('V')] == 1) {
+        if (g_data[int('V')] == 1)
+        {
             g_data[int('V')] = 0;
-            if (int(g_map[1]) != 255) {
+            if (int(g_map[1]) != 255)
+            {
                 store_undo();
-                if (g_machine == PLUS4M && g_farge == g_map[1]) {
+                if (g_machine == PLUS4M && g_farge == g_map[1])
+                {
                     message("1st and 2nd|can't be|same");
                     refresh();
                     return;
@@ -691,7 +712,8 @@
                 message("Set 2nd|back color");
             }
         }
-        if (g_data[int('N')] == 1) {
+        if (g_data[int('N')] == 1)
+        {
             g_data[int('N')] = 0;
             if (++g_animspeed > 3)
                 g_animspeed = 0;
@@ -737,57 +759,69 @@
             }
         }
 
-        if (g_data[int('i')] == 1) {
+        if (g_data[int('i')] == 1)
+        {
             g_data[int('i')] = 0;
             selectcolor(0, nextluminance(g_farge, 1));
         }
-        if (g_data[int('k')] == 1) {
+        if (g_data[int('k')] == 1)
+        {
             g_data[int('k')] = 0;
             selectcolor(0, nextluminance(g_farge, -1));
         }
-        if (g_data[int('d')] == 0) {
+        if (g_data[int('d')] == 0)
+        {
             if (ckey == 'd') consistency();
         }
-        if (g_data[int('z')] == 1) {
+        if (g_data[int('z')] == 1)
+        {
             g_data[int('z')] = 0;
             int orient;
             orient = g_data[int('x')] * 100 + g_data[int('y')] * 10 + g_data[int('q')];
-            if (orient == 0) {
+            if (orient == 0)
+            {
                 g_data[int('x')] = 0;
                 g_data[int('y')] = 0;
                 g_data[int('q')] = 1;
             }
-            if (orient == 1) {
+            if (orient == 1)
+            {
                 g_data[int('x')] = 1;
                 g_data[int('y')] = 1;
                 g_data[int('q')] = 0;
             }
-            if (orient == 110) {
+            if (orient == 110)
+            {
                 g_data[int('x')] = 1;
                 g_data[int('y')] = 1;
                 g_data[int('q')] = 1;
             }
-            if (orient == 111) {
+            if (orient == 111)
+            {
                 g_data[int('x')] = 0;
                 g_data[int('y')] = 0;
                 g_data[int('q')] = 0;
             }
-            if (orient == 100) {
+            if (orient == 100)
+            {
                 g_data[int('x')] = 0;
                 g_data[int('y')] = 1;
                 g_data[int('q')] = 1;
             }
-            if (orient == 11) {
+            if (orient == 11)
+            {
                 g_data[int('x')] = 0;
                 g_data[int('y')] = 1;
                 g_data[int('q')] = 0;
             }
-            if (orient == 10) {
+            if (orient == 10)
+            {
                 g_data[int('x')] = 1;
                 g_data[int('y')] = 0;
                 g_data[int('q')] = 1;
             }
-            if (orient == 101) {
+            if (orient == 101)
+            {
                 g_data[int('x')] = 1;
                 g_data[int('y')] = 0;
                 g_data[int('q')] = 0;
@@ -795,8 +829,10 @@
             message("Rotate|brush");
         }
 
-        if (ckey == 'm') {
-            if (g_data[int('M')] == 1) {
+        if (ckey == 'm')
+        {
+            if (g_data[int('M')] == 1)
+            {
                 g_data[int('m')] = 0;
                 ckey = 0;
                 g_boxreconstruct = 2;
@@ -805,13 +841,16 @@
             g_data[int('M')] = 0;
         }
 
-        if (g_data[int('m')] == 1) {
-            if (ckey == 'm') {
+        if (g_data[int('m')] == 1)
+        {
+            if (ckey == 'm')
+            {
                 g_data[int('M')] = 0;
                 g_ofx = int(g_storedcoordx / 8) - int(magx() / 2);
                 g_ofy = int(g_storedcoordy / 8) - int(magy() / 2);
                 message("Magnify");
-                if (tool() == 0) {
+                if (tool() == 0)
+                {
                     set_tool(g_prevtool);
                     g_phase = 0;
                     g_rubbermode = 0;
@@ -821,7 +860,8 @@
         refresh();
     }
 
-    if (g_data[int('J')] == 1) {
+    if (g_data[int('J')] == 1)
+    {
         g_data[int('J')] = 0;
         g_data[int('j')] = 0;
         spare();
@@ -831,7 +871,8 @@
         spare();
     }
 
-    if (g_data[int('j')] == 1) {
+    if (g_data[int('j')] == 1)
+    {
         g_data[int('j')] = 0;
         spare();
         message((g_spare ? "Spare" : "Front") + " Page");
@@ -839,10 +880,12 @@
         g_boxreconstruct = 2;
     }
 
-    if (g_data[int('O')] == 1) {
+    if (g_data[int('O')] == 1)
+    {
         g_data[int('O')] = 0;
         store_undo();
-        for (int xx = 0; xx < X * Y; xx++) {
+        for (int xx = 0; xx < X * Y; xx++)
+        {
             g_map[1024 + xx] = 0;
         }
         for (int xx = 0; xx < X; xx++)
@@ -854,7 +897,8 @@
         }
     }
 
-    if (g_data[int('o')] == 1) {
+    if (g_data[int('o')] == 1)
+    {
         g_data[int('o')] = 0;
         message("Clear all");
         store_undo();
@@ -864,12 +908,15 @@
         g_data[int('d')] = 0;
         g_data[int('t')] = 0;
 
-        for (int xx = 0; xx < X * Y; xx++) {
+        for (int xx = 0; xx < X * Y; xx++)
+        {
             g_map[1024 + xx] = 0;
         }
 
-        for (int xx = 0; xx < X; xx++) {
-            for (int yy = 0; yy < Y; yy++) {
+        for (int xx = 0; xx < X; xx++)
+        {
+            for (int yy = 0; yy < Y; yy++)
+            {
                 g_farge = g_backg;
                 makepoint(xx, yy);
                 g_farge = g_ofarge;
@@ -882,35 +929,40 @@
     if (g_data[int('e')] == 1)
         g_data[int('e')] = 0;
 
-    if (g_data[int('h')] == 1) {
+    if (g_data[int('h')] == 1)
+    {
         g_data[int('h')] = 0;
         g_bsize--;
         if (g_bsize < 0) g_bsize = 0;
         g_msgctr = -2;
         help(int('h'));
     }
-    if (g_data[int('H')] == 1) {
+    if (g_data[int('H')] == 1)
+    {
         g_data[int('H')] = 0;
         g_bsize++;
         if (g_bsize > 10) g_bsize = 10;
         g_msgctr = -2;
         help(int('h'));
     }
-    if (g_data[int('u')] == 1) {
+    if (g_data[int('u')] == 1)
+    {
         g_data[int('u')] = 0;
         message("Undo");
         restore_undo();
         refresh();
         g_boxreconstruct = 2;
     }
-    if (g_data[int('U')] == 1) {
+    if (g_data[int('U')] == 1)
+    {
         g_data[int('U')] = 0;
         message("Redo");
         redo_undo();
         refresh();
     }
 
-    if (g_machine == SPECTRUM) {
+    if (g_machine == SPECTRUM)
+    {
         if (g_data[int('I')] == 1)
         {
             g_data[int('I')] = 0;
--- a/exporters.pde	Wed Sep 05 20:08:57 2018 +0300
+++ b/exporters.pde	Wed Sep 05 20:28:23 2018 +0300
@@ -234,14 +234,17 @@
         }
     }
     else
-    if (g_machine == C64) {
+    if (g_machine == C64)
+    {
         //0x0002->bitmap
         //0x1f42->colormap
         //0x232a=border (take the lower nybble)
-        if (fdata.length < 9006) {
+        if (fdata.length < 9006)
+        {
             return false;
         }
-        if (fdata.length >= 0x232a) {
+        if (fdata.length >= 0x232a)
+        {
             g_map[0] = byte(fdata[0x232a] & 0x0f);
         }
         for (y = 0; y < 25; y++)
@@ -259,12 +262,14 @@
         }
     }
     else
-    if (g_machine == PLUS4) { // Botticelli
+    if (g_machine == PLUS4)
+    { // Botticelli
         //g.hires.prg = botticelli
         //2 - luminance 40*25
         //1026 - colors 40*25
         //2050 - bitmappi 40*25*8
-        if (fdata.length < 10050) {
+        if (fdata.length < 10050)
+        {
             return false;
         }
         int l1, l2;
@@ -286,14 +291,16 @@
         }
     }
     else
-    if (g_machine == PLUS4M) { // Multi Botticelli
+    if (g_machine == PLUS4M)
+    { // Multi Botticelli
         //m.multi.prg = multi botticelli
         //2- lumins 40*25
         //1024 - bäkki1
         //1025 - bäkki2
         //1026 - colors 40*25
         //2050 - bitmap 40*25*8
-        if (fdata.length < 10050) {
+        if (fdata.length < 10050)
+        {
             return false;
         }
         int l1, l2;
@@ -323,14 +330,16 @@
         g_map[2] = byte(convertluminance(l1, p1));
     }
     else
-    if (g_machine == C64M) { //advanced art studio
+    if (g_machine == C64M)
+    { //advanced art studio
         //adv. art studio (=multicolor) 10018 bytes
         //0x0002 bitmap (40*25*8)
         //0x1f42 colors1 (40*25)
         //0x232a border
         //0x232b background
         //0x233a colors2 (40*25)
-        if (fdata.length < 10018) {
+        if (fdata.length < 10018)
+        {
             return false;
         }
         for (y = 0; y < 25; y++)
@@ -353,13 +362,15 @@
         g_map[1] = byte(fdata[0x232b] & 0x0f); //baku
     }
     else
-    if (g_machine == C64FLIM) {
+    if (g_machine == C64FLIM)
+    {
         // FBI Crew FLI designer 1.x & 2.0 (unpacked)
         //    { DO_COPY      , DS_COLOR_RAM   , 0x0000, 0,  0,   0, NULL, NULL },
         //    DEF_SCREEN_RAMS_8(0x0400, 0, 0x400, 0),
         //    { DO_COPY      , DS_BITMAP_RAM  , 0x2400, 0,  0,   0, NULL, NULL },
         //    { DO_LAST      , 0              , 0     , 0,  0,   0, NULL, NULL },
-        if (fdata.length != 17409) {
+        if (fdata.length != 17409)
+        {
             // TODO XXX: Check for load addresses 3c00 and 3ff0
             return false;
         }
@@ -384,10 +395,12 @@
         g_map[1] = byte(0); //baku
     }
     else
-    if (g_machine == MSX) { // sc2
+    if (g_machine == MSX)
+    { // sc2
         // 7=bitmap 32*24*8
         // 7+(32*24*8)=colormap 32*24
-        if (fdata.length < 14343) {
+        if (fdata.length < 14343)
+        {
             return false;
         }
         for (y = 0; y < 24; y++)
@@ -410,7 +423,8 @@
         }
     }
     else
-    if (g_machine == CPC) { // a studio?
+    if (g_machine == CPC)
+    { // a studio?
         return false;
     }
 
@@ -426,7 +440,8 @@
     int val1, val2, val3;
     int y, y2, yy, x, yp, xp, ad, valu, valu2, bri;
 
-    if (g_machine == PLUS4) { // botticelli hires
+    if (g_machine == PLUS4)
+    { // botticelli hires
         ctx.loadTemplate("g.hires.prg");
 
         ctx.setOffs(0x02);
@@ -439,7 +454,8 @@
         mpExportBitmapData(ctx, 40, 25);
     }
     else
-    if (g_machine == PLUS4M) { // multi botticelli multicolor
+    if (g_machine == PLUS4M)
+    { // multi botticelli multicolor
         ctx.loadTemplate("m.multi.prg");
 
         val2 = getpluscolor(int(g_map[1]));
@@ -462,7 +478,8 @@
         mpExportBitmapData(ctx, 40, 25);
     }
     else
-    if (g_machine == C64) {
+    if (g_machine == C64)
+    {
         ctx.loadTemplate("hires.art");
 
         ctx.setOffs(2);
@@ -474,7 +491,8 @@
         ctx.writeByteAt(0x232a, g_map[0]);
     }
     else
-    if (g_machine == C64M) {
+    if (g_machine == C64M)
+    {
         if (subformat == 0)
         {
             // Advanced Art Studio
@@ -510,7 +528,8 @@
         }
     }
     else
-    if (g_machine == C64FLIM) {
+    if (g_machine == C64FLIM)
+    {
         // FBI Crew FLI designer 1.x & 2.0 (unpacked)
         //    { DO_COPY      , DS_COLOR_RAM   , 0x0000, 0,  0,   0, NULL, NULL },
         //    DEF_SCREEN_RAMS_8(0x0400, 0, 0x400, 0),
@@ -531,7 +550,8 @@
         mpExportBitmapData(ctx, 40, 25);
     }
     else
-    if (g_machine == MSX) {
+    if (g_machine == MSX)
+    {
         ctx.loadTemplate("msx-screen2.sc2");
 
         ctx.setOffs(7);
@@ -541,7 +561,8 @@
         mpExportColorData(ctx, 32, 24, 65536, 3); //there's an exception for msx-style
     }
     else
-    if (g_machine == SPECTRUM) {
+    if (g_machine == SPECTRUM)
+    {
         ctx.loadTemplate("zx-screen.scr");
 
         ctx.setOffs(0);
@@ -598,7 +619,8 @@
     // any common text headers
     ctx.addComment("g_machine=" + str(g_machine) + " (" + g_name + ")");
 
-    if (g_machine == C64) { //C64 HIRES
+    if (g_machine == C64)
+    { //C64 HIRES
         ctx.loadTemplate("c64show.prg");
 
         ctx.setOffs(0x0227);
@@ -619,7 +641,8 @@
         //0x2169->värikartta (40x25 bytee, nyppelit foreg/backg)
     }
     else
-    if (g_machine == C64M) { //C64 MULTICOLOR
+    if (g_machine == C64M)
+    { //C64 MULTICOLOR
         ctx.loadTemplate("c64mshow.prg");
 
         ctx.setOffs(0x0239);
@@ -648,7 +671,8 @@
         //0x2563->värikartta 2 (40x25 bytee, nyppeli 3-väri nepan osoitteessa $d800-)
     }
     else
-    if (g_machine == PLUS4M) { //PLUS4 MULTICOLOR
+    if (g_machine == PLUS4M)
+    { //PLUS4 MULTICOLOR
         ctx.loadTemplate("showpfourm.prg");
 
         ctx.addLine(".global @@_bitmap");
@@ -700,7 +724,8 @@
         //0x2469 luminance (40 x 25)
     }
     else
-    if (g_machine == PLUS4) { // Plus 4 hires
+    if (g_machine == PLUS4)
+    { // Plus 4 hires
         ctx.loadTemplate("showpfour.prg");
 
         ctx.addLine(".global @@_bitmap");
@@ -732,7 +757,8 @@
         //0x2460   luminance (40 x 25)
     }
     else
-    if (g_machine == MSX) { // MSX
+    if (g_machine == MSX)
+    { // MSX
         ctx.loadTemplate("msxshow.com");
 
         ctx.addLine(".globl @@_bitmap,@@_nimi2");
@@ -755,7 +781,8 @@
         //0x18fa colors (32*24 bytes)
     }
     else
-    if (g_machine == SPECTRUM) { // ZX Spectrum
+    if (g_machine == SPECTRUM)
+    { // ZX Spectrum
 
         //would need some cleaning up
 
@@ -828,7 +855,8 @@
         ctx.writeByteAt(0x1d3e, int(checksum), "_checksum");
     }
     else
-    if (g_machine == CPC) {
+    if (g_machine == CPC)
+    {
         int val1, val2, val3, valu;
         ctx.loadTemplate("cpc-mode0.bin");
 
@@ -1015,7 +1043,8 @@
     else
         xmult = width;
 
-    if (g_machine == MSX) {
+    if (g_machine == MSX)
+    {
         myrpsi = 7;
     }
 
@@ -1108,10 +1137,12 @@
     erkki = 1;
     limitter = 2;
 
-    if (g_britemode == 1) {
+    if (g_britemode == 1)
+    {
         xcolors = 8;
     }
-    if (g_attrimode == 0) {
+    if (g_attrimode == 0)
+    {
         vertti = 1;
         erkki = 8;
     }
--- a/files.pde	Wed Sep 05 20:08:57 2018 +0300
+++ b/files.pde	Wed Sep 05 20:28:23 2018 +0300
@@ -1,7 +1,8 @@
 boolean mpHaveLocalStorage()
 {
     var test = 'mpLSTest';
-    try {
+    try
+    {
         localStorage.setItem(test, test);
         if (localStorage.getItem(test) == test)
         {
@@ -9,7 +10,8 @@
             return true;
         }
     }
-    catch (e) {
+    catch (e)
+    {
         return false;
     }
     return false;
@@ -32,14 +34,15 @@
             mobj.accept = fmtexts;
 
         stAddEventOb(mobj.name, mobj, "change",
-            function(evt)
+            function (evt)
             {
                 var files = evt.target.files;
                 if (files.length > 0)
                 {
                     var freader = new FileReader();
 
-                    freader.onloadend = (function(theFile) {
+                    freader.onloadend = (function (theFile)
+                    {
                         fcallback(theFile, new Uint8Array(freader.result));
                     });
 
@@ -54,7 +57,7 @@
         mobj = stCE("button", "mpFileSelectorCancel");
         mobj.textContent = "Cancel";
         stAddEventOb(mobj.name, mobj, "click",
-            function(evt)
+            function (evt)
             {
                 mpHideGUI();
             });
--- a/interface.pde	Wed Sep 05 20:08:57 2018 +0300
+++ b/interface.pde	Wed Sep 05 20:28:23 2018 +0300
@@ -126,7 +126,8 @@
 
 void fixed_raster_command(int par)
 {
-    if (par == 'p') {
+    if (par == 'p')
+    {
         g_raster_no--;
         if (g_raster_no < 0)
             g_raster_no = 9;
@@ -134,7 +135,8 @@
         g_data[int('r')] = 1;
     }
     else
-    if (par == 'n') {
+    if (par == 'n')
+    {
         g_raster_no++;
         if (g_raster_no > 9)
             g_raster_no = 0;
@@ -142,13 +144,15 @@
         g_data[int('r')] = 1;
     }
     else
-    if (par == 'x') {
+    if (par == 'x')
+    {
         g_raster_offset_x++;
         if (g_raster_offset_x > 3)
             g_raster_offset_x = 0;
     }
     else
-    if (par == 'y') {
+    if (par == 'y')
+    {
         g_raster_offset_y++;
         if (g_raster_offset_y > 3)
             g_raster_offset_y = 0;
@@ -199,7 +203,8 @@
 {
     //0-255 go to g_map[] up until 1021-1023
     //the rest is not stored
-    if (c < 256) {
+    if (c < 256)
+    {
         g_map[256 + c * 3] = byte(rr);
         g_map[256 + c * 3 + 1] = byte(gg);
         g_map[256 + c * 3 + 2] = byte(bb);
@@ -216,7 +221,8 @@
 {
     //for the animated rubberband thingy
     g_rband++;
-    if (g_rband > g_rbang) {
+    if (g_rband > g_rbang)
+    {
         g_rband = 0;
         g_rbang++;
         if (g_rbang > 12) g_rbang = 8;
@@ -319,7 +325,8 @@
 // parameter store/restore in case some functions need to bypass grid, attribute modes etc
 void storeparameters()
 {
-    for (int i = 0; i <= 255; i++) {
+    for (int i = 0; i <= 255; i++)
+    {
         g_data[767 + i] = g_data[i];
     }
 }
@@ -327,7 +334,8 @@
 
 void restoreparameters()
 {
-    for (int i = 0; i <= 255; i++) {
+    for (int i = 0; i <= 255; i++)
+    {
         g_data[i] = g_data[767 + i];
     }
 }
@@ -387,8 +395,10 @@
                 if (mm == 1) far = 0xffffff80;
             }
 
-            if (t == 66) { //raster icon
-                if (x >= 1 && y >= 2 && x <= 13 && y <= 12) {
+            if (t == 66)
+            { //raster icon
+                if (x >= 1 && y >= 2 && x <= 13 && y <= 12)
+                {
                     far = metal;
                     if (mm == 1) far = 0xffffff80;
                     if (get_raster(x + 1, y) == 1) far = 0xff000000;
@@ -419,12 +429,16 @@
         for (int x = 0; x < 8; x++)
         {
             int far;
-            if (int(g_icons[ad + x]) != 0) {
+            if (int(g_icons[ad + x]) != 0)
+            {
                 far = 0xffb0b0b0;
-                if (g_bsize < 4) {
+                if (g_bsize < 4)
+                {
                     if (g_bsize + (g_btype * 4) + 96 == t) far = 0xffffff80;
                 }
-            } else {
+            }
+            else
+            {
                 far = 0xff000000;
                 if (g_spare && t <= 95) far = 0xff008000; //different background color for spare mode
                 if (g_msgctr > 0 && t + 32 < 128) far = 0xff0000ff; //different background color
@@ -821,7 +835,8 @@
         //tooltip
         if (ad != ':' && ad != ';' && ad != '.')
         {
-            if (realdraw == 0) {
+            if (realdraw == 0)
+            {
                 if (moicon(xx + x, yy + y, 16 * g_uiscale, 16 * g_uiscale)) help(ad);
             }
             if (doicon(xx + x, yy + y, 16 * g_uiscale, 16 * g_uiscale))
@@ -883,7 +898,8 @@
 {
     int res = f + d;
 
-    if (g_machine == PLUS4 || g_machine == PLUS4M) {
+    if (g_machine == PLUS4 || g_machine == PLUS4M)
+    {
         if (f + d * 15 > 120) return f;
         if (f + d * 15 < 1) return f;
         if (d == 1) return f + 15;
@@ -891,22 +907,26 @@
         return res;
     }
 
-    if (g_map[13] == C64) { //here the "C64" is generic across C64,C64M and potential FLI modes
+    if (g_map[13] == C64)
+    { //here the "C64" is generic across C64,C64M and potential FLI modes
         int out[] = {
             6, 1, 11, 15, 8, 10,
             9, 13, 14, 2, 3, 4,
             5, 1, 12, 7
         }; // from "Ptoing"
         if (d == 1) res = out[f];
-        if (d == -1) {
+        if (d == -1)
+        {
             if (f == 0) return 0;
-            for (int i = 0; i < g_maxcolors; i++) {
+            for (int i = 0; i < g_maxcolors; i++)
+            {
                 if (out[i] == f) res = i;
             }
         }
     }
 
-    if (g_map[13] == MSX) {
+    if (g_map[13] == MSX)
+    {
         int out[] = {
             1,   4,  9, 10,
             6,  12, 13, 14,
@@ -914,9 +934,11 @@
             2,   8, 11, 15
         }; // calculated Y
         if (d == 1) res = out[f];
-        if (d == -1) {
+        if (d == -1)
+        {
             if (f == 0) return 0;
-            for (int i = 0; i < g_maxcolors - 1; i++) {
+            for (int i = 0; i < g_maxcolors - 1; i++)
+            {
                 if (out[i] == f) res = i;
             }
         }
@@ -942,7 +964,8 @@
 void set_tool(int s)
 {
     //set current tool, for convenience
-    for (int i = '0'; i <= '9'; i++) {
+    for (int i = '0'; i <= '9'; i++)
+    {
         g_data[i] = 0;
     }
     g_data[48 + s] = byte(1);
@@ -954,14 +977,16 @@
 {
     if (x >= g_maxcolors) x = x - g_maxcolors;
     if (x < 0) x = x + g_maxcolors;
-    if (hand == 0) {
+    if (hand == 0)
+    {
         g_farge = x;
         g_ofarge = x; //kludgey, the colour and the "original colour"
         if (g_btype == 9) g_data[int('p')] = 1;
         g_realfront = byte(g_farge);
         g_realback = byte(g_backg);
     }
-    if (hand == 1) {
+    if (hand == 1)
+    {
         g_backg = x;
         g_realback = byte(g_backg);
         g_realfront = byte(g_farge);
@@ -994,26 +1019,31 @@
 }
 
 
-void palettebox(float x0, int y0, float x1) {
+void palettebox(float x0, int y0, float x1)
+{
     if (g_palsteps == 0) return;
     float expand = ((x1 - x0) / g_palsteps);
     int divs = int(255 / (g_palsteps - 1));
-    for (int i = 0; i < g_palsteps; i++) {
-        if (doicon_drag(int(x0 + expand * i), y0, int(expand), 7 * g_uiscale)) {
+    for (int i = 0; i < g_palsteps; i++)
+    {
+        if (doicon_drag(int(x0 + expand * i), y0, int(expand), 7 * g_uiscale))
+        {
             g_r[g_farge] = int(i * divs);
             message("RED:" + i);
             makecolor(g_farge, g_r[g_farge], g_g[g_farge], g_b[g_farge]);
             refresh();
             g_boxreconstruct = 2;
         }
-        if (doicon_drag(int(x0 + expand * i), y0 + 10 * g_uiscale, int(expand), 7 * g_uiscale)) {
+        if (doicon_drag(int(x0 + expand * i), y0 + 10 * g_uiscale, int(expand), 7 * g_uiscale))
+        {
             g_g[g_farge] = int(i * divs);
             message("GREEN:" + i);
             makecolor(g_farge, g_r[g_farge], g_g[g_farge], g_b[g_farge]);
             refresh();
             g_boxreconstruct = 2;
         }
-        if (doicon_drag(int(x0 + expand * i), y0 + 20 * g_uiscale, int(expand), 7 * g_uiscale)) {
+        if (doicon_drag(int(x0 + expand * i), y0 + 20 * g_uiscale, int(expand), 7 * g_uiscale))
+        {
             g_b[g_farge] = int(i * divs);
             message("BLUE:" + i);
             makecolor(g_farge, g_r[g_farge], g_g[g_farge], g_b[g_farge]);
@@ -1026,7 +1056,8 @@
     {
         e_rect(int(x0), y0 + j * 10 * g_uiscale, int(x1 - x0), 7 * g_uiscale, g_rgb[258]);
 
-        for (int i = 1; i < g_palsteps; i++) {
+        for (int i = 1; i < g_palsteps; i++)
+        {
             e_rect(int(x0 + expand * i), y0 + j * 10 * g_uiscale, g_uiscale, 2 * g_uiscale, g_rgb[257]);
         }
     }
@@ -1050,7 +1081,8 @@
     yfat = 4 * g_uiscale;
     bfat = 1 * g_uiscale;
 
-    if (g_maxcolors > 60) {
+    if (g_maxcolors > 60)
+    {
         yhei = 4 * g_uiscale;
         yfat = 0;
         bfat = 1;
@@ -1064,7 +1096,8 @@
     maxp = g_maxcolors;
     xonko = int(int(512 / g_maxcolors) / 2) * g_uiscale;
 
-    if (g_maxcolors > 32) {
+    if (g_maxcolors > 32)
+    {
         maxp = int(g_maxcolors / 2);
         xonko = int(1024 / g_maxcolors);
     }
@@ -1080,31 +1113,38 @@
         {
             yloc = yo + yhei * 7;
 
-            if (x > 15 && x <= 30) {
+            if (x > 15 && x <= 30)
+            {
                 xloc = xo + (x - 15) * xonko;
                 yloc = yo + yhei * 6 + yfat * 2;
             }
-            if (x > 30 && x <= 45) {
+            if (x > 30 && x <= 45)
+            {
                 xloc = xo + (x - 30) * xonko;
                 yloc = yo + yhei * 5 + yfat * 4;
             }
-            if (x > 45 && x <= 60) {
+            if (x > 45 && x <= 60)
+            {
                 xloc = xo + (x - 45) * xonko;
                 yloc = yo + yhei * 4 + yfat * 6;
             }
-            if (x > 60 && x <= 75) {
+            if (x > 60 && x <= 75)
+            {
                 xloc = xo + (x - 60) * xonko;
                 yloc = yo + yhei * 3 + yfat * 8;
             }
-            if (x > 75 && x <= 90) {
+            if (x > 75 && x <= 90)
+            {
                 xloc = xo + (x - 75) * xonko;
                 yloc = yo + yhei * 2 + yfat * 10;
             }
-            if (x > 90 && x <= 105) {
+            if (x > 90 && x <= 105)
+            {
                 xloc = xo + (x - 90) * xonko;
                 yloc = yo + yhei * 1 + yfat * 12;
             }
-            if (x > 105 && x <= 120) {
+            if (x > 105 && x <= 120)
+            {
                 xloc = xo + (x - 105) * xonko;
                 yloc = yo + yhei * 0 + yfat * 14;
             }
@@ -1118,7 +1158,8 @@
             {
                 selectcolor(0, x);
             }
-            if (mouseButton == RIGHT) {
+            if (mouseButton == RIGHT)
+            {
                 selectcolor(1, x);
                 g_button = LEFT;
             }
@@ -1139,17 +1180,21 @@
 
             e_rect(xloc, yloc + yhei, xonko, yfat, far);
             if (doicon(xloc, yloc + yhei, xonko, yfat)) selectcolor(1, x);
-            if (yfat == 0) {
-                if (g_farge == x) {
+            if (yfat == 0)
+            {
+                if (g_farge == x)
+                {
                     e_rect(xloc, yloc, xonko / 4, yhei / 4, far);
                     e_rect(xloc, yloc + 1, xonko / 8, yhei / 4, far);
                 }
-                if (g_backg == x) {
+                if (g_backg == x)
+                {
                     e_rect(xloc + xonko - xonko / 4, yloc + yhei - 2, int(xonko / 4), int(yhei / 4), far);
                     e_rect(xloc + xonko - xonko / 8, yloc + yhei - 3, int(xonko / 8), int(yhei / 4), far);
                 }
             }
-            if (int(g_map[0]) == x) {
+            if (int(g_map[0]) == x)
+            {
                 far = 0xff000000;
                 if (dist(g_r[x], g_g[x], g_b[x], 0, 0, 0) < 1) far = 0xffffffff;
                 e_rect(xloc, yloc, xonko, bfat, far);
@@ -1157,13 +1202,16 @@
                 e_rect(xloc, yloc, bfat, yhei, far);
                 e_rect(xloc + xonko - bfat, yloc, bfat, yhei, far);
             }
-            if (int(g_map[1]) == x) {
+            if (int(g_map[1]) == x)
+            {
                 far = 0xff000000;
                 if (dist(g_r[x], g_g[x], g_b[x], 0, 0, 0) < 1) far = 0xffffffff;
                 e_rect(xloc + int(xonko / 4), yloc + int(yhei / 4), int(xonko / 4), int(yhei / 4), far);
             }
-            if (g_machine == PLUS4 || g_machine == PLUS4M) {
-                if (int(g_map[1]) != 255 && int(g_map[2]) == x) {
+            if (g_machine == PLUS4 || g_machine == PLUS4M)
+            {
+                if (int(g_map[1]) != 255 && int(g_map[2]) == x)
+                {
                     far = 0xff000000;
                     if (dist(g_r[x], g_g[x], g_b[x], 0, 0, 0) < 1) far = 0xffffffff;
                     e_rect(xloc + xonko - int(xonko / 4) * 2, yloc + yhei - int(yhei / 4) * 2, int(xonko / 4), int(yhei / 4), far);
@@ -1199,24 +1247,29 @@
     e_rect(ox, oy, bs * 2, bs * 4, g_rgb[int(g_realback)]);
     e_rect(ox + bs / 2, oy + 4 * g_uiscale, 12 * g_uiscale, bs * 2, g_rgb[int(g_realfront)]);
     if (doicon(ox, oy, bs * 2, bs * 3)) command(int('<'));
-    if (g_machine == C64M || g_machine == MSX || g_machine == AMIGA) {
+    if (g_machine == C64M || g_machine == MSX || g_machine == AMIGA)
+    {
         e_rect(ox, oy + bs * 3, bs * 2, bs, g_rgb[int(g_map[1])]);
         d_rect(ox, oy + bs * 3, bs * 2, bs, g_rgb[257]);
-        if (doicon(ox, oy + bs * 3, bs * 2, bs)) {
+        if (doicon(ox, oy + bs * 3, bs * 2, bs))
+        {
             if (g_shift == false) selectcolor(h, int(g_map[1]));
             if (g_shift) command(int('C'));
         }
     }
-    if (g_machine == PLUS4M) {
+    if (g_machine == PLUS4M)
+    {
         e_rect(ox, oy + bs * 3, bs, bs, g_rgb[int(g_map[1])]);
         e_rect(ox + 8 * g_uiscale, oy + bs * 3, bs, bs, g_rgb[int(g_map[2])]);
         d_rect(ox, oy + bs * 3, bs, bs, g_rgb[257]);
         d_rect(ox + 8 * g_uiscale, oy + bs * 3, bs, bs, g_rgb[257]);
-        if (doicon(ox, oy + bs * 3, bs, bs)) {
+        if (doicon(ox, oy + bs * 3, bs, bs))
+        {
             if (g_shift == false) selectcolor(h, int(g_map[1]));
             if (g_shift) command(int('C'));
         }
-        if (doicon(ox + 8 * g_uiscale, oy + bs * 3, bs, bs)) {
+        if (doicon(ox + 8 * g_uiscale, oy + bs * 3, bs, bs))
+        {
             if (g_shift == false) selectcolor(h, int(g_map[2]));
             if (g_shift) command(int('V'));
         }
@@ -1238,7 +1291,8 @@
         icontable(width - 32 * g_uiscale, 0, 0, 0);
         icontable(272 * g_uiscale, height - 32 * g_uiscale, 1, 0);
         //icontable(0,0,3,0);
-        if (g_machine == PLUS4M || g_machine == PLUS4) {
+        if (g_machine == PLUS4M || g_machine == PLUS4)
+        {
             icontable(240 * g_uiscale, height - 32 * g_uiscale, 2, 0);
         }
     }
@@ -1248,7 +1302,8 @@
         icontable(272 * g_uiscale, height - 32 * g_uiscale, 1, 1);
         palettebox(g_uiscale * 324 + 4, height - 32 * g_uiscale, width - (96 * g_uiscale) - 4);
 
-        if (g_machine == PLUS4M || g_machine == PLUS4) {
+        if (g_machine == PLUS4M || g_machine == PLUS4)
+        {
             icontable(240 * g_uiscale, height - 32 * g_uiscale, 2, 1);
         }
 
@@ -1289,7 +1344,8 @@
     mayy = magy();
     //borders & ultimate background
 
-    if (g_boxreconstruct == 1) {
+    if (g_boxreconstruct == 1)
+    {
         g_boxreconstruct = 0;
         //between mag window and toolboxes
         if (g_data['m'] == 1 || g_data['M'] == 1)
@@ -1321,7 +1377,8 @@
     g_ofx = clampv(g_ofx, 0, MX - magx());
     g_ofy = clampv(g_ofy, 0, MY - magy());
 
-    if (mmode == 10) {
+    if (mmode == 10)
+    {
         g_ofx = 0;
         g_ofy = 0;
         maxx = MX - 1;
@@ -1331,7 +1388,8 @@
         xcmag = 16;
     } //mini
     else
-    if (mmode == 0) {
+    if (mmode == 0)
+    {
         g_ofx = 0;
         g_ofy = 0;
         maxx = MX - 1;
@@ -1341,7 +1399,8 @@
         xcmag = 24;
     } //normal
     else
-    if (mmode == 20) {
+    if (mmode == 20)
+    {
         g_ofx = 0;
         g_ofy = 0;
         maxx = MX - 1;