changeset 179:934934bb1fbb

Rename global variable s/machine/g_machine/g
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 23 Aug 2018 13:11:47 +0300
parents 66c1d15e335a
children 48bb77ae9f40
files draw_inputs.pde draw_outputs.pde draw_smart.pde events.pde exporters.pde interface.pde mpui.js multipaint.pde
diffstat 8 files changed, 95 insertions(+), 94 deletions(-) [+]
line wrap: on
line diff
--- a/draw_inputs.pde	Thu Aug 23 13:08:34 2018 +0300
+++ b/draw_inputs.pde	Thu Aug 23 13:11:47 2018 +0300
@@ -60,7 +60,7 @@
         case 2:
             return g_brush[looks + 1000];
         case 3:
-            if (machine == PLUS4M) return int(g_map[2]);
+            if (g_machine == PLUS4M) return int(g_map[2]);
             return g_brush[looks + 2000];
     }
     return g_brush[ad] + g_brush[ad + 1] * 2;
@@ -117,7 +117,7 @@
             case 2:
                 return g_map[looks + 1000];
             case 3:
-                if (machine == PLUS4M) return int(g_map[2]);
+                if (g_machine == PLUS4M) return int(g_map[2]);
                 return g_map[looks + 2000];
         }
     }
@@ -133,7 +133,7 @@
             case 2:
                 return g_brush[looks + 1000];
             case 3:
-                if (machine == PLUS4M) return int(g_map[2]);
+                if (g_machine == PLUS4M) return int(g_map[2]);
                 return g_brush[looks + 2000];
         }
     }
--- a/draw_outputs.pde	Thu Aug 23 13:08:34 2018 +0300
+++ b/draw_outputs.pde	Thu Aug 23 13:11:47 2018 +0300
@@ -627,7 +627,7 @@
         switch (g_multic) {
             case 0: //1-bit + attribute i.e. spectrum
                 fari = g_farge;
-                if (machine == MSX && fari == int(g_map[1])) fari = 0;
+                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]) {
@@ -691,7 +691,7 @@
                     g_map[1024 + xx + yy * X + 1] = byte(0);
                     cut = true;
                 }
-                if (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;
@@ -743,8 +743,8 @@
                         if (pars == 1) fars[1] = int(g_map[looks]);
                         if (pars == 2) fars[2] = int(g_map[looks + 1000]);
                         if (pars == 3) {
-                            if (machine == C64M) fars[3] = int(g_map[looks + 2000]);
-                            if (machine == PLUS4M) fars[3] = zeroc2;
+                            if (g_machine == C64M) fars[3] = int(g_map[looks + 2000]);
+                            if (g_machine == PLUS4M) fars[3] = zeroc2;
                         }
                         saps = saps + 2;
                     }
@@ -763,7 +763,7 @@
                 if (skippo == 0) {
                     int okay = 0;
                     metamax = 3;
-                    if (machine == PLUS4M) metamax = 2;
+                    if (g_machine == PLUS4M) metamax = 2;
 
                     // if the color is already in the 4x8 area?
 
@@ -783,8 +783,8 @@
                                 if (metay == 3) {
                                     bit1 = 1;
                                     bit2 = 1;
-                                    if (machine == C64M) g_map[looks + 2000] = byte(fari);
-                                    if (machine == PLUS4M) g_map[looks + 2000] = byte(zeroc2);
+                                    if (g_machine == C64M) g_map[looks + 2000] = byte(fari);
+                                    if (g_machine == PLUS4M) g_map[looks + 2000] = byte(zeroc2);
                                 }
                                 g_map[1024 + xx + yy * X] = bit1;
                                 g_map[1024 + xx + yy * X + 1] = bit2;
@@ -814,8 +814,8 @@
                                 if (metay == 3) {
                                     bit1 = 1;
                                     bit2 = 1;
-                                    if (machine == C64M) g_map[looks + 2000] = byte(fari);
-                                    if (machine == PLUS4M) g_map[looks + 2000] = byte(zeroc2);
+                                    if (g_machine == C64M) g_map[looks + 2000] = byte(fari);
+                                    if (g_machine == PLUS4M) g_map[looks + 2000] = byte(zeroc2);
                                 }
                                 g_map[1024 + xx + yy * X] = bit1;
                                 g_map[1024 + xx + yy * X + 1] = bit2;
--- a/draw_smart.pde	Thu Aug 23 13:08:34 2018 +0300
+++ b/draw_smart.pde	Thu Aug 23 13:11:47 2018 +0300
@@ -111,8 +111,8 @@
 
 void changeborder(int mbut)
 {
-    if (machine == MSX || machine == QLLOW || machine == AMIGA ||
-        machine == PICO8 || machine == BK0010 || machine == COCO3)
+    if (g_machine == MSX || g_machine == QLLOW || g_machine == AMIGA ||
+        g_machine == PICO8 || g_machine == BK0010 || g_machine == COCO3)
         return;
 
     int par = g_farge;
@@ -395,7 +395,7 @@
     free2 = 1;
     f3 = int(g_map[cad + 2000]);
     free3 = 1;
-    if (machine == PLUS4M) {
+    if (g_machine == PLUS4M) {
         free3 = 0;
         suffocatelimit = 3;
         f3 = int(g_map[2]);
@@ -421,7 +421,7 @@
                     if (f2 == f) order = 2;
                 }
                 if (g_map[ad] == 1 && g_map[ad + 1] == 1) { //03 = 11
-                    if (machine == C64M) {
+                    if (g_machine == C64M) {
                         numb = numb | 4;
                         free3 = 0;
                     }
@@ -436,7 +436,7 @@
 
         boolean zoink = false;
         if (order == 4) zoink = true;
-        if (order == 3 && machine == PLUS4M) zoink = true;
+        if (order == 3 && g_machine == PLUS4M) zoink = true;
 
         if ((zoink || numb != suffocatelimit) && g_control == true) {
             if (zoink) {
@@ -451,11 +451,11 @@
                     b0 = 0;
                     b1 = 1;
                 }
-                if (foreg == f3 && machine == C64M && free3 == 0) {
+                if (foreg == f3 && g_machine == C64M && free3 == 0) {
                     b0 = 1;
                     b1 = 1;
                 }
-                if (foreg == f3 && machine == PLUS4M) {
+                if (foreg == f3 && g_machine == PLUS4M) {
                     b0 = 1;
                     b1 = 1;
                 }
@@ -502,7 +502,7 @@
             if (order == 2) {
                 g_map[cad + 1000] = byte(foreg);
             } //01==2
-            if (order == 3 && machine == C64M) {
+            if (order == 3 && g_machine == C64M) {
                 g_map[cad + 2000] = byte(foreg);
             } //11==3
         }
@@ -513,7 +513,7 @@
             for (int xx = 0; xx <= 3; xx++) {
                 ad = 1024 + (mx * 8 + xx * 2) + (my * 8 + yy) * X;
 
-                if (machine == C64M) {
+                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;
@@ -547,7 +547,7 @@
                     }
                 }
 
-                if (machine == PLUS4M) {
+                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;
@@ -568,7 +568,7 @@
                     }
                 }
 
-                if (machine == C64M) {
+                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;
--- a/events.pde	Thu Aug 23 13:08:34 2018 +0300
+++ b/events.pde	Thu Aug 23 13:11:47 2018 +0300
@@ -636,21 +636,22 @@
 
         if (g_data[int('B')] == 1) {
             changeborder(LEFT);
-            if (machine == MSX) g_data['C'] = 1;
+            if (g_machine == MSX)
+                g_data[int('C')] = 1;
         }
 
         if (g_data[int('C')] == 1) {
             g_data[int('C')] = 0;
             if (int(g_map[1]) != 255) {
                 store_undo();
-                if (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 (machine == MSX) {
+                if (g_machine == MSX) {
                     g_map[0] = byte(g_farge);
                     sussborder();
                 }
@@ -661,7 +662,7 @@
             g_data[int('V')] = 0;
             if (int(g_map[1]) != 255) {
                 store_undo();
-                if (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;
@@ -888,7 +889,7 @@
         refresh();
     }
 
-    if (machine == SPECTRUM) {
+    if (g_machine == SPECTRUM) {
         if (g_data[int('i')] == 1)
         {
             g_data[int('i')] = 0;
@@ -1032,7 +1033,7 @@
             {
                 var fdata = mpGetNativeImage();
                 var fstr = JSON.stringify(fdata);
-                localStorage.setItem("MPIMAGE_DATA"+ str(machine), fstr);
+                localStorage.setItem("MPIMAGE_DATA"+ str(g_machine), fstr);
                 message("Saved to lstorage");
             }
             catch (err)
@@ -1051,7 +1052,7 @@
         {
             try
             {
-                var fstr = localStorage.getItem("MPIMAGE_DATA"+ str(machine));
+                var fstr = localStorage.getItem("MPIMAGE_DATA"+ str(g_machine));
                 var fdata = JSON.parse(fstr);
                 if (typeof(fdata) == "object" &&
                     Array.isArray(fdata))
--- a/exporters.pde	Thu Aug 23 13:08:34 2018 +0300
+++ b/exporters.pde	Thu Aug 23 13:11:47 2018 +0300
@@ -196,7 +196,7 @@
 
     head = 0;
 
-    if (machine == SPECTRUM) //SCR=SCREEN$
+    if (g_machine == SPECTRUM) //SCR=SCREEN$
     {
         // 32*24*8 bytes of bitmap
         // 32*24 bytes of attributes
@@ -234,7 +234,7 @@
         }
     }
     else
-    if (machine == C64) {
+    if (g_machine == C64) {
         //0x0002->bitmap
         //0x1f42->colormap
         //0x232a=border (take the lower nybble)
@@ -259,7 +259,7 @@
         }
     }
     else
-    if (machine == PLUS4) { // Botticelli
+    if (g_machine == PLUS4) { // Botticelli
         //g.hires.prg = botticelli
         //2 - luminance 40*25
         //1026 - colors 40*25
@@ -286,7 +286,7 @@
         }
     }
     else
-    if (machine == PLUS4M) { // Multi Botticelli
+    if (g_machine == PLUS4M) { // Multi Botticelli
         //m.multi.prg = multi botticelli
         //2- lumins 40*25
         //1024 - bäkki1
@@ -323,7 +323,7 @@
         g_map[2] = byte(convertluminance(l1, p1));
     }
     else
-    if (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)
@@ -353,7 +353,7 @@
         g_map[1] = byte(fdata[0x232b] & 0x0f); //baku
     }
     else
-    if (machine == MSX) { // sc2
+    if (g_machine == MSX) { // sc2
         // 7=bitmap 32*24*8
         // 7+(32*24*8)=colormap 32*24
         if (fdata.length < 14343) {
@@ -379,7 +379,7 @@
         }
     }
     else
-    if (machine == CPC) { // a studio?
+    if (g_machine == CPC) { // a studio?
         return false;
     }
 
@@ -395,7 +395,7 @@
     int val1, val2, val3;
     int y, y2, yy, x, yp, xp, ad, valu, valu2, bri;
 
-    if (machine == PLUS4) { // botticelli hires
+    if (g_machine == PLUS4) { // botticelli hires
         ctx.loadTemplate("g.hires.prg");
 
         ctx.setOffs(0x02);
@@ -408,7 +408,7 @@
         mpExportBitmapData(ctx, 40, 25);
     }
     else
-    if (machine == PLUS4M) { // multi botticelli multicolor
+    if (g_machine == PLUS4M) { // multi botticelli multicolor
         ctx.loadTemplate("m.multi.prg");
 
         val2 = getpluscolor(int(g_map[1]));
@@ -431,7 +431,7 @@
         mpExportBitmapData(ctx, 40, 25);
     }
     else
-    if (machine == C64) {
+    if (g_machine == C64) {
         ctx.loadTemplate("hires.art");
 
         ctx.setOffs(2);
@@ -443,7 +443,7 @@
         ctx.writeByteAt(0x232a, g_map[0]);
     }
     else
-    if (machine == C64M) {
+    if (g_machine == C64M) {
         if (subformat == 0)
         {
             // Advanced Art Studio
@@ -479,7 +479,7 @@
         }
     }
     else
-    if (machine == MSX) {
+    if (g_machine == MSX) {
         ctx.loadTemplate("msx-screen2.sc2");
 
         ctx.setOffs(7);
@@ -489,7 +489,7 @@
         mpExportColorData(ctx, 32, 24, 65536, 3); //there's an exception for msx-style
     }
     else
-    if (machine == SPECTRUM) {
+    if (g_machine == SPECTRUM) {
         ctx.loadTemplate("zx-screen.scr");
 
         ctx.setOffs(0);
@@ -544,9 +544,9 @@
 boolean mpExportMachinePRG(MPWriteCtx ctx)
 {
     // any common text headers
-    ctx.addComment("machine=" + str(machine) + " (" + g_name + ")");
+    ctx.addComment("g_machine=" + str(g_machine) + " (" + g_name + ")");
 
-    if (machine == C64) { //C64 HIRES
+    if (g_machine == C64) { //C64 HIRES
         ctx.loadTemplate("c64show.prg");
 
         ctx.setOffs(0x0227);
@@ -567,7 +567,7 @@
         //0x2169->värikartta (40x25 bytee, nyppelit foreg/backg)
     }
     else
-    if (machine == C64M) { //C64 MULTICOLOR
+    if (g_machine == C64M) { //C64 MULTICOLOR
         ctx.loadTemplate("c64mshow.prg");
 
         ctx.setOffs(0x0239);
@@ -596,7 +596,7 @@
         //0x2563->värikartta 2 (40x25 bytee, nyppeli 3-väri nepan osoitteessa $d800-)
     }
     else
-    if (machine == PLUS4M) { //PLUS4 MULTICOLOR
+    if (g_machine == PLUS4M) { //PLUS4 MULTICOLOR
         ctx.loadTemplate("showpfourm.prg");
 
         ctx.addLine(".global @@_bitmap");
@@ -648,7 +648,7 @@
         //0x2469 luminance (40 x 25)
     }
     else
-    if (machine == PLUS4) { // Plus 4 hires
+    if (g_machine == PLUS4) { // Plus 4 hires
         ctx.loadTemplate("showpfour.prg");
 
         ctx.addLine(".global @@_bitmap");
@@ -680,7 +680,7 @@
         //0x2460   luminance (40 x 25)
     }
     else
-    if (machine == MSX) { // MSX
+    if (g_machine == MSX) { // MSX
         ctx.loadTemplate("msxshow.com");
 
         ctx.addLine(".globl @@_bitmap,@@_nimi2");
@@ -703,7 +703,7 @@
         //0x18fa colors (32*24 bytes)
     }
     else
-    if (machine == SPECTRUM) { // ZX Spectrum
+    if (g_machine == SPECTRUM) { // ZX Spectrum
 
         //would need some cleaning up
 
@@ -776,7 +776,7 @@
         ctx.writeByteAt(0x1d3e, int(checksum), "_checksum");
     }
     else
-    if (machine == CPC) {
+    if (g_machine == CPC) {
         int val1, val2, val3, valu;
         ctx.loadTemplate("cpc-mode0.bin");
 
@@ -963,7 +963,7 @@
     else
         xmult = width;
 
-    if (machine == MSX) {
+    if (g_machine == MSX) {
         myrpsi = 7;
     }
 
@@ -1282,7 +1282,7 @@
             f = easygetcolor(xx, yy);
 //            f = getabsa(xx, yy, 0);
 
-        if (machine == MSX && f == 0)
+        if (g_machine == MSX && f == 0)
             f = g_map[1];
 
         color c = color(g_r[f], g_g[f], g_b[f]);
@@ -1634,7 +1634,7 @@
 
 void mpSetupMachine(int m)
 {
-    machine = m;
+    g_machine = m;
 
     g_name = "ERROR";
     g_exportext = "none";
@@ -1646,8 +1646,8 @@
 
     g_aspect = AR_SQUARE;
 
-    g_map[3] = byte(machine);
-    g_map[13] = byte(machine);
+    g_map[3] = byte(g_machine);
+    g_map[13] = byte(g_machine);
     g_palsteps = 0;
     g_farge = 1;
     g_backg = 0;
@@ -1659,7 +1659,7 @@
     X = 320;
     Y = 200;
 
-    if (machine == C64)
+    if (g_machine == C64)
     {
         //c64 hires
         g_name = "c64";
@@ -1674,7 +1674,7 @@
         make_c64_palette();
     }
     else
-    if (machine == CPC)
+    if (g_machine == CPC)
     {
         //Amstrad CPC mode 0
         g_name = "cpc";
@@ -1708,7 +1708,7 @@
         makecolor(15, 0xFF, 0xFF, 0xFF);
     }
     else
-    if (machine == MSX)
+    if (g_machine == MSX)
     {
         // MSX
         g_name = "msx";
@@ -1749,7 +1749,7 @@
         make_msx_palette();
     }
     else
-    if (machine == SPECTRUM)
+    if (g_machine == SPECTRUM)
     {
         // ZX Spectrum
         g_name = "spec";
@@ -1769,7 +1769,7 @@
         make_spectrum_palette();
     }
     else
-    if (machine == TIMEX)
+    if (g_machine == TIMEX)
     {
         // timex sinclair
         g_name = "tmx";
@@ -1784,7 +1784,7 @@
         make_spectrum_palette();
     }
     else
-    if (machine == JR200)
+    if (g_machine == JR200)
     {
         // Panasonic JR200
         g_name = "jr200";
@@ -1799,7 +1799,7 @@
         make_spectrum_palette(); //cheating
     }
     else
-    if (machine == PLUS4M || machine == PLUS4)
+    if (g_machine == PLUS4M || g_machine == PLUS4)
     {
         // Commodore plus/4
         g_name = "plus4m";
@@ -1818,7 +1818,7 @@
         g_map[2] = 61;
         g_farge = 61;
 
-        if (machine == PLUS4)
+        if (g_machine == PLUS4)
         {
             // plus/4 hires
             g_name = "plus4";
@@ -1833,7 +1833,7 @@
         make_plus4_palette();
     }
     else
-    if (machine == C64M)
+    if (g_machine == C64M)
     {
         //c64 multicolor
         g_name = "c64m";
@@ -1851,7 +1851,7 @@
         make_c64_palette();
     }
     else
-    if (machine == QLLOW)
+    if (g_machine == QLLOW)
     {
         // Sinclair QL low
         g_backmode = 0;
@@ -1866,7 +1866,7 @@
         make_ql_palette();
     }
     else
-    if (machine == BK0010)
+    if (g_machine == BK0010)
     {
         // BK0010 patch
         g_backmode = 0;
@@ -1881,7 +1881,7 @@
         make_bk_palette();
     }
     else
-    if (machine == AMIGA)
+    if (g_machine == AMIGA)
     {
         g_name = "amiga";
         g_exportext = "";
@@ -1905,7 +1905,7 @@
         }
     }
     else
-    if (machine == ATARIST)
+    if (g_machine == ATARIST)
     {
         //ATARI ST 512 color
         g_name = "st";
@@ -1928,7 +1928,7 @@
         }
     }
     else
-    if (machine == C64FLI)
+    if (g_machine == C64FLI)
     {
         //c64 hires FLI = AFLI
         g_name = "afli";
@@ -1943,7 +1943,7 @@
         make_c64_palette();
     }
     else
-    if (machine == C64FLIM)
+    if (g_machine == C64FLIM)
     {
         //C64 FLI multicolor
         g_name = "fli";
@@ -1961,7 +1961,7 @@
         make_c64_palette();
     }
     else
-    if (machine == C64NOLIMIT)
+    if (g_machine == C64NOLIMIT)
     {
         g_name = "c64hino";
         g_exportext = "";
@@ -1978,7 +1978,7 @@
         make_c64_palette();
     }
     else
-    if (machine == PICO8)
+    if (g_machine == PICO8)
     {
         // Pico-8 fantasy console
         g_name = "pico8";
@@ -2011,7 +2011,7 @@
         makecolor(15, 255, 214, 197);
     }
     else
-    if (machine == COCO3)
+    if (g_machine == COCO3)
     {
         //6-bit RGB, 16 out of 64 possible
         g_name = "coco";
@@ -2029,7 +2029,7 @@
         make_coco_palette();
     }
     else
-    if (machine == UNIA)
+    if (g_machine == UNIA)
     {
         // Unia digital palette
         g_name = "unia";
--- a/interface.pde	Thu Aug 23 13:08:34 2018 +0300
+++ b/interface.pde	Thu Aug 23 13:11:47 2018 +0300
@@ -668,7 +668,7 @@
             break;
         case 'C':
             teks = "Set backgnd";
-            if (machine == PLUS4M || machine == PLUS4) teks = "Set backgnd|V/RMB=back2";
+            if (g_machine == PLUS4M || g_machine == PLUS4) teks = "Set backgnd|V/RMB=back2";
             if (int(g_map[1]) == 255) teks = "Set backnd|-Not here";
             break;
         case 'i':
@@ -880,7 +880,7 @@
 {
     int res = f + d;
 
-    if (machine == PLUS4 || 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;
@@ -1066,7 +1066,7 @@
         xonko = int(1024 / g_maxcolors);
     }
 
-    if (machine == PLUS4 || machine == PLUS4M)
+    if (g_machine == PLUS4 || g_machine == PLUS4M)
         xonko = 15 * g_uizoom;
 
     for (x = 0; x < g_maxcolors; x++)
@@ -1124,7 +1124,7 @@
         if (g_repanel <= 0)
         {
             int index = x;
-            if (machine == MSX && x == 0) index = g_map[1];
+            if (g_machine == MSX && x == 0) index = g_map[1];
             e_rect(xloc, yloc, xonko, yhei, g_rgb[index]); // the colour blocks
             far = 0xff000000;
             if (g_farge == x) far = 0xff808080;
@@ -1159,7 +1159,7 @@
                 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 (machine == PLUS4 || machine == PLUS4M) {
+            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;
@@ -1196,7 +1196,7 @@
     e_rect(ox, oy, bs * 2, bs * 4, g_rgb[int(g_realback)]);
     e_rect(ox + bs / 2, oy + 4 * g_uizoom, 12 * g_uizoom, bs * 2, g_rgb[int(g_realfront)]);
     if (doicon(ox, oy, bs * 2, bs * 3)) command(int('<'));
-    if (machine == C64M || machine == MSX || 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)) {
@@ -1204,7 +1204,7 @@
             if (g_shift) command(int('C'));
         }
     }
-    if (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_uizoom, oy + bs * 3, bs, bs, g_rgb[int(g_map[2])]);
         d_rect(ox, oy + bs * 3, bs, bs, g_rgb[257]);
@@ -1235,7 +1235,7 @@
         icontable(width - 32 * g_uizoom, 0, 0, 0);
         icontable(272 * g_uizoom, height - 32 * g_uizoom, 1, 0);
         //icontable(0,0,3,0);
-        if (machine == PLUS4M || machine == PLUS4) {
+        if (g_machine == PLUS4M || g_machine == PLUS4) {
             icontable(240 * g_uizoom, height - 32 * g_uizoom, 2, 0);
         }
     }
@@ -1245,7 +1245,7 @@
         icontable(272 * g_uizoom, height - 32 * g_uizoom, 1, 1);
         palettebox(g_uizoom * 324 + 4, height - 32 * g_uizoom, width - (96 * g_uizoom) - 4);
 
-        if (machine == PLUS4M || machine == PLUS4) {
+        if (g_machine == PLUS4M || g_machine == PLUS4) {
             icontable(240 * g_uizoom, height - 32 * g_uizoom, 2, 1);
         }
 
@@ -1421,7 +1421,7 @@
                         a = int(g_map[cad]);
                         b = int(g_map[cad + 1000]);
                         c = int(g_map[cad + 2000]);
-                        if (machine == PLUS4M) {
+                        if (g_machine == PLUS4M) {
                             c = int(g_map[2]);
                         }
                         break;
--- a/mpui.js	Thu Aug 23 13:08:34 2018 +0300
+++ b/mpui.js	Thu Aug 23 13:11:47 2018 +0300
@@ -2,7 +2,7 @@
  * Multipaint.JS - Initializer/loader
  * (C) Copyright 2018 Matti 'ccr' Hämäläinen <ccr@tnsp.org>
  */
-var mpMachine = 0;
+var mpMachine = 0, mpUIZoom = 0;
 var mpURL;
 
 var mpMachines =
--- a/multipaint.pde	Thu Aug 23 13:08:34 2018 +0300
+++ b/multipaint.pde	Thu Aug 23 13:11:47 2018 +0300
@@ -36,7 +36,7 @@
 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 g_machine = -1; // change this to autoselect
 int platform = PSJS;
 
 int[] g_grids = new int[16];
@@ -106,8 +106,8 @@
 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_machine = (mpMachine >= 0) ? mpMachine : C64;
+    g_uizoom = (mpUIZoom >= 1 && mpUIZoom <= 3) ? mpUIZoom : 2;
     g_animspeed = 1;
 
     //normi
@@ -176,8 +176,6 @@
     g_data[int('m')] = 0;
     g_data[int('M')] = 0; // mags off
 
-    g_icons = mpLoadBinaryFile("icons.bin");
-
     set_tool(3);
 
     g_gridx = 8;
@@ -185,8 +183,10 @@
     g_multic = 0;
     g_repanel = -2;
 
+    mpSetupMachine(g_machine);
     mpSetUIColors();
-    mpSetupMachine(machine);
+
+    g_icons = mpLoadBinaryFile("icons.bin");
 
     if (g_forced_palette.length() > 3)
         mpLoadPalette(g_forced_palette);
@@ -472,7 +472,7 @@
 byte[] mpGetNativeImage()
 {
     //save the picture page g_map[], make sure some essential parameters are correct
-    g_map[3] = byte(machine);
+    g_map[3] = byte(g_machine);
     g_map[5] = byte(MX);
     g_map[7] = byte(MY);
 
@@ -485,7 +485,7 @@
     if (data == null)
         return -1;
 
-    if (data[3] != machine && !noError)
+    if (data[3] != g_machine && !noError)
         return -2;
 
     store_undo();