changeset 20:72407a4d9539

Cleanup / optimize.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 04 Jul 2018 10:08:35 +0300
parents 1fcc61b882f7
children 028b5ab1d98d
files draw_inputs.pde events.pde
diffstat 2 files changed, 5 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/draw_inputs.pde	Wed Jul 04 10:06:10 2018 +0300
+++ b/draw_inputs.pde	Wed Jul 04 10:08:35 2018 +0300
@@ -2,35 +2,29 @@
 // plus other passive manipulations
 
 int odd(int v) {
-    if ((v | 1) == v) return 1;
-    return 0;
+    return (v & 1);
 }
 
 int even(int v) {
-    if (v >> 1 == v) return 1;
-    return 0;
+    return 1 - (v & 1);
 }
 
 float getangel(float xx, float yy) {
     float ang = degrees(atan2(xx, -yy));
-    if (ang < 0) return 360 + ang;
-    return ang;
+    return (ang < 0) ? 360 + ang : ang;
 }
 
 int zxcolor(int col) {
     //something that allows different zx brightness colors treated logically as the same
     //i.e. bright red and dark red the same. handy for brush transparency
     if (g_britemode == 0) return col;
-    if (col > 7) return col - 8;
-    return col;
+    return (col > 7) ? col - 8 : col;
 }
 
 //the "slow" call to mark "dirty block"
 void updatepoint(int xx, int yy) {
     if (yy < 0 || xx < 0 || xx >= X || yy >= Y) return;
-    xx = int(xx / 8);
-    yy = int(yy / 8);
-    int ad = xx + yy * MX;
+    int ad = int(xx / 8) + int(yy / 8) * MX;
     g_redo[ad] = byte(0); //block update
     g_remdo[ad] = byte(1); //block update
 }
--- a/events.pde	Wed Jul 04 10:06:10 2018 +0300
+++ b/events.pde	Wed Jul 04 10:08:35 2018 +0300
@@ -633,7 +633,6 @@
 
         if (ckey == 'm') {
             if (g_data[int('M')] == 1) {
-                g_data[int('M')] = 0;
                 g_data[int('m')] = 0;
                 ckey = 0;
                 g_boxreconstruct = 2;