changeset 135:72ae62f2036b

Cosmetic cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 08 Aug 2018 11:16:18 +0300
parents def42459c9a4
children 12cf30907f26
files .hgignore Interface.pde buffers.pde draw_outputs.pde draw_smart.pde events.pde multipaint.pde
diffstat 7 files changed, 141 insertions(+), 123 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Wed Aug 08 11:06:43 2018 +0300
+++ b/.hgignore	Wed Aug 08 11:16:18 2018 +0300
@@ -3,3 +3,4 @@
 *~
 *.orig
 *.diff
+new/
--- a/Interface.pde	Wed Aug 08 11:06:43 2018 +0300
+++ b/Interface.pde	Wed Aug 08 11:16:18 2018 +0300
@@ -457,9 +457,11 @@
 }
 
 
-void printat(int xx, int yy, String tex) {
+void printat(int xx, int yy, String tex)
+{
     //creating text into the help box
-    for (int tit = 0; tit < tex.length(); tit++) {
+    for (int tit = 0; tit < tex.length(); tit++)
+    {
         if (tex.charCodeAt(tit) != '|') {
             if (g_data[256 + xx + yy * 12] != byte(tex.charCodeAt(tit))) {
                 g_data[256 + xx + yy * 12] = byte(tex.charCodeAt(tit));
@@ -474,12 +476,13 @@
 }
 
 
-void clearmsg() {
-    for (int y = 0; y <= 3; y++) {
-        for (int x = 0; x <= 11; x++) {
-            g_data[256 + x + y * 12] = byte(32);
-            g_chaup[x + y * 16] = 1;
-        }
+void clearmsg()
+{
+    for (int y = 0; y < 4; y++)
+    for (int x = 0; x < 12; x++)
+    {
+        g_data[256 + x + y * 12] = byte(32);
+        g_chaup[x + y * 16] = 1;
     }
 }
 
@@ -496,10 +499,12 @@
 }
 
 
-void help(int mode, int xc, int yc) {
+void help(int mode, int xc, int yc)
+{
     String teks;
 
-    if (g_msgctr > 0) return;
+    if (g_msgctr > 0)
+        return;
 
     clearmsg();
 
@@ -719,7 +724,8 @@
 }
 
 
-void icontable(int xx, int yy, int tabletype, int realdraw) {
+void icontable(int xx, int yy, int tabletype, int realdraw)
+{
     String pan = "";
     int x, y, ad;
     g_data[int('9')] = 0;
@@ -813,8 +819,10 @@
 }
 
 
-int nextluminance(int f, int d) {
+int nextluminance(int f, int d)
+{
     int res = f + d;
+
     if (machine == PLUS4 || machine == PLUS4M) {
         if (f + d * 15 > 120) return f;
         if (f + d * 15 < 1) return f;
@@ -825,22 +833,9 @@
 
     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
+            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) {
@@ -853,22 +848,10 @@
 
     if (g_map[13] == MSX) {
         int out[] = {
-            1,
-            4,
-            9,
-            10,
-            6,
-            12,
-            13,
-            14,
-            5,
-            3,
-            7,
-            15,
-            2,
-            8,
-            11,
-            15
+            1,   4,  9, 10,
+            6,  12, 13, 14,
+            5,   3,  7, 15,
+            2,   8, 11, 15
         }; // calculated Y
         if (d == 1) res = out[f];
         if (d == -1) {
@@ -882,7 +865,8 @@
 }
 
 
-int tool() {
+int tool()
+{
     //returns the current tool #, for convenience
     //as there is no "tool" variable really
     for (int i = '0'; i <= '9'; i++) {
@@ -892,7 +876,8 @@
 }
 
 
-void set_tool(int s) {
+void set_tool(int s)
+{
     //set current tool, for convenience
     for (int i = '0'; i <= '9'; i++) {
         g_data[i] = 0;
@@ -902,7 +887,8 @@
 }
 
 
-void selectcolor(int hand, int x) {
+void selectcolor(int hand, int x)
+{
     if (x >= g_maxcolors) x = x - g_maxcolors;
     if (x < 0) x = x + g_maxcolors;
     if (hand == 0) {
@@ -920,19 +906,23 @@
 }
 
 
-void refresh() {
+void refresh()
+{
     g_dirty = true;
+
     //refreshes all "dirty chars" and icon panels
     for (int i = 0; i < MX * MY; i++) {
         g_redo[i] = byte(0);
         g_remdo[i] = byte(1);
     }
+
     if (g_boxreconstruct == 0) g_boxreconstruct = 1;
     //elsewhere use g_boxreconstruct=2 for complete window reconstruction
 }
 
 
-void refresh_all() {
+void refresh_all()
+{
     refresh();
     g_boxreconstruct = 2;
 }
@@ -980,21 +970,25 @@
 }
 
 
-void colorselector(int xo, int yo) {
+void colorselector(int xo, int yo)
+{
     int x, y, ad, yfat;
     int far, xonko, yhei, maxp, xloc, yloc;
     int bfat;
     float expand, divus;
+
     xonko = 16 * g_uizoom;
     yhei = 16 * g_uizoom;
     expand = 1;
     yfat = 4 * g_uizoom;
     bfat = 1 * g_uizoom;
+
     if (g_maxcolors > 60) {
         yhei = 4 * g_uizoom;
         yfat = 0;
         bfat = 1;
     }
+
     divus = 255 / g_palsteps;
     x = 0;
     y = 0;
@@ -1008,13 +1002,17 @@
         xonko = int(1024 / g_maxcolors);
     }
 
-    if (machine == PLUS4 || machine == PLUS4M) xonko = 15 * g_uizoom;
+    if (machine == PLUS4 || machine == PLUS4M)
+        xonko = 15 * g_uizoom;
 
-    for (x = 0; x < g_maxcolors; x++) {
+    for (x = 0; x < g_maxcolors; x++)
+    {
         xloc = xo + x * xonko;
         yloc = yo + 8 * g_uizoom;
-        if (g_maxcolors > 60) {
+        if (g_maxcolors > 60)
+        {
             yloc = yo + yhei * 7;
+
             if (x > 15 && x <= 30) {
                 xloc = xo + (x - 15) * xonko;
                 yloc = yo + yhei * 6 + yfat * 2;
@@ -1104,23 +1102,24 @@
 }
 
 
-void messagebox(int ox, int oy) {
-    int cz = 8 * g_uizoom;
+void messagebox(int ox, int oy)
+{
     // lcd character display chardisplay textbox
     // coordinates. has its own "dirtychar"
-
-    for (int xx = 0; xx <= 11; xx++) {
-        for (int yy = 0; yy <= 3; yy++) {
-            if (g_chaup[xx + yy * 16] == 1) {
-                g_chaup[xx + yy * 16] = 0;
-                drawchar(ox + xx * cz, oy + yy * cz, g_data[256 + xx + yy * 12]);
-            }
+    int cz = 8 * g_uizoom;
+    for (int xx = 0; xx < 12; xx++)
+    for (int yy = 0; yy < 4; yy++)
+    {
+        if (g_chaup[xx + yy * 16] == 1) {
+            g_chaup[xx + yy * 16] = 0;
+            drawchar(ox + xx * cz, oy + yy * cz, g_data[256 + xx + yy * 12]);
         }
     }
 }
 
 
-void colorindicator(int ox, int oy) {
+void colorindicator(int ox, int oy)
+{
     int bs = 8 * g_uizoom;
     int h = 0;
     if (g_button == RIGHT) h = 1;
--- a/buffers.pde	Wed Aug 08 11:06:43 2018 +0300
+++ b/buffers.pde	Wed Aug 08 11:16:18 2018 +0300
@@ -102,12 +102,12 @@
 }
 
 
-void switcher(int di)
+void switcher(int mode)
 {
     // this achieves varieties of whole screen copying
     // needed for brush copy and pre-drawing the shapes when a
     // tool is active etc.
-    switch (di)
+    switch (mode)
     {
         case 0:
             arrayCopy(g_map, g_rmap);
--- a/draw_outputs.pde	Wed Aug 08 11:06:43 2018 +0300
+++ b/draw_outputs.pde	Wed Aug 08 11:16:18 2018 +0300
@@ -957,11 +957,13 @@
     }
 }
 
-void do_tool(int qqx, int qqy, int mb) {
-    int tt, ox, oy, psizex, psizey;
-    tt = tool();
-    psizex = g_magpix[magmode()];
-    psizey = g_magpiy[magmode()];
+
+void do_tool(int qqx, int qqy, int mbut)
+{
+    int ox, oy;
+    int tt = tool(),
+        psizex = g_magpix[magmode()],
+        psizey = g_magpiy[magmode()];
 
     //handles different tool behavior
     if (g_data[int('m')] == 0 && g_data[int('M')] == 0) {
@@ -988,7 +990,6 @@
         y = int(qqy);
     }
 
-
     ox = x;
     oy = y;
     g_storedcoordx = x;
@@ -998,7 +999,7 @@
     int midy = 0;
     //brush handle mid point
     //some tools are exempted
-    if (g_btype == 9 && tool() != 4 && tool() != 0 && mb != 255) {
+    if (g_btype == 9 && tool() != 4 && tool() != 0 && mbut != 255) {
         midx = int((g_bsourcex2 - g_bsourcex) / 2);
         midy = int((g_bsourcey2 - g_bsourcey) / 2);
         x = x - midx;
@@ -1014,13 +1015,14 @@
         ox = chop2(ox);
     }
 
-    if (mb == 254) { //block picker
+    if (mbut == 254) { //block picker
         switcher(2);
         g_data[int('n')] = 0;
         g_data[int('x')] = 0;
         g_data[int('y')] = 0;
         g_data[int('q')] = 0;
         g_data[int('z')] = 0;
+
         x = int(ox / g_gridx) * g_gridx;
         y = int(oy / g_gridy) * g_gridy;
 
@@ -1033,7 +1035,7 @@
         return;
     }
 
-    if (mb == 255) { // color picker
+    if (mbut == 255) { // color picker
         if (g_multic == 2) {
             if (g_hzoomer == 2) {
                 ox = chop2(ox);
@@ -1068,7 +1070,7 @@
         for (int i = 0; i <= 12; i++) {
             int rx = x - 10 + int(random((10) * 2));
             int ry = y - 10 + int(random((10) * 2));
-            if (mb == LEFT) {
+            if (mbut == LEFT) {
                 if (dist(x, y, rx, ry) < 10) craft(rx, ry, 0);
             } else {
                 if (dist(x, y, rx, ry) < 10) craft(rx, ry, 0);
@@ -1095,12 +1097,13 @@
             g_data[int('Y')] = 0;
             g_data[int('c')] = 0;
             g_data[int('t')] = 0;
+
             if (ox >= 0 && ox < X && oy >= 0 & oy < Y) {
                 store_undo(); // exceptional!
                 if (g_multic)
-                    floodfill_mc(ox, oy, mb);
+                    floodfill_mc(ox, oy, mbut);
                 else
-                    floodfill_iq(ox, oy, mb);
+                    floodfill_iq(ox, oy, mbut);
             }
             restoreparameters();
         }
--- a/draw_smart.pde	Wed Aug 08 11:06:43 2018 +0300
+++ b/draw_smart.pde	Wed Aug 08 11:16:18 2018 +0300
@@ -1,7 +1,8 @@
 //all "intelligent" stuff, the color behavior
 //and flood fills
 
-void consistency() {
+void consistency()
+{
     int xx, yy, ad, a, b, x0, y0, x2, y2;
     int pat, mat, fad, bad, maxxy, mulu, ymax;
 
@@ -54,7 +55,8 @@
 }
 
 
-void transchar(int xx, int yy) {
+void transchar(int xx, int yy)
+{
     int fad, bad, ad, pt, x0, y0;
     int aa, bb, pp, ya, yb;
 
@@ -94,8 +96,8 @@
 }
 
 
-void prepare_char(int xx, int yy, int farbe) {
-
+void prepare_char(int xx, int yy, int farbe)
+{
     //changes the char foreg/backg into "favorable" relative to used color
     //needed in floodfill
 
@@ -135,17 +137,18 @@
 }
 
 
-void floodfill_mc(int xx, int yy, int mou) {
+void floodfill_mc(int xx, int yy, int mbut)
+{
     int x, y, ax, valid, okay, par, npar, zad;
     par = 0;
 
     if (g_pixelw == 2)
         xx = chop2(xx);
 
-    if (mou == LEFT)
+    if (mbut == LEFT)
         par = g_farge;
     else
-    if (mou == RIGHT)
+    if (mbut == RIGHT)
         par = g_backg;
 
     npar = getmultic(xx, yy, 0);
@@ -219,15 +222,15 @@
 }
 
 
-void floodfill_iq(int xx, int yy, int mou)
+void floodfill_iq(int xx, int yy, int mbut)
 {
     int x, y, ax, ay, valid, okay, par, npar, zad;
     par = 0;
 
-    if (mou == LEFT)
+    if (mbut == LEFT)
         par = g_farge;
     else
-    if (mou == RIGHT)
+    if (mbut == RIGHT)
         par = g_backg;
 
     npar = getabsa(xx, yy, 0);
@@ -359,8 +362,11 @@
     targetbit1 = 0;
     suffocatelimit = 7;
 
+    if (g_multic == 2) return;
+
     f = getmultic(x, y, 0);
-    if (g_data[int('d')] == 1 && f != g_backg) return;
+    if (g_data[int('d')] == 1 && f != g_backg)
+        return;
 
     cad = 65536 + mx + (my * MX);
 
@@ -559,16 +565,17 @@
 }
 
 
-void kaveri(int x, int y, int foreg, int backg) {
-    int k_max;
-    int maxy, miny;
-    int ad, bad, cad;
-    int mx, my, val;
+void kaveri(int x, int y, int foreg, int backg)
+{
+    if (g_multic == 2)
+        return;
+    if (g_multic != 0 || g_hzoomer == 2 || g_data[int('d')] == 1)
+        return;
+
+    int k_max, maxy, miny, val, ad, bad, cad;
     int farge0, farge1;
-    if (g_multic != 0 || g_hzoomer == 2) return;
-    if (g_data[int('d')] == 1) return;
-    mx = int(x / 8);
-    my = int(y / 8);
+    int mx = int(x / 8);
+    int my = int(y / 8);
 
     if (g_attrimode == 1) {
         k_max = 64;
@@ -581,23 +588,26 @@
         miny = maxy;
     }
 
-    if (g_britemode == 1 && foreg == 8) foreg = 0;
+    if (g_britemode == 1 && foreg == 8)
+        foreg = 0;
 
     //check the amount of colors in the area
     //if there is only one, return & draw "normally"
 
-    if (g_control == false) {
-
+    if (!g_control)
+    {
         val = 0;
 
-        for (int yy = miny; yy <= maxy; yy++) {
+        for (int yy = miny; yy <= maxy; yy++)
+        {
             ad = 1024 + (mx * 8) + (my * 8 + yy) * X;
             for (int xx = 0; xx <= 7; xx++) {
                 val = val + g_map[ad + xx];
             }
         }
 
-        if (val >= k_max || val == 0) return;
+        if (val >= k_max || val == 0)
+            return;
 
         //check the two colors the color area is made of
         //if either of the intended color already exists inside the color area, return & draw "normally"
@@ -693,12 +703,11 @@
 
 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;
+    int k_c1, k_c2, k_v0, k_v1, k_tipping, k_maximum, exist;
     byte k_p;
 
-    if (g_multic != 0 || g_hzoomer == 2) return;
-
-    int exist;
+    if (g_multic != 0 || g_hzoomer == 2)
+        return;
 
     exist = getabsa(x, y, 0);
 
--- a/events.pde	Wed Aug 08 11:06:43 2018 +0300
+++ b/events.pde	Wed Aug 08 11:16:18 2018 +0300
@@ -7,7 +7,8 @@
 }
 
 
-void keyPressed() {
+void keyPressed()
+{
     g_dirty = true;
     if (key == ESC)
     {
@@ -37,7 +38,8 @@
 
         refresh();
 
-        if (platform == MACOSX) {
+        if (platform == MACOSX)
+        {
             if (keyCode == COMMAND)
                 g_control = true;
         } else {
@@ -54,8 +56,10 @@
 }
 
 
-void keyReleased() {
-    if (key == CODED) {
+void keyReleased()
+{
+    if (key == CODED)
+    {
         if (keyCode == CONTROL) g_control = false;
         if (keyCode == SHIFT) g_shift = false;
         if (platform == MACOSX) {
@@ -68,7 +72,8 @@
     }
 }
 
-void mouseMoved() {
+void mouseMoved()
+{
     g_dirty = true;
 
     if (moicon(16 * 16 * g_uizoom, height - 32 * g_uizoom, 16 * g_uizoom, 24 * g_uizoom)) help(int('<'));
@@ -78,7 +83,8 @@
 }
 
 
-void mouseDragged() {
+void mouseDragged()
+{
     int msx, msy;
 
     mouseMoved();
@@ -123,7 +129,8 @@
 }
 
 
-void mousePressed() {
+void mousePressed()
+{
     int msx, msy;
 
     g_dirty = true;
@@ -143,8 +150,9 @@
             g_iconx = -1;
             g_icony = -1;
         }
-        return;
-    } else {
+    }
+    else
+    {
         g_msx = g_iconx;
         g_msy = g_icony;
         if (g_data[int('m')] == 0 && g_data[int('M')] == 0) {
@@ -167,6 +175,7 @@
             g_repanel = -2;
             if (g_shift) g_button = 254;
         }
+
         g_phase = 0;
         do_tool(msx, msy, g_button);
         g_phase = 1;
@@ -174,9 +183,8 @@
 }
 
 
-void mouseReleased() {
-    int swap;
-
+void mouseReleased()
+{
     g_dirty = true;
 
     g_tooltrigger = 0;
@@ -261,8 +269,6 @@
 }
 
 void command(int ckey) {
-    int swap;
-
     g_dirty = true;
 
     //keypresses change g_data[] values directly as 1/0 switches
@@ -417,7 +423,7 @@
     }
     if (ckey == '<') {
         g_repanel = -2;
-        swap = g_farge;
+        int swap = g_farge;
         g_farge = g_backg;
         g_ofarge = g_farge;
         g_backg = swap;
--- a/multipaint.pde	Wed Aug 08 11:06:43 2018 +0300
+++ b/multipaint.pde	Wed Aug 08 11:16:18 2018 +0300
@@ -481,7 +481,7 @@
     }
 
     // Tool drawing for shows
-    int lipo = g_button;
+    int savebut = g_button;
     if (tool() != 5)
     {
         if (g_phase == 0)
@@ -491,7 +491,7 @@
     if (tool() == 6) doline(g_rx, g_ry, g_rx2, g_ry2, 0);
     if (tool() == 7) docircle(g_rx, g_ry, g_rx2, g_ry2);
     if (tool() == 8) rectangle(g_rx, g_ry, g_rx2, g_ry2);
-    g_button = lipo;
+    g_button = savebut;
 
     // Screen update stuff
     loadPixels();