changeset 176:0940d991d3b0

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 23 Aug 2018 12:47:11 +0300
parents 3ddf4d799fe6
children 5e9ebac7e8e7
files events.pde multipaint.pde
diffstat 2 files changed, 43 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/events.pde	Thu Aug 23 12:38:52 2018 +0300
+++ b/events.pde	Thu Aug 23 12:47:11 2018 +0300
@@ -679,11 +679,14 @@
         refresh();
     }
 
-    if (ckey >= 'a' && ckey <= 'z') {
+    if (ckey >= 'a' && ckey <= 'z')
+    {
         g_repanel = -2;
         g_data[ckey]++;
-        if (g_data[ckey] > 1) {
-            if (ckey == 'm' || ckey == 'M') {
+        if (g_data[ckey] > 1)
+        {
+            if (ckey == 'm' || ckey == 'M')
+            {
                 g_boxreconstruct = 2;
                 g_data[int('M')] = 0;
                 g_data[int('m')] = 0;
--- a/multipaint.pde	Thu Aug 23 12:38:52 2018 +0300
+++ b/multipaint.pde	Thu Aug 23 12:47:11 2018 +0300
@@ -6,7 +6,8 @@
 //
 
 // Supported
-final int C64 = 0, MSX = 5, SPECTRUM = 6, C64M = 10, PLUS4 = 9, PLUS4M = 19, CPC = 2;
+final int C64 = 0, MSX = 5, SPECTRUM = 6, C64M = 10,
+    PLUS4 = 9, PLUS4M = 19, CPC = 2;
 
 // Experimental or incomplete
 final int C64NOLIMIT = 32; // Commodore 64 without attribute limitations
@@ -27,33 +28,17 @@
 final int NES = 90; // 8-bit NES
 final int SEGAM = 91; // 8-bit Sega Master System
 
+final int GRIDMODE_OLD = 0;
+final int GRIDMODE_NEW = 1;
+final int AR_FLAT = 1;
+final int AR_SQUARE = 0;
+
 final int PEESEE = 0, MACOSX = 1, PSJS = 2;
 final int COMMAND = 157; // Marq's cmd/ctrl solution
 
 int machine = -1; // change this to autoselect
 int platform = PSJS;
 
-int g_active, g_tooltrigger, g_prevtool, g_rband, g_rbang,
-    g_boxreconstruct, g_charlimit, g_animx, g_animy,
-    g_animframes, g_animno, g_animtime, g_animspeed, g_keymacpos;
-int g_wheelup = int(':'), g_wheeldown = int(';'), g_middlebutton = int(',');
-
-boolean g_control = false, g_shift = false, g_dirty, g_inhibit_aspect = false;
-
-String g_formatname, g_formatext,
-    filename = "", sfilename = "",
-    g_name, g_exportext = "",
-    g_exportname = "", g_keymacro = "",
-    g_forcedpalette = "";
-
-final int GRIDMODE_OLD = 0;
-final int GRIDMODE_NEW = 1;
-final int AR_FLAT = 1;
-final int AR_SQUARE = 0;
-int g_gridmode = GRIDMODE_OLD;
-int g_pixelw = 1;
-int g_aspect = AR_SQUARE;
-
 int[] g_grids = new int[16];
 
 int[] g_r = new int[266];
@@ -76,6 +61,24 @@
 
 byte g_realfront, g_realback;
 
+int g_tooltrigger, g_prevtool, g_rband, g_rbang, g_boxreconstruct,
+    g_charlimit, g_animx, g_animy, g_animframes, g_animno, g_animtime,
+    g_animspeed, g_keymacpos, g_forced_width, g_forced_height;
+
+int g_wheelup = int(':'), g_wheeldown = int(';'), g_middlebutton = int(',');
+int g_gridmode = GRIDMODE_OLD;
+int g_pixelw = 1;
+int g_aspect = AR_SQUARE;
+
+boolean g_control = false, g_shift = false,
+    g_dirty, g_inhibit_aspect = false;
+
+String g_formatname, g_formatext,
+    filename = "", sfilename = "",
+    g_name, g_exportext = "",
+    g_exportname = "", g_keymacro = "",
+    g_forced_palette = "";
+
 
 //dimensions
 int X, Y, MX, MY;
@@ -102,6 +105,11 @@
 
 void setup()
 {
+    // Get settings from Javascript runner, or use defaults
+    machine = (mpMachine >= 0) ? mpMachine : C64;
+    g_uizoom = (g_uizoom >= 1 && g_uizoom <= 3) ? g_uizoom : 2;
+    g_animspeed = 1;
+
     //normi
     g_magpix[0] = 3;
     g_magpix[1] = 8;
@@ -150,16 +158,7 @@
     g_magpiy[121] = 8;
     g_magpiy[122] = 14;
 
-    // Set up UI
-    g_uizoom = 2;
-    g_animspeed = 1;
-
-    // Get machine from Javascript runner, or default to C64
-    if (mpMachine)
-        machine = mpMachine;
-    else
-        machine = C64;
-
+    // Setup other stuff
     if (g_inhibit_aspect)
     {
         if (machine == QLLOW || machine == BK0010)
@@ -192,19 +191,17 @@
     g_multic = 0;
     g_repanel = -2;
 
-
     mpSetUIColors();
     mpSetupMachine(machine);
 
-    if (g_forcedpalette.length() > 3)
-        mpLoadPalette(g_forcedpalette);
+    if (g_forced_palette.length() > 3)
+        mpLoadPalette(g_forced_palette);
 
     int truwinsizex = X * g_magpix[magmode()];
     int truwinsizey = Y * g_magpiy[magmode()];
-/*
-    if (g_forcex == 0 || g_forcey == 0)
+
+    if (g_forced_width == 0 || g_forced_height == 0)
     {
-*/
         g_hadjust = 0;
         g_vadjust = 0;
 
@@ -218,12 +215,10 @@
             hsize += 2;
 
         size(hsize, vsize);
-/*
     }
 
-    if (g_forcex > 800 && g_forcey > 600)
-        size(g_forcex, g_forcey);
-*/
+    if (g_forced_width > 800 && g_forced_height > 600)
+        size(g_forced_width, g_forced_height);
 
     if (g_inhibit_aspect)
         g_aspect = AR_SQUARE;