annotate multipaint.pde @ 212:b3579297e04e

Implement rest of the stuff needed for selecting external palettes in the launcher and actual Multipaint code.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 03 Sep 2018 14:22:20 +0300
parents 3b1afb0b9b30
children d3eba28c26e5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35
eb9157c6a067 Update author blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
1 //
159
fec2088cdd31 Change version.
Matti Hamalainen <ccr@tnsp.org>
parents: 154
diff changeset
2 // Multipaint.JS 1.8.2018
35
eb9157c6a067 Update author blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
3 // Tero Heikkinen (Dr. TerrorZ)
eb9157c6a067 Update author blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
4 // ProcessingJS port and changes by Matti Hämäläinen (ccr/TNSP)
eb9157c6a067 Update author blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
5 // processing setup draw and file things here
eb9157c6a067 Update author blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
6 //
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
7
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
8 // Supported
176
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
9 final int C64 = 0, MSX = 5, SPECTRUM = 6, C64M = 10,
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
10 PLUS4 = 9, PLUS4M = 19, CPC = 2;
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
11
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
12 // Experimental or incomplete
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
13 final int C64NOLIMIT = 32; // Commodore 64 without attribute limitations
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
14 final int C64FLI = 20, C64FLIM = 21; // incomplete FLI & AFLI modes
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
15 final int TIMEX = 7, JR200 = 8, AMIGA = 11, ATARIST = 12;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
16 final int PICO8 = 88;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
17 final int UNIA = 33;
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
18 final int COCO3 = 34;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
19 final int BK0010 = 99;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
20 final int QLLOW = 66;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
21
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
22 // Reserved but completely unimplemented
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
23 final int VIC = 22; // VIC-20
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
24 final int CGA = 23; // 320 x 200 PC CGA screen with black, white, cyan, magenta
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
25 final int CGAX = 24; // 320 x 200 PC CGA screen with black, yellow, green, red-ish
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
26 final int EGA = 200; // 320 x 200 PC EGA screen, 16 colors of 64
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
27 final int VGA = 255; // 320 x 200 PC VGA screen, 256 colors of 65536
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
28 final int NES = 90; // 8-bit NES
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
29 final int SEGAM = 91; // 8-bit Sega Master System
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
30
176
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
31 final int GRIDMODE_OLD = 0;
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
32 final int GRIDMODE_NEW = 1;
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
33 final int AR_FLAT = 1;
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
34 final int AR_SQUARE = 0;
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
35
16
f356d9c176a6 ProcessingJS does not provide "platform" variables, we need to define them ourselves.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
36 final int PEESEE = 0, MACOSX = 1, PSJS = 2;
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
37 final int COMMAND = 157; // Marq's cmd/ctrl solution
69
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
38
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 178
diff changeset
39 int g_machine = -1; // change this to autoselect
16
f356d9c176a6 ProcessingJS does not provide "platform" variables, we need to define them ourselves.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
40 int platform = PSJS;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
41
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
42 int[] g_grids = new int[16];
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
43
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
44 int[] g_r = new int[266];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
45 int[] g_g = new int[266];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
46 int[] g_b = new int[266];
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
47 int[] g_rgb = new int[266];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
48
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
49 byte[] g_map = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
50 byte[] g_fillmap = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
51 byte[] g_rmap = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
52 byte[] g_icons = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
53 byte[] g_brush = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
54 byte[] g_template = new byte[16384];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
55 byte[] g_redo = new byte[1024];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
56 byte[] g_remdo = new byte[1024];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
57 int[] g_chaup = new int[64];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
58 byte[] g_data = new byte[1024];
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
59 int[] g_magpix = new int[64];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
60 int[] g_magpiy = new int[64];
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
61
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
62 byte g_realfront, g_realback;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
63
176
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
64 int g_tooltrigger, g_prevtool, g_rband, g_rbang, g_boxreconstruct,
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
65 g_charlimit, g_animx, g_animy, g_animframes, g_animno, g_animtime,
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
66 g_animspeed, g_keymacpos, g_forced_width, g_forced_height,
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
67 g_hadjust, g_vadjust;
176
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
68
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
69 int g_wheelup = int(':'), g_wheeldown = int(';'), g_middlebutton = int(',');
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
70 int g_gridmode = GRIDMODE_OLD;
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
71 int g_pixelw = 1;
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
72 int g_aspect = AR_SQUARE;
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
73
205
3b1afb0b9b30 Clean up key event handling and add support for g_alt.
Matti Hamalainen <ccr@tnsp.org>
parents: 195
diff changeset
74 boolean g_control = false, g_shift = false, g_alt = false,
176
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
75 g_dirty, g_inhibit_aspect = false;
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
76
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
77 String g_formatname, g_formatext,
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
78 filename = "", sfilename = "",
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
79 g_name, g_exportext = "",
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
80 g_exportname = "", g_keymacro = "",
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
81 g_forced_palette = "";
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
82
69
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
83
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
84 //dimensions
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
85 int X, Y, MX, MY;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
86 //generic mouse
154
1b2cbf3ab441 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
87 boolean g_klikkeri, g_iconmode = false;
143
5e18cb16bc4b Booleanize.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
88 int g_ofx, g_ofy, g_button, g_realbutton, g_mx, g_my, g_orx, g_ory, g_msx, g_msy;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
89 //rubberband,mouse
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
90 int g_phase, g_rx, g_ry, g_rx2, g_ry2, g_rubbermode;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
91 int g_prex, g_prey, g_storedcoordx, g_storedcoordy;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
92 //window positioning
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
93 int g_windowx, g_windowy, g_maglocx, g_maglocy;
183
1cb7ecd73554 Rename global variable g_uizoom to g_uiscale and mpUIZoom -> mpUIScale.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
94 int g_hedge, g_vedge, g_uiscale, g_wzoom;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
95 //icons & gui stuff
154
1b2cbf3ab441 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
96 int g_iconx, g_icony, g_piconx, g_picony;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
97 int g_gridx, g_gridy, g_spare;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
98 int g_farge, g_backg, g_ofarge, g_repanel, g_msgctr;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
99 //machine related color properties
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
100 int g_attrimode, g_britemode, g_multic, g_backmode, g_maxcolors, g_hzoomer;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
101 float g_palsteps;
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
102 //brush, tool parameters
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
103 int g_bsourcex, g_bsourcey, g_bsourcex2, g_bsourcey2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
104 int g_bsize, g_btype;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
105
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
106
83
6524e83c3ba7 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
107 void setup()
6524e83c3ba7 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
108 {
176
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
109 // Get settings from Javascript runner, or use defaults
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 178
diff changeset
110 g_machine = (mpMachine >= 0) ? mpMachine : C64;
183
1cb7ecd73554 Rename global variable g_uizoom to g_uiscale and mpUIZoom -> mpUIScale.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
111 g_uiscale = (mpUIScale >= 1 && mpUIScale <= 3) ? mpUIScale : 2;
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 186
diff changeset
112 g_forced_width = mpUIForcedWidth > 0 ? mpUIForcedWidth : 0;
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 186
diff changeset
113 g_forced_height = mpUIForcedHeight > 0 ? mpUIForcedHeight : 0;
212
b3579297e04e Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
114 g_forced_palette = mpUIPalette ? mpUIPalette : "";
176
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
115 g_animspeed = 1;
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
116
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
117 //normi
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
118 g_magpix[0] = 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
119 g_magpix[1] = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
120 g_magpix[2] = 16;
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
121 g_magpiy[0] = 3;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
122 g_magpiy[1] = 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
123 g_magpiy[2] = 16;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
124
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
125 //mini
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
126 g_magpix[10] = 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
127 g_magpix[11] = 6;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
128 g_magpix[12] = 16;
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
129 g_magpiy[10] = 2;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
130 g_magpiy[11] = 6;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
131 g_magpiy[12] = 16;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
132
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
133 //maxi
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
134 g_magpix[20] = 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
135 g_magpix[21] = 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
136 g_magpix[22] = 32;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
137 g_magpiy[20] = 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
138 g_magpiy[21] = 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
139 g_magpiy[22] = 32;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
140
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
141 //FLAT normi
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
142 g_magpix[100] = 3;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
143 g_magpix[101] = 9;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
144 g_magpix[102] = 12;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
145 g_magpiy[100] = 2;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
146 g_magpiy[101] = 6;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
147 g_magpiy[102] = 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
149 //FLAT mini
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
150 g_magpix[110] = 3;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
151 g_magpix[111] = 9;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
152 g_magpix[112] = 12;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
153 g_magpiy[110] = 2;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
154 g_magpiy[111] = 6;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
155 g_magpiy[112] = 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
156
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
157 //FLAT maxi
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
158 g_magpix[120] = 6;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
159 g_magpix[121] = 12;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
160 g_magpix[122] = 21;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
161 g_magpiy[120] = 4;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
162 g_magpiy[121] = 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
163 g_magpiy[122] = 14;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
164
176
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
165 // Setup other stuff
183
1cb7ecd73554 Rename global variable g_uizoom to g_uiscale and mpUIZoom -> mpUIScale.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
166 if (g_uiscale >= 1 && g_uiscale <= 3)
1cb7ecd73554 Rename global variable g_uizoom to g_uiscale and mpUIZoom -> mpUIScale.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
167 g_wzoom = g_uiscale + 1;
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
168
183
1cb7ecd73554 Rename global variable g_uizoom to g_uiscale and mpUIZoom -> mpUIScale.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
169 g_hedge = 32 * g_uiscale;
1cb7ecd73554 Rename global variable g_uizoom to g_uiscale and mpUIZoom -> mpUIScale.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
170 g_vedge = 32 * g_uiscale;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
171
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
172 g_spare = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
173 g_bsize = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
174 g_btype = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
175 g_phase = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
176 g_button = LEFT;
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
177
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
178 g_data[int('f')] = 1; // fill on
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
179 g_data[int('g')] = 1; // grid on
153
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
180 g_data[int('m')] = 0;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
181 g_data[int('M')] = 0; // mags off
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
182
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
183 set_tool(3);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
184
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
185 g_gridx = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
186 g_gridy = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
187 g_multic = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
188 g_repanel = -2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
189
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 178
diff changeset
190 mpSetupMachine(g_machine);
162
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
191 mpSetUIColors();
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 178
diff changeset
192
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 178
diff changeset
193 g_icons = mpLoadBinaryFile("icons.bin");
153
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
194
176
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
195 if (g_forced_palette.length() > 3)
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
196 mpLoadPalette(g_forced_palette);
153
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
197
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
198 int truwinsizex = X * g_magpix[magmode()];
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
199 int truwinsizey = Y * g_magpiy[magmode()];
176
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
200
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
201 if (g_forced_width == 0 || g_forced_height == 0)
153
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
202 {
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
203 g_hadjust = 0;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
204 g_vadjust = 0;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
205
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
206 int hsize = truwinsizex + g_hedge + (22) * g_wzoom;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
207 int vsize = truwinsizey + g_vedge + (14) * g_wzoom;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
208
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
209 while (vsize - g_vedge < (12 * 16) * g_wzoom)
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
210 vsize += 2;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
211
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
212 while (hsize - g_hedge < (17 * 16) * g_wzoom)
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
213 hsize += 2;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
214
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
215 size(hsize, vsize);
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
216 }
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
217
176
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
218 if (g_forced_width > 800 && g_forced_height > 600)
0940d991d3b0 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
219 size(g_forced_width, g_forced_height);
153
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
220
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
221 if (g_inhibit_aspect)
172
e77a726a587e Rename FLATRATIO/SQUARERATIO and gridmode OLD/NEW constants to something more sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 168
diff changeset
222 g_aspect = AR_SQUARE;
153
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
223
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
224 int paspect = g_wzoom;
172
e77a726a587e Rename FLATRATIO/SQUARERATIO and gridmode OLD/NEW constants to something more sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 168
diff changeset
225 if (g_aspect == AR_FLAT)
153
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
226 {
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
227 if (g_wzoom == 2) paspect = 1;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
228 if (g_wzoom == 3) paspect = 2;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
229 if (g_wzoom == 4) paspect = 3;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
230 }
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
231
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
232 g_windowx = width - (g_hedge) - (truwinsizex);
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
233 g_windowx = g_windowx / 2;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
234 g_windowy = height - (g_vedge) - (truwinsizey);
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
235 g_windowy = g_windowy / 2;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
236
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
237 if (g_hadjust > 0)
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
238 g_windowx = width - (g_hedge) - (g_wzoom * X) - g_hadjust;
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
239
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
240 if (g_vadjust > 0)
9f4e6f888120 Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
241 g_windowy = height - (g_vedge) - (paspect * Y) - g_vadjust;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
242
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
243 switcher(3);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
244
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
245 g_map[4] = byte(g_maxcolors - 1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
246 g_ofarge = g_farge;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
247 MX = int(X / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
248 MY = int(Y / 8);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
249 g_realfront = byte(g_farge);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
250 g_realback = byte(g_backg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
251
83
6524e83c3ba7 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
252 for (int y = 0; y < Y; y++)
6524e83c3ba7 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
253 for (int x = 0; x < X; x++)
69
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
254 absolute_clearpoint(x, y);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
255
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
256 switcher(2);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
257 noStroke();
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
258 background(g_r[263], g_g[263], g_b[263]);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
259 sussborder();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
260 setup_raster();
83
6524e83c3ba7 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
261
159
fec2088cdd31 Change version.
Matti Hamalainen <ccr@tnsp.org>
parents: 154
diff changeset
262 message(" Multipaint| - 2018 -||v1.8.2018.JS");
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
263 message("*");
89
09c1a4aba305 Set dirty flag on setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 88
diff changeset
264 g_dirty = true;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
265 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
266
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
267
162
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
268 void mpSetUIColors()
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
269 {
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
270 // UI colors
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
271 makecolor(256, 0xff, 0, 0xff);
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
272 makecolor(257, 180, 180, 180);
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
273 // g_rgb[257] = 0xff808080;
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
274 makecolor(258, 0, 0, 0);
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
275 makecolor(259, 48, 48, 48);
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
276
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
277 // R,G and B for the palette sliders
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
278 makecolor(260, 255, 0, 0);
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
279 makecolor(261, 0, 255, 0);
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
280 makecolor(262, 0, 0, 255);
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
281 makecolor(263, 48, 48, 48); //backest UI background
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
282
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
283 }
ca07bdf66a70 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
284
101
e5c147a7bf98 Remove fexists(), it's not in use.
Matti Hamalainen <ccr@tnsp.org>
parents: 97
diff changeset
285 void mpSetTitle(String str)
e5c147a7bf98 Remove fexists(), it's not in use.
Matti Hamalainen <ccr@tnsp.org>
parents: 97
diff changeset
286 {
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
287 console.log("TITLE: '" + str + "'");
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
288 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
289
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
290
69
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
291 void draw()
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
292 {
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
293 if (!focused)
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
294 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
295 g_control = false;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
296 g_shift = false;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
297 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
298
72
5e7553e9aee0 Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
299 // If there should be no update, do not update.
73
d2a89e88f958 When in rubberband mode, do not delay screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
300 if (!g_dirty && !g_rubbermode)
72
5e7553e9aee0 Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
301 return;
5e7553e9aee0 Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
302 g_dirty = false;
5e7553e9aee0 Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
303
5e7553e9aee0 Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
304 // Animate animbrush
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
305 if (g_data[int('n')] == 1)
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
306 {
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
307 if (++g_animtime > 8 - g_animspeed * 2)
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
308 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
309 animbrush_do();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
310 g_animtime = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
311 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
312 }
9
dfdc18b62fab Change the help() function and its usage to have more than one parameter to
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
313
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
314 // Update some mouse variables
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
315 if (g_data[int('m')] == 0 && g_data[int('M')] == 0)
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
316 {
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
317 g_mx = g_msx - g_windowx;
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
318 g_my = g_msy - g_windowy;
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
319 }
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
320 else
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
321 {
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
322 g_mx = mouseX;
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
323 g_my = mouseY;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
324 }
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
325
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
326 g_msx = mouseX;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
327 g_msy = mouseY;
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
328
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
329 // Actual tool drawing
145
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
330 if (g_tooltrigger == 1 &&
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
331 g_mx <= width - g_hedge &&
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
332 g_my <= height - g_vedge)
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
333 do_tool(g_mx, g_my, g_button);
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
334
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
335 switcher(0);
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
336
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
337 for (int i = 0; i < 1024; i++)
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
338 g_remdo[i] = 0;
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
339
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
340 // Tool drawing for shows
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
341 int savebut = g_button;
186
74e1616ca38e Micro-optimize draw().
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
342 int tt = tool();
74e1616ca38e Micro-optimize draw().
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
343 if (tt != 5)
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
344 {
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
345 if (g_phase == 0)
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
346 g_button = LEFT;
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
347 do_tool(g_mx, g_my, LEFT);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
348 }
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
349 else
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
350 storecoords(g_mx, g_my);
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
351
186
74e1616ca38e Micro-optimize draw().
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
352 if (tt == 6) do_line(g_rx, g_ry, g_rx2, g_ry2, 0);
74e1616ca38e Micro-optimize draw().
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
353 if (tt == 7) do_circle(g_rx, g_ry, g_rx2, g_ry2);
74e1616ca38e Micro-optimize draw().
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
354 if (tt == 8) do_rectangle(g_rx, g_ry, g_rx2, g_ry2);
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
355 g_button = savebut;
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
356
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
357 // Screen update stuff
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
358 loadPixels();
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
359 viewport();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
360 switcher(1);
145
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
361
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
362 if (g_pgrab)
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
363 preview_box_drag();
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
364
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
365 preview_window();
136
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
366 update_ui(false);
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
367 updatePixels();
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
368
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
369 // Message control
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
370 if (g_msgctr > 0)
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
371 g_msgctr--;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
372
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
373 // Macro handling
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
374 if (g_keymacro.length() > g_keymacpos)
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
375 {
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
376 macro_command(g_keymacro.charAt(g_keymacpos));
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
377 g_keymacpos++;
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
378 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
379 }