changeset 49:2d9a674bdeb2

Random cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 04 Jul 2018 18:44:11 +0300
parents 33a63f851a3b
children 8ba88c25f51d
files exporters.pde multipaint.pde
diffstat 2 files changed, 108 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/exporters.pde	Wed Jul 04 18:07:51 2018 +0300
+++ b/exporters.pde	Wed Jul 04 18:44:11 2018 +0300
@@ -4,23 +4,25 @@
 // remember hexdump -C !
 
 String g_formatname, g_formatextension;
-
 int g_headpos;
 int[] g_grids = new int[16];
 int OLD = 0;
 int NEW = 1;
 int g_gridmode = OLD;
 
+
 int bitti(int inp) {
     if (inp == 0) return 0;
     return 1;
 }
 
+
 int qbitti(int inp) {
     if (inp == 10) return 1;
     return 0;
 }
 
+
 void poopspecialsprites() {
     int x, y, xs, xx, yy, mup, row;
     int b7, b6, b5, b4, b3, b2, b1, b0, val;
@@ -98,6 +100,7 @@
     }
 }
 
+
 void poopultimachars() {
     PImage poutput;
     poutput = createImage(256 * 8, 8, RGB);
@@ -231,6 +234,7 @@
     //poutput.save("/home/tero/sketchbook/petscii/data/petscii-c64x.png");
 }
 
+
 void poopchars() {
     PImage poutput;
     poutput = createImage(256 * 8, 8, RGB);
@@ -349,6 +353,7 @@
     poutput.save("/home/tero/sketchbook/petscii/data/petscii-c64x.png");
 }
 
+
 void poopsprites() {
     int x, y, xs, xx, yy, mup;
     int b7, b6, b5, b4, b3, b2, b1, b0, val;
@@ -380,6 +385,7 @@
 
 }
 
+
 void pushbyte(int ad, int head) {
     g_map[ad    ] = byte((g_template[head] & 128) >> 7);
     g_map[ad + 1] = byte((g_template[head] & 64) >> 6);
@@ -392,7 +398,7 @@
 }
 
 
