changeset 155:b9ad669fb025

Integrate more 1.8.2018 changes.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 16 Aug 2018 14:33:36 +0300
parents 1b2cbf3ab441
children 5d73681b97eb
files Interface.pde events.pde mpui.js
diffstat 3 files changed, 114 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/Interface.pde	Thu Aug 16 13:00:03 2018 +0300
+++ b/Interface.pde	Thu Aug 16 14:33:36 2018 +0300
@@ -1,5 +1,5 @@
-// This collects UI stuff that's not directly related to the viewport
-// i.e. Icons, color selectors and the like, but also undo/spare
+// This collects UI stuff, viewport
+// i.e. Icons, color selectors and the like
 
 //fixed raster parameters
 int g_raster_offset_x;
@@ -158,11 +158,13 @@
 
 int magmode()
 {
-    //return the mode "number" based on g_uizoom and 'm' and 'M'
-    //currently valid outputs are 0,10,20,1,11,21,2,12,22
+    // return the mode "number" based on g_uizoom and 'm' and 'M'
+    // currently valid outputs are 0,10,20,1,11,21,2,12,22
+    // flat variants: 100,110,120,101,111,121,102,112,122
     int base = 0;
-    if (g_uizoom == 1) base = 10;
-    if (g_uizoom == 3) base = 20;
+    if (g_aspect == FLATRATIO) base = 100;
+    if (g_uizoom == 1) base += 10;
+    if (g_uizoom == 3) base += 20;
     if (g_data[int('M')] == 1 && g_data[int('m')] == 1) g_data[int('m')] = 0;
     if (g_data[int('m')] == 1) base += 1;
     if (g_data[int('M')] == 1) base += 2;
@@ -226,6 +228,9 @@
 
 void e_rect(int x1, int y1, int w, int h, int rgb)
 {
+    if (y1 < 0 || x1 < 0 || y1 + h >= height || x1 + w >= width)
+        return;
+
     int ad = x1 + y1 * width;
     for (int yy = 0; yy < h; yy++)
     {
@@ -239,6 +244,10 @@
 
 void d_rect(int x1, int y1, int w, int h, int rgb)
 {
+//    if (y1 < 0 || x1 < 0 || y1 + h >= height || x1 + w >= width)
+    if (y1 + h >= height || x1 + w >= width)
+        return;
+
     int ad = x1 + y1 * width;
     for (int yy = 0; yy < h; yy++)
     {
@@ -772,7 +781,7 @@
     g_data[int('9')] = (g_btype == 9) ? 1 : 0;
 
     // the main and sideboard icon panel order
-    if (tabletype == 0) pan = ";;h9::123456::78::pzxy::XYtn::lsEAwW::jc0g::uo::.b";
+    if (tabletype == 0) pan = ";;h9::123456::78::pzxy::XYtn::lsEAwW::jc0g::uo::"; //.b
     if (tabletype == 1) pan = "BCrRfd";
     if (tabletype == 2) pan = "ik";
 
@@ -1009,14 +1018,14 @@
             g_boxreconstruct = 2;
         }
     }
-    e_rect(int(x0), y0, int(x1 - x0), 7 * g_uizoom, g_rgb[258]);
-    e_rect(int(x0), y0 + 10 * g_uizoom, int(x1 - x0), 7 * g_uizoom, g_rgb[258]);
-    e_rect(int(x0), y0 + 20 * g_uizoom, int(x1 - x0), 7 * g_uizoom, g_rgb[258]);
 
-    for (int i = 1; i < g_palsteps; i++) {
-        e_rect(int(x0 + expand * i), y0, g_uizoom, 2 * g_uizoom, g_rgb[257]);
-        e_rect(int(x0 + expand * i), y0 + 10 * g_uizoom, g_uizoom, 2 * g_uizoom, g_rgb[257]);
-        e_rect(int(x0 + expand * i), y0 + 20 * g_uizoom, g_uizoom, 2 * g_uizoom, g_rgb[257]);
+    for (int j = 0; j < 3; j++)
+    {
+        e_rect(int(x0), y0 + j * 10 * g_uizoom, int(x1 - x0), 7 * g_uizoom, g_rgb[258]);
+
+        for (int i = 1; i < g_palsteps; i++) {
+            e_rect(int(x0 + expand * i), y0 + j * 10 * g_uizoom, g_uizoom, 2 * g_uizoom, g_rgb[257]);
+        }
     }
 
     e_rect(int(x0 + expand * g_r[g_farge] / divs), y0, int(expand), 7 * g_uizoom, g_rgb[260]);
@@ -1096,6 +1105,8 @@
                 xloc = xo + (x - 105) * xonko;
                 yloc = yo + yhei * 0 + yfat * 14;
             }
+
+            yloc--;
         }
 
         if (doicon_drag(xloc, yloc, xonko, yhei))
@@ -1215,7 +1226,7 @@
     if (g_repanel <= 0)
         g_repanel++;
 
-    messagebox(width - 12 * 8 * g_uizoom, height - 4 * 8 * g_uizoom);
+    messagebox(width - 12 * 8 * g_uizoom, height - 4 * 8 * g_uizoom - g_uizoom);
 
     // when tooltipping, the panels are not really
     // drawn but used for easy coordinate reference
@@ -1227,30 +1238,19 @@
         if (machine == PLUS4M || machine == PLUS4) {
             icontable(240 * g_uizoom, height - 32 * g_uizoom, 2, 0);
         }
-        return;
     }
-
-    icontable(width - 32 * g_uizoom - 1, 0, 0, 1);
-    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) {
-        icontable(240 * g_uizoom, height - 32 * g_uizoom, 2, 1);
-    }
+    else
+    {
+        icontable(width - 32 * g_uizoom - 1, 0, 0, 1);
+        icontable(272 * g_uizoom, height - 32 * g_uizoom, 1, 1);
+        palettebox(g_uizoom * 324 + 4, height - 32 * g_uizoom, width - (96 * g_uizoom) - 4);
 
-    colorselector(0, height - 32 * g_uizoom);
-    colorindicator(256 * g_uizoom, height - 32 * g_uizoom);
-}
-
+        if (machine == PLUS4M || machine == PLUS4) {
+            icontable(240 * g_uizoom, height - 32 * g_uizoom, 2, 1);
+        }
 
-void magport() {
-    int b = g_uizoom * 2;
-    int xo = 0;
-    int yo = 0;
-    for (int y = 0; y < Y; y++) {
-        for (int x = 0; x < X; x++) {
-            int raddr = (xo * 24 + x) + (yo * 24 + y) * width;
-            pixels[raddr] = int(g_rgb[easygetcolor(x, y)]);
-        }
+        colorselector(0, height - 32 * g_uizoom);
+        colorindicator(256 * g_uizoom, height - 32 * g_uizoom);
     }
 }
 
@@ -1261,8 +1261,8 @@
     // main machine screen redraw
     // and dirty char update
     int xx, yy, xo, yo, xwin, ywin, x, y, winsux, winsuy, rubx;
-    int ad, cad, a, b, c, mmode, fari, psize;
-    int zonx, zony, maxx, mayy, mag, raddr;
+    int ad, cad, a, b, c, mmode, fari, psizex, psizey;
+    int maxx, mayy, xcmag, ycmag, raddr;
     int left = 32 * g_uizoom;
     raddr = 0;
     winsux = 0;
@@ -1277,22 +1277,32 @@
     if (g_data[int('m')] == 1) makecolor(259, 48, 48, 48); //don't use border color in mag modes
     if (g_data[int('M')] == 1) makecolor(259, 48, 48, 48);
 
-    psize = g_magpix[mmode];
-    mag = psize * 8;
+    psizex = g_magpix[mmode];
+    psizey = g_magpiy[mmode];
+    xcmag = psizex * 8;
+    ycmag = psizey * 8;
+
     maxx = magx();
     mayy = magy();
+    //borders & ultimate background
 
     if (g_boxreconstruct == 1) {
         g_boxreconstruct = 0;
-        e_rect(0, (mayy * psize) * 8, maxx * psize * 8, height - ((g_vedge + g_uizoom * 2) + (mayy * psize * 8)), g_rgb[259]);
-        e_rect((maxx * psize) * 8, 0, width - (maxx * psize * 8 + (g_hedge + g_uizoom * 2)), height - (g_vedge + g_uizoom), g_rgb[259]);
+        //between mag window and toolboxes
+        if (g_data['m'] == 1 || g_data['M'] == 1)
+        {
+            e_rect(0, (mayy * psizex) * 8, maxx * psizex * 8, height - ((g_vedge + g_uizoom * 2) + (mayy * psizex * 8)), g_rgb[263]);
+            e_rect((maxx * psizex) * 8, 0, width - (maxx * psizex * 8 + (g_hedge + g_uizoom * 2)), height - (g_vedge + g_uizoom), g_rgb[263]);
+        }
+        //  e_rect(width-(g_hedge+g_uizoom*2),0,g_hedge+g_uizoom*2,height,g_rgb[263]);
+        //  e_rect(0,height-(g_vedge+g_uizoom*2),width,g_vedge+g_uizoom*2,g_rgb[263]);
     }
 
     if (g_boxreconstruct == 2)
     {
         //in case of full window update
         g_boxreconstruct = 0;
-        e_rect(0, 0, width - (g_hedge + g_uizoom * 2), height - (g_vedge + g_uizoom * 2), g_rgb[259]);
+        e_rect(0, 0, width - (g_hedge + g_uizoom * 2 - 2), height - (g_vedge + g_uizoom * 2 - 2), g_rgb[259]);
     }
 
     if (g_pgrab)
@@ -1304,13 +1314,9 @@
 
     maxx--;
     mayy--;
-    zonx = MX - magx();
-    zony = MY - magy();
 
-    if (g_ofx > zonx) g_ofx = zonx;
-    if (g_ofy > zony) g_ofy = zony;
-    if (g_ofx < 0) g_ofx = 0;
-    if (g_ofy < 0) g_ofy = 0;
+    g_ofx = clipv(g_ofx, 0, MX - magx());
+    g_ofy = clipv(g_ofy, 0, MY - magy());
 
     if (mmode == 10) {
         g_ofx = 0;
@@ -1319,7 +1325,7 @@
         mayy = MY - 1;
         winsux = g_windowx;
         winsuy = g_windowy;
-        mag = 16;
+        xcmag = 16;
     } //mini
     else
     if (mmode == 0) {
@@ -1329,7 +1335,7 @@
         mayy = MY - 1;
         winsux = g_windowx;
         winsuy = g_windowy;
-        mag = 24;
+        xcmag = 24;
     } //normal
     else
     if (mmode == 20) {
@@ -1339,19 +1345,22 @@
         mayy = MY - 1;
         winsux = g_windowx;
         winsuy = g_windowy;
-        mag = 32;
+        xcmag = 32;
     } //maxi
+    else
+    if (mmode == 1 || mmode == 2 ||
+        mmode == 11 || mmode == 12 ||
+        mmode == 21 || mmode == 22)
+    {
+        winsux = 0;
+        winsuy = 0;
+        fill(32, 32, 32);
+    }
 
     b = 0;
     c = 0;
     a = 5;
 
-    if (mmode == 1 || mmode == 2 || mmode == 11 || mmode == 12 || mmode == 21 || mmode == 22) {
-        winsux = 0;
-        winsuy = 0;
-        fill(32, 32, 32);
-    }
-
     for (ywin = 0; ywin <= mayy; ywin++)
     for (xwin = 0; xwin <= maxx; xwin++)
     {
@@ -1624,19 +1633,19 @@
             if (int(g_data[int('g')]) == 1) {
                 int lapx = chopv(xx * 8, g_gridx);
                 if (lapx == (xx * 8)) {
-                    t_rect(xo * mag + winsux, yo * mag + winsuy, 1, mag, g_rgb[257]);
+                    t_rect(xo * xcmag + winsux, yo * xcmag + winsuy, 1, xcmag, g_rgb[257]);
                     if (g_gridx == 4) {
-                        t_rect(xo * mag + winsux + 4 * psize, yo * mag + winsuy + 1, 1, int(mag / 2) - 2, g_rgb[257]);
-                        t_rect(xo * mag + winsux + 4 * psize, yo * mag + winsuy + mag - int(mag / 2) + 2, 1, int(mag / 2) - 2, g_rgb[257]);
+                        t_rect(xo * xcmag + winsux + 4 * psizex, yo * xcmag + winsuy + 1, 1, int(xcmag / 2) - 2, g_rgb[257]);
+                        t_rect(xo * xcmag + winsux + 4 * psizex, yo * xcmag + winsuy + xcmag - int(xcmag / 2) + 2, 1, int(xcmag / 2) - 2, g_rgb[257]);
                     }
                 }
                 lapx = chopv(yy * 8, g_gridy);
 
                 if (lapx == (yy * 8)) {
-                    t_rect(xo * mag + winsux + 1, yo * mag + winsuy, mag - 1, 1, g_rgb[257]);
+                    t_rect(xo * xcmag + winsux + 1, yo * xcmag + winsuy, xcmag - 1, 1, g_rgb[257]);
                     if (g_gridy == 4) {
-                        t_rect(xo * mag + winsux + 1, yo * mag + winsuy + 4 * psize, int(mag / 2) - 2, 1, g_rgb[257]);
-                        t_rect(xo * mag + winsux + 2 + mag - int(mag / 2), yo * mag + winsuy + 4 * psize, int(mag / 2) - 2, 1, g_rgb[257]);
+                        t_rect(xo * xcmag + winsux + 1, yo * xcmag + winsuy + 4 * psizex, int(xcmag / 2) - 2, 1, g_rgb[257]);
+                        t_rect(xo * xcmag + winsux + 2 + xcmag - int(xcmag / 2), yo * xcmag + winsuy + 4 * psizex, int(xcmag / 2) - 2, 1, g_rgb[257]);
                     }
                 }
             }
--- a/events.pde	Thu Aug 16 13:00:03 2018 +0300
+++ b/events.pde	Thu Aug 16 14:33:36 2018 +0300
@@ -85,11 +85,10 @@
 }
 
 
-void mouseWheel(processing.event.MouseEvent event)
+void mouseScrolled()
 {
-    float e = event.getCount();
-    if (e < -0.1) command(g_wheelup);
-    if (e > 0.1) command(g_wheeldown);
+    if (mouseScroll < -0.1) command(g_wheelup);
+    if (mouseScroll > 0.1) command(g_wheeldown);
 }
 
 
@@ -304,6 +303,33 @@
 }
 
 
+void maghelper(int rel)
+{
+    if (rel < 0)
+    {
+        if (g_data[int('M')] == 1 || g_data[int('m')] == 1)
+        {
+            command('m');
+            refresh();
+        }
+    }
+    else
+    {
+        if (g_data[int('m')] == 0 && g_data[int('M')] == 0)
+        {
+            command('m');
+            refresh();
+        }
+        else
+        if (g_data[int('m')] == 1 && g_data[int('M')] == 0)
+        {
+            command('M');
+            refresh();
+        }
+    }
+}
+
+
 void command(int ckey)
 {
     g_dirty = true;
@@ -420,9 +446,11 @@
         if (ckey == ' ') {}
     }
 
-    if (ckey >= 0 && ckey <= 255) {
-        //g_depressed[ckey-48]=10;
-    }
+    if (ckey == g_wheeldown)
+        maghelper(-1);
+    else
+    if (ckey == g_wheelup)
+        maghelper(1);
 
     if (ckey == ',') {
         g_repanel = -2;
--- a/mpui.js	Thu Aug 16 13:00:03 2018 +0300
+++ b/mpui.js	Thu Aug 16 14:33:36 2018 +0300
@@ -10,6 +10,12 @@
     [   9, "Plus4 hires"        , true ],
     [  19, "Plus4 multicolor"   , true ],
     [   2, "Amstrad CPC mode 0" , true ],
+
+/*
+    [  32, "C64 no limit"       , false ],
+    [  20, "C64 FLI hires"      , false ],
+    [  21, "C64 FLI multicolor" , false ],
+*/
 ];