changeset 173:9bbed9b6df8d

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 23 Aug 2018 11:10:25 +0300
parents e77a726a587e
children aa3d05b4dfa5
files draw_outputs.pde events.pde
diffstat 2 files changed, 115 insertions(+), 91 deletions(-) [+]
line wrap: on
line diff
--- a/draw_outputs.pde	Thu Aug 23 11:09:20 2018 +0300
+++ b/draw_outputs.pde	Thu Aug 23 11:10:25 2018 +0300
@@ -521,20 +521,23 @@
     if (xx < 0 || yy < 0 || xx >= X || yy >= Y) return;
 
     // adaptive color unless with floodfill (which has its own system)
-    if (int(g_map[12]) != 5) {
+    if (int(g_map[12]) != 5)
+    {
         if (g_multic == 2)
         {
             skaveri(xx, yy, g_farge, 0);
         }
         else
         {
-            if (g_data[int('b')] == 0) {
-                if (g_multic == 1) {
+            if (g_data[int('b')] == 0)
+            {
+                if (g_multic == 1)
                     mkaveri(xx, yy, g_farge, 0);
-                } else {
+                else
                     kaveri(xx, yy, g_farge, 0);
-                }
-            } else {
+            }
+            else
+            {
                 //old iq
                 kaveri_iq(xx, yy, g_farge, 0);
             }
--- a/events.pde	Thu Aug 23 11:09:20 2018 +0300
+++ b/events.pde	Thu Aug 23 11:10:25 2018 +0300
@@ -379,7 +379,8 @@
     }
 
     //println("ckey+"+ckey);
-    if (g_control == true) {
+    if (g_control == true)
+    {
         int UNDO = 26,
             REDO = 25,
             PASTE = 22,
@@ -390,7 +391,8 @@
             COPYALT = 24,
             ALL = 1;
 
-        if (platform == MACOSX) {
+        if (platform == MACOSX)
+        {
             UNDO = 122;
             REDO = 25;
             PASTE = 22;
@@ -402,110 +404,124 @@
             ALL = 97;
         }
 
-        if (ckey == UNDO) {
-            ckey = 'u';
-            if (g_shift) ckey = 'U';
-        } //undo
-        if (ckey == REDO) ckey = 'U';
-        if (ckey == PASTE) ckey = '9';
-        if (ckey == SAVE) {
-            ckey = 'S';
-            if (g_shift) ckey = 's';
-        } //save
-        if (ckey == LOAD) ckey = 'l';
-        if (ckey == NEW) ckey = 'o';
-        if (ckey == COPY || ckey == COPYALT) ckey = '4';
-        if (ckey == ALL) {
-            switcher(2);
-            g_bsourcex = 0;
-            g_bsourcey = 0;
-            g_bsourcex2 = X - 1;
-            g_bsourcey2 = Y - 1;
-            ckey = '9';
-            g_data[int('p')] = 0;
-            g_data[int('x')] = 0;
-            g_data[int('y')] = 0;
-            g_data[int('q')] = 0;
-            g_data[int('z')] = 0;
-            g_phase = 0;
-            g_rubbermode = 0;
-            set_tool(1);
+        switch (ckey)
+        {
+            case UNDO: ckey = g_shift ? 'U' : 'u'; break;
+            case REDO: ckey = 'U'; break;
+            case PASTE: ckey = '9'; break;
+            case SAVE: ckey = g_shift ? 's' : 'S'; break;
+            case LOAD: ckey = 'l'; break;
+            case NEW: ckey = 'o'; break;
+
+            case COPY:
+            case COPYALT: ckey = '4'; break;
+
+            case ALL:
+                switcher(2);
+                g_bsourcex = 0;
+                g_bsourcey = 0;
+                g_bsourcex2 = X - 1;
+                g_bsourcey2 = Y - 1;
+                ckey = '9';
+                g_data[int('p')] = 0;
+                g_data[int('x')] = 0;
+                g_data[int('y')] = 0;
+                g_data[int('q')] = 0;
+                g_data[int('z')] = 0;
+                g_phase = 0;
+                g_rubbermode = 0;
+                set_tool(1);
+                break;
         }
     }
 
-    if (ckey >= 128 && ckey <= 131) {
+    if (ckey >= 128 && ckey <= 131)
+    {
         g_bsize = ckey - 128;
         g_btype = 0;
     }
-
-    if (ckey >= 132 && ckey <= 135) {
+    else
+    if (ckey >= 132 && ckey <= 135)
+    {
         g_bsize = ckey - 132;
         g_btype = 1;
     }
-
-    if (ckey == ' ' || ckey == '.') {
-        if (ckey == '.') {
+    else
+    if (ckey == ' ' || ckey == '.')
+    {
+        if (ckey == '.')
+        {
             g_bsize = 0;
             g_btype = 0;
             g_data[int('n')] = 0;
         }
         ckey = '3';
-        if (ckey == ' ') {}
     }
-
+    else
     if (ckey == g_wheeldown)
         maghelper(-1);
     else
     if (ckey == g_wheelup)
         maghelper(1);
-
-    if (ckey == ',') {
+    else
+    if (ckey == ',')
+    {
         g_repanel = -2;
         do_tool(mouseX, mouseY, 255);
         do_tool(g_mx, g_my, 255);
         return;
     }
-
-    if (ckey == 'v') {
+    else
+    if (ckey == 'v')
+    {
         g_repanel = -2;
         // do_tool(mouseX,mouseY,254);
         do_tool(g_mx, g_my, 254);
         return;
     }
-
-    if (ckey == '[') {
+    else
+    if (ckey == '[')
+    {
         fixed_raster_command(int('x'));
         message("R.OFFSET " + str(g_raster_offset_x) + "." + str(g_raster_offset_y));
         g_repanel = -2;
         return;
     }
-    if (ckey == ']') {
+    else
+    if (ckey == ']')
+    {
         fixed_raster_command(int('y'));
         message("R.OFFSET " + str(g_raster_offset_x) + "." + str(g_raster_offset_y));
         g_repanel = -2;
         return;
     }
-    if (ckey == '(') {
+    else
+    if (ckey == '(')
+    {
         fixed_raster_command(int('p'));
         message("RASTER " + str(g_raster_no) + "/9|[=PREV|]=NEXT");
         g_repanel = -2;
         return;
     }
-
-    if (ckey == ')') {
+    else
+    if (ckey == ')')
+    {
         fixed_raster_command(int('n'));
         message("RASTER " + str(g_raster_no) + "/9|[=PREV|]=NEXT");
         g_repanel = -2;
         return;
     }
-
-    if (ckey == '>') {
+    else
+    if (ckey == '>')
+    {
         selectcolor(0, g_rgb[int(g_map[1])]);
         message("Current=Back");
         g_repanel = -2;
         return;
     }
-    if (ckey == '<') {
+    else
+    if (ckey == '<')
+    {
         g_repanel = -2;
         int swap = g_farge;
         g_farge = g_backg;
@@ -514,24 +530,29 @@
         g_realfront = byte(g_farge);
         g_realback = byte(g_backg);
     }
-
-    if (ckey == '0') {
-        if (g_data[int('m')] == 0 && g_data[int('M')] == 0) {
-            if (tool() != 0) {
+    else
+    if (ckey == '0')
+    {
+        if (g_data[int('m')] == 0 && g_data[int('M')] == 0)
+        {
+            if (tool() != 0)
                 g_prevtool = tool();
-            }
-        } else {
+        }
+        else
             ckey = 'm';
-        }
     }
-
-    if (ckey == '9') {
+    else
+    if (ckey == '9')
+    {
         g_repanel = -2;
         g_btype = 9;
         return;
     }
 
-    if (ckey >= '0' && ckey <= '8') {
+    // Intentional break in else -chain
+
+    if (ckey >= '0' && ckey <= '8')
+    {
         g_repanel = -2;
         set_tool(ckey - 48);
         g_phase = 0;
@@ -540,8 +561,12 @@
         g_ry = -1;
         g_rx2 = -1;
         g_ry2 = -1;
-        if (g_data[ckey] > 1) g_data[ckey] = 0;
-        if (ckey == '4') {
+
+        if (g_data[ckey] > 1)
+            g_data[ckey] = 0;
+
+        if (ckey == '4')
+        {
             g_data[int('x')] = 0;
             g_data[int('y')] = 0;
             g_data[int('h')] = 0;
@@ -551,7 +576,8 @@
         }
     }
 
-    if (ckey >= 'A' && ckey <= 'Z') {
+    if (ckey >= 'A' && ckey <= 'Z')
+    {
         g_repanel = -2;
         g_data[ckey]++;
         if (g_data[ckey] > 1) g_data[ckey] = 0;
@@ -584,35 +610,30 @@
             g_msgctr = 50;
         }
 
-        if (ckey == 'I') {
-            // message("sprites shitted");
-            //poopsprites();
-            // poopspecialsprites();
-        }
-
-        if (ckey == 'T') {
-            //   message("chars shitted");
-            //  poopultimachars();
-            //        poopsprites();
-        }
         if (ckey == 'G') {
             if (g_data[int('g')] == 0) g_data[int('g')] = 1;
         }
-        if (g_data[int('M')] == 0) g_boxreconstruct = 2;
 
-        if (g_data[int('M')] == 1) {
-            if (ckey == 'M') {
+        if (g_data[int('M')] == 0)
+            g_boxreconstruct = 2;
+        else
+        {
+            if (ckey == 'M')
+            {
                 g_ofx = int(g_storedcoordx / 8) - int(magx() / 2);
                 g_ofy = int(g_storedcoordy / 8) - int(magy() / 2);
                 g_data[int('m')] = 0;
                 message("Super|Magnify");
-                if (tool() == 0) {
+
+                if (tool() == 0)
+                {
                     set_tool(g_prevtool);
                     g_phase = 0;
                     g_rubbermode = 0;
                 }
             }
         }
+
         if (g_data[int('B')] == 1) {
             changeborder(LEFT);
             if (machine == MSX) g_data['C'] = 1;
@@ -797,12 +818,12 @@
         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++) {
-                g_farge = g_backg;
-                makepoint(xx, yy);
-                g_farge = g_ofarge;
-            }
+        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;
         }
     }