-void format_import(byte[] fhd) {
+bool format_import(byte[] fhd) {
     int x, y, x2, y2, y3, head, xx, yy, yp, ad, valu;
     int p1, p2, p3;
     head = 0;
@@ -405,20 +411,19 @@
         // 32*24 bytes of attributes
         if (g_template.length < 6912) {
             message("FALSE");
-            return;
+            return false;
         }
-        for (y = 0; y <= 2; y++) {
-            for (y2 = 0; y2 <= 7; y2++) {
-                for (yy = 0; yy <= 7; yy++) {
-                    for (x = 0; x <= 31; x++) {
-                        yp = y * 64 + yy * 8 + y2;
-                        ad = 1024 + yp * 256 + x * 8;
-                        pushbyte(ad, head);
-                        head++;
-                    }
-                }
-            }
+        for (y = 0; y < 3; y++)
+        for (y2 = 0; y2 < 8; y2++)
+        for (yy = 0; yy < 8; yy++)
+        for (x = 0; x < 32; x++)
+        {
+            yp = y * 64 + yy * 8 + y2;
+            ad = 1024 + yp * 256 + x * 8;
+            pushbyte(ad, head);
+            head++;
         }
+
         for (y = 0; y <= 23; y++) {
             for (x = 0; x <= 31; x++) {
                 ad = 65536 + x + y * (32 * 8);
@@ -448,24 +453,23 @@
         //0x232a=border (take the lower nybble)
         if (g_template.length < 9006) {
             message("FALSE "+ str(g_template.length));
-            return;
+            return false;
         }
         if (g_template.length >= 0x232a) {
             g_map[0] = byte(g_template[0x232a] & 0x0f);
         }
-        for (y = 0; y < 25; y++) {
-            for (x = 0; x < 40; x++) {
-                for (y2 = 0; y2 <= 7; y2++) {
-                    head = 2 + x * 8 + y * (40 * 8) + y2;
-                    ad = 1024 + x * 8 + y * (320 * 8) + y2 * 320;
-                    pushbyte(ad, head);
-                    p1 = g_template[0x1f42 + x + y * 40] & 0x0f;
-                    p2 = g_template[0x1f42 + x + y * 40] & 0xf0;
-                    p2 = p2 >> 4;
-                    g_map[65536 + x + y * 40 * 8 + y2 * 40] = byte(p2);
-                    g_map[65536 + MX * MY * 8 + x + y * 40 * 8 + y2 * 40] = byte(p1);
-                }
-            }
+        for (y = 0; y < 25; y++)
+        for (x = 0; x < 40; x++)
+        for (y2 = 0; y2 <= 7; y2++)
+        {
+            head = 2 + x * 8 + y * (40 * 8) + y2;
+            ad = 1024 + x * 8 + y * (320 * 8) + y2 * 320;
+            pushbyte(ad, head);
+            p1 = g_template[0x1f42 + x + y * 40] & 0x0f;
+            p2 = g_template[0x1f42 + x + y * 40] & 0xf0;
+            p2 = p2 >> 4;
+            g_map[65536 + x + y * 40 * 8 + y2 * 40] = byte(p2);
+            g_map[65536 + MX * MY * 8 + x + y * 40 * 8 + y2 * 40] = byte(p1);
         }
     }
 
@@ -476,7 +480,7 @@
         //2050 - bitmappi 40*25*8
         if (g_template.length < 10050) {
             message("FALSE");
-            return;
+            return false;
         }
         int l1, l2;
         for (y = 0; y < 25; y++) {
@@ -509,7 +513,7 @@
         //2050 - bitmap 40*25*8
         if (g_template.length < 10050) {
             message("FALSE");
-            return;
+            return false;
         }
         int l1, l2;
         for (y = 0; y < 25; y++) {
@@ -549,7 +553,7 @@
         //0x233a colors2 (40*25)
         if (g_template.length < 10018) {
             message("FALSE "+ str(g_template.length));
-            return;
+            return false;
         }
         for (y = 0; y < 25; y++) {
             for (x = 0; x < 40; x++) {
@@ -578,7 +582,7 @@
         // 7+(32*24*8)=colormap 32*24
         if (g_template.length < 14343) {
             message("FALSE");
-            return;
+            return false;
         }
         for (y = 0; y < 24; y++) {
             for (x = 0; x < 32; x++) {
@@ -604,14 +608,18 @@
 
     if (machine == CPC) { // a studio?
         message("Not|Working");
+        return false;
     }
 
     consistency();
     refresh();
     g_boxreconstruct = 2;
+    return true;
 }
 
-void format_export(String fname) {
+
+void format_export(String fname)
+{
     int val1, val2, val3;
     int y, y2, yy, x, yp, xp, ad, valu, valu2, bri;
 
@@ -625,7 +633,7 @@
         bitmapexport(40, 25);
         export_program(fname);
     }
-
+    else
     if (machine == PLUS4M) { // multi botticelli multicolor
         load_template("m.multi.prg");
         val2 = getpluscolor(int(g_map[1]));
@@ -646,7 +654,7 @@
         bitmapexport(40, 25);
         export_program(fname);
     }
-
+    else
     if (machine == C64) {
         load_template("hires.art");
         set_head(2);
@@ -657,9 +665,24 @@
         write_head(int(g_map[0]));
         export_program(fname);
     }
-
+    else
     if (machine == C64M) {
-        if (fname.indexOf(".kla") == -1) {
+        if (fname.indexOf(".kla") >= 0)
+        {
+            // Koala Painter
+            load_template("multic.kla");
+            set_head(2);
+            bitmapexport(40, 25);
+            set_head(0x1f42);
+            colorexport(40, 25, 65536, 1);
+            set_head(0x232a);
+            colorexport(40, 25, 65536 + 2000, 2);
+            set_head(0x2712);
+            write_head(int(g_map[1] & 0x0f));
+        }
+        else
+        {
+            // Advanced Art Studio
             load_template("multic.ocp");
             set_head(2);
             bitmapexport(40, 25);
@@ -671,26 +694,10 @@
             write_head(int(g_map[0]));
             set_head(0x232b);
             write_head(int(g_map[1]));
-            export_program(fname);
         }
-
-        //koala
-
-        if (fname.indexOf(".kla") >= 0) {
-            load_template("multic.kla");
-            set_head(2);
-            bitmapexport(40, 25);
-            set_head(0x1f42);
-            colorexport(40, 25, 65536, 1);
-            set_head(0x232a);
-            colorexport(40, 25, 65536 + 2000, 2);
-            set_head(0x2712);
-            write_head(int(g_map[1] & 0x0f));
-            export_program(fname);
-        }
-
+        export_program(fname);
     }
-
+    else
     if (machine == MSX) {
         load_template("msx-screen2.sc2");
         set_head(7);
@@ -699,46 +706,54 @@
         colorexport(32, 24, 65536, 3); //there's an exception for msx-style
         export_program(fname);
     }
-
+    else
     if (machine == SPECTRUM) {
         load_template("zx-screen.scr");
         set_head(0);
-        for (y = 0; y <= 2; y++) {
-            for (y2 = 0; y2 <= 7; y2++) {
-                for (yy = 0; yy <= 7; yy++) {
-                    for (x = 0; x <= 31; x++) {
-                        yp = y * 64 + yy * 8 + y2;
-                        ad = 1024 + yp * 256 + x * 8;
-                        valu = g_map[ad + 0] * 128 + g_map[ad + 1] * 64 + g_map[ad + 2] * 32 + g_map[ad + 3] * 16 + g_map[ad + 4] * 8 + g_map[ad + 5] * 4 + g_map[ad + 6] * 2 + g_map[ad + 7] * 1;
-                        write_head(int(valu));
-                    }
+        for (y = 0; y < 3; y++)
+        for (y2 = 0; y2 < 8; y2++)
+        for (yy = 0; yy < 8; yy++)
+        for (x = 0; x < 32; x++)
+        {
+            yp = y * 64 + yy * 8 + y2;
+            ad = 1024 + yp * 256 + x * 8;
+
+            valu = g_map[ad + 0] * 128 +
+                   g_map[ad + 1] * 64 +
+                   g_map[ad + 2] * 32 +
+                   g_map[ad + 3] * 16 +
+                   g_map[ad + 4] * 8 +
+                   g_map[ad + 5] * 4 +
+                   g_map[ad + 6] * 2 +
+                   g_map[ad + 7] * 1;
+
+            write_head(int(valu));
+        }
+
+        for (y = 0; y < 24; y++)
+        for (x = 0; x <= 31; x++) {
+            ad = 65536 + x + y * 256;
+            valu = int(g_map[ad]);
+            valu2 = int(g_map[ad + MX * MY * 8]);
+            bri = 0;
+            if (valu >= 8) {
+                bri = 1;
+                valu = valu - 8;
+                valu2 = valu2 - 8;
+                if (valu2 <= 0) {
+                    valu2 = 0;
                 }
             }
-        }
-        for (y = 0; y <= 23; y++) {
-            for (x = 0; x <= 31; x++) {
-                ad = 65536 + x + y * 256;
-                valu = int(g_map[ad]);
-                valu2 = int(g_map[ad + MX * MY * 8]);
-                bri = 0;
-                if (valu >= 8) {
-                    bri = 1;
-                    valu = valu - 8;
-                    valu2 = valu2 - 8;
-                    if (valu2 <= 0) {
-                        valu2 = 0;
-                    }
-                }
-                if (bri == 1) {
-                    valu = valu + 64;
-                }
-                write_head(int(valu + valu2 * 8));
+            if (bri == 1) {
+                valu += 64;
             }
+            write_head(int(valu + valu2 * 8));
         }
         export_program(fname);
     }
 }
 
+
 void machine_export(String fname, int sorsa) {
     int yy, xx, x, y2, y, checksum;
     int xp, yp;
@@ -1820,7 +1835,9 @@
     g_gridmode = NEW;
 }
 
-void set_machine(int m) {
+
+void set_machine(int m)
+{
     machine = m;
     g_expname = "none";
     g_map[3] = byte(machine);
@@ -2007,6 +2024,10 @@
 
     if (machine == AMIGA) { //generic 16bit
         g_name = "test";
+        g_expname = "";
+        g_formatname = "";
+        g_formatextension = "";
+
         g_backmode = 1;
         g_maxcolors = 32;
         g_palsteps = 16;
@@ -2023,10 +2044,10 @@
     }
 
     if (machine == C64FLI) { //c64 hires FLI = AFLI
+        g_name = "afli";
         g_expname = "prg";
         g_formatname = "";
         g_formatextension = "";
-        g_name = "afli";
 
         g_attrimode = 0;
         g_map[1] = byte(255);
--- a/multipaint.pde	Wed Jul 04 18:07:51 2018 +0300
+++ b/multipaint.pde	Wed Jul 04 18:44:11 2018 +0300
@@ -25,8 +25,7 @@
 int g_omag, g_bordh, g_bordv, g_keymacpos, g_framec;
 
 boolean fileselect = false, saveas = false, refselect = false, g_control = false, g_shift = false, exporttxt = false, importfmt = false, exportemu = false, exportfmt = false;
-String path = "", refpath = "", filename = "", elename = "", sfilename = "", refname = "", g_expname = "";
-String g_keymacro = "";
+String path = "", refpath = "", filename = "", elename = "", sfilename = "", refname = "", g_expname = "", g_keymacro = "";
 
 int[] g_r = new int[266];
 int[] g_g = new int[266];