annotate draw_smart.pde @ 237:a3f79ce74471

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 10 Sep 2018 11:10:19 +0300
parents 1d9f9c3d8ab1
children 3a85cf4a4fef
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1 //all "intelligent" stuff, the color behavior
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
2 //and flood fills
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
3
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
4 void consistency()
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
5 {
237
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
6 int mat, mulu, ymax;
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
7
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
8 if (g_multic == 1 || g_multic == 2)
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
9 return;
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
10
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
11 if (g_attrimode == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
12 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
13 mat = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
14 mulu = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
15 ymax = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
16 }
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
17 else
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
18 {
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
19 mat = 64;
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
20 mulu = 8;
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
21 ymax = 7;
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
22 }
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
23
237
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
24 for (int yy = 0; yy < MY; yy++)
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
25 for (int xx = 0; xx < MX; xx++)
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
26 {
237
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
27 int a = getattra(xx * 8, yy * mulu, 0),
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
28 b = getattra(xx * 8, yy * mulu, 1),
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
29 ad = 1024 + (xx * 8) + (yy * mulu * X);
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
30
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
31 if (a == b)
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
32 {
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
33 for (int y0 = 0; y0 <= ymax; y0++)
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
34 for (int x0 = 0; x0 <= 7; x0++)
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
35 {
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
36 g_map[ad + x0 + y0 * X] = byte(0);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
37 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
38 }
237
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
39
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
40 int pat = 0;
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
41 for (int y0 = 0; y0 <= ymax; y0++)
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
42 for (int x0 = 0; x0 <= 7; x0++)
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
43 {
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
44 pat += int(g_map[ad + x0 + y0 * X]);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
45 }
237
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
46
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
47 if (pat == mat || pat == 0)
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
48 {
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
49 for (y0 = 0; y0 <= ymax; y0++)
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
50 {
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
51 int fad = 65536 + xx + (yy * mulu + y0) * MX,
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
52 bad = fad + (MX * MY * 8);
a3f79ce74471 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
53
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
54 if (pat == 0) g_map[fad] = g_map[bad];
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
55 if (pat == mat) g_map[bad] = g_map[fad];
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
56 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
57 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
58 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
59 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
60
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
61
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
62 void transchar(int xx, int yy)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
63 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
64 int fad, bad, ad, pt, x0, y0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
65 int aa, bb, pp, ya, yb;
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
66
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
67 ya = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
68 yb = 0;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
69 xx = int(xx / 8);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
70
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
71 if (g_attrimode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
72 {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
73 yy = chop8(yy);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
74 ya = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
75 yb = 7;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
76 } //zx spec etc
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
77 if (g_attrimode == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
78 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
79 ya = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
80 yb = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
81 } //msx
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
82
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
83 for (y0 = ya; y0 <= yb; y0++)
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
84 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
85 fad = 65536 + xx + (yy + y0) * MX;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
86 bad = fad + (MX * MY * 8);
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
87
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
88 aa = int(g_map[fad]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
89 bb = int(g_map[bad]);
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
90
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
91 g_map[fad] = byte(bb);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
92 g_map[bad] = byte(aa);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
93 }
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
94
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
95 for (y0 = ya; y0 <= yb; y0++)
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
96 for (x0 = 0; x0 < 8; x0++)
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
97 {
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
98 ad = 1024 + x0 + xx * 8 + (y0 + yy) * X;
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
99 pp = 1 - int(g_map[ad]);
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
100 g_map[ad] = byte(pp);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
101 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
102 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
103
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
104
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
105 void prepare_char(int xx, int yy, int farbe)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
106 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
107 //changes the char foreg/backg into "favorable" relative to used color
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
108 //needed in floodfill
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
109
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
110 // currently seems to be same as transchar except this check,
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
111 // so we'll just call transchar() .. -- ccr
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
112 if (int(g_map[1024 + xx + yy * X]) == 0 &&
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
113 g_data[int('r')] == 0 && g_data[int('R')] == 0)
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
114 transchar(xx, yy);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
115 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
116
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
117
136
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
118 void changeborder(int mbut)
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
119 {
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
120 if (g_machine == MSX || g_machine == QLLOW || g_machine == AMIGA ||
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
121 g_machine == PICO8 || g_machine == BK0010 || g_machine == COCO3)
136
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
122 return;
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
123
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
124 int par = g_farge;
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
125 store_undo();
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
126 message("Set border");
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
127 if (mbut == LEFT) par = g_farge;
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
128 if (mbut == RIGHT) par = g_backg;
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
129 g_map[0] = byte(zxcolor(par));
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
130 sussborder();
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
131 g_boxreconstruct = 2;
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
132 refresh_all();
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
133 }
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
134
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
135
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
136 void floodfill_init(int xx, int yy)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
137 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
138 for (x = 0; x < X; x++)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
139 for (y = 0; y < Y; y++)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
140 g_fillmap[1024 + x + y * X] = byte(0);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
141
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
142 g_fillmap[1024 + xx + yy * X] = byte(100);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
143 }
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
144
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
145
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 117
diff changeset
146 boolean floodfill_mc_plop(int npar, int xc, int yc)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
147 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
148 int ad = 1024 + xc + yc * X;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
149
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
150 if (getmultic(xc, yc, 0) == npar &&
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
151 g_fillmap[ad] == 0)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
152 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
153 g_fillmap[ad] = byte(100);
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 117
diff changeset
154 if (g_pixelw == 2)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
155 g_fillmap[ad + 1] = byte(0);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
156
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
157 return true;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
158 }
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
159 else
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
160 return false;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
161 }
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
162
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
163
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
164 void floodfill_mc(int xx, int yy, int mbut)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
165 {
233
1d9f9c3d8ab1 Fixes to multicolor/pixelw==2 flood fill.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
166 int x, y, ax, valid, okay, par, npar;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
167 par = 0;
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
168
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 117
diff changeset
169 if (g_pixelw == 2)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
170 xx = chop2(xx);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
171
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
172 if (mbut == LEFT)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
173 par = g_farge;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
174 else
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
175 if (mbut == RIGHT)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
176 par = g_backg;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
177
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
178 npar = getmultic(xx, yy, 0);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
179 if (npar == par)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
180 return;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
181
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
182 floodfill_init(xx, yy);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
183
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
184 valid = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
185 okay = 0;
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
186 while (okay == 0)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
187 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
188 valid = 0;
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
189 for (y = 0; y < Y; y++)
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 117
diff changeset
190 for (x = 0; x < X; x += g_pixelw)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
191 {
233
1d9f9c3d8ab1 Fixes to multicolor/pixelw==2 flood fill.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
192 int zad = 1024 + x + y * X;
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
193 ax = int(g_fillmap[zad]);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
194 if (ax >= 100 && ax <= 199)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
195 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
196 valid = 1;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 117
diff changeset
197 if (y > 0 && floodfill_mc_plop(npar, x, y - 1))
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
198 valid = 1;
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
199
233
1d9f9c3d8ab1 Fixes to multicolor/pixelw==2 flood fill.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
200 if (x >= g_pixelw && floodfill_mc_plop(npar, x - g_pixelw, y))
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
201 valid = 1;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
202
233
1d9f9c3d8ab1 Fixes to multicolor/pixelw==2 flood fill.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
203 if (x <= X - g_pixelw - g_pixelw && floodfill_mc_plop(npar, x + g_pixelw, y))
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
204 valid = 1;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
205
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 117
diff changeset
206 if (y < Y - 1 && floodfill_mc_plop(npar, x, y + 1))
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
207 valid = 1;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
208
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
209 g_fillmap[zad] = byte(200);
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 117
diff changeset
210 if (g_pixelw == 2)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
211 g_fillmap[zad + 1] = byte(0);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
212 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
213 }
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
214
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
215 if (valid == 0)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
216 okay = 1;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
217 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
218
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
219 for (y = 0; y < Y; y++)
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 117
diff changeset
220 for (x = 0; x < X; x += g_pixelw)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
221 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
222 if (g_fillmap[1024 + x + y * X] == byte(200))
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
223 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
224 g_farge = par;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
225 mkaveri(x, y, par, 0);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
226 makepoint(x, y);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
227 }
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
228 }
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
229 g_farge = g_ofarge;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
230 }
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
231
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
232
117
44a07b1c620d Rename 'bool' -> 'boolean'.
Matti Hamalainen <ccr@tnsp.org>
parents: 46
diff changeset
233 boolean floodfill_iq_plop(int npar, int xc, int yc)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
234 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
235 int ad = 1024 + xc + yc * X;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
236
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
237 if (getabsa(xc, yc, 0) == npar &&
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
238 g_fillmap[ad] == 0)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
239 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
240 prepare_char(xc, yc, npar);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
241 g_fillmap[ad] = byte(100);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
242 return true;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
243 }
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
244 else
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
245 return false;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
246 }
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
247
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
248
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
249 void floodfill_iq(int xx, int yy, int mbut)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
250 {
233
1d9f9c3d8ab1 Fixes to multicolor/pixelw==2 flood fill.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
251 int x, y, ax, ay, valid, okay, par, npar;
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
252 par = 0;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
253
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
254 if (mbut == LEFT)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
255 par = g_farge;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
256 else
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
257 if (mbut == RIGHT)
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
258 par = g_backg;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
259
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
260 npar = getabsa(xx, yy, 0);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
261 if (npar == par)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
262 return;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
263
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
264 // Do consistency chec, then get the NEW color under xx,yy
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
265 consistency();
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
266 prepare_char(xx, yy, npar);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
267 floodfill_init(xx, yy);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
268
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
269 valid = 0;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
270 okay = 0;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
271 while (okay == 0)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
272 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
273 valid = 0;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
274 for (y = 0; y < Y; y++)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
275 for (x = 0; x < X; x++)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
276 {
233
1d9f9c3d8ab1 Fixes to multicolor/pixelw==2 flood fill.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
277 int zad = 1024 + x + y * X;
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
278 ax = int(g_fillmap[zad]);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
279 if (ax == 100)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
280 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
281 valid = 1;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
282 if (y > 0 && floodfill_iq_plop(npar, x, y - 1))
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
283 valid = 1;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
284
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
285 if (x > 0 && floodfill_iq_plop(npar, x - 1, y))
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
286 valid = 1;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
287
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
288 if (x < X - 1 && floodfill_iq_plop(npar, x + 1, y))
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
289 valid = 1;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
290
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
291 if (y < Y - 1 && floodfill_iq_plop(npar, x, y + 1))
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
292 valid = 1;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
293
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
294 g_fillmap[zad] = byte(200);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
295 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
296 }
46
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
297 if (valid == 0)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
298 okay = 1;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
299 }
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
300
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
301 for (y = 0; y < Y; y++)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
302 for (x = 0; x < X; x++)
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
303 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
304 if (g_fillmap[1024 + x + y * X] == byte(200))
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
305 {
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
306 g_farge = par;
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
307 makepoint(x, y);
31bfa78dba15 Clean up and fix the flood fill functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
308 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
309 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
310 g_farge = g_ofarge;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
311 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
312
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
313
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
314 //adaptive color helper for low-attribute modes
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
315 //reasons the background color for each char as you draw
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
316 //=changed
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
317
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
318 void fixattr(int x, int y, int foreg, int backg)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
319 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
320 int bad, cad, miny, maxy;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
321
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
322 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
323 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
324 if (foreg == 8 || backg == 8 || foreg == 0 || backg == 0) return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
325 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
326
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
327 miny = chop8(y);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
328 maxy = y - miny;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
329 miny = maxy;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
330 y = chop8(y);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
331
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
332 if (g_attrimode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
333 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
334 miny = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
335 maxy = 7;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
336 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
337
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
338 for (int i = miny; i <= maxy; i++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
339 {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
340 bad = 65536 + int(x / 8) + (y + i) * MX;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
341 cad = bad + MX * (MY * 8);
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
342 if (foreg >= 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
343 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
344 g_map[bad] = byte(foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
345 if (foreg >= 8 && g_map[cad] < 8) g_map[cad] = byte(g_map[cad] + 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
346 if (foreg < 8 && g_map[cad] >= 8) g_map[cad] = byte(g_map[cad] - 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
347 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
348 if (backg >= 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
349 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
350 g_map[cad] = byte(backg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
351 if (backg >= 8 && g_map[bad] < 8) g_map[bad] = byte(g_map[bad] + 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
352 if (backg < 8 && g_map[bad] >= 8) g_map[bad] = byte(g_map[bad] - 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
353 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
354 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
355 updatepoint(x, y);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
356 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
357
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
358
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
359 //multicolor color behavior
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
360 //different behavior depending on whether color area already has max colors,
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
361 //or if forcecolor is pressed.
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
362 //bit different for C64 and PLUS4M
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
363
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
364 void skaveri(int x, int y, int foreg, int backg)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
365 {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
366 int mx = int(x / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
367 int my = int(y / 8);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
368 if (g_control == false) return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
369 int cc = easygetcolor(x, y);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
370 mx = mx * 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
371 my = my * 8;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
372 for (int xx = 0; xx <= 7; xx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
373 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
374 for (int yy = 0; yy <= 7; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
375 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
376 if (easygetcolor(mx + xx, my + yy) == cc)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
377 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
378 g_map[1024 + mx + xx + (my + yy) * X] = byte(foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
379 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
380 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
381 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
382 updatepoint(x, y);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
383 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
384
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
385
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
386 void mkaveri(int x, int y, int foreg, int backg)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
387 {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
388 int mx = int(x / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
389 int my = int(y / 8);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
390 int ad, bad, cad, dad, b0, b1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
391 int f0, f1, f2, f3, free1, free2, free3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
392 int f, order, numb, suffocatelimit;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
393 int targetbit0, targetbit1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
394 order = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
395 numb = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
396 targetbit0 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
397 targetbit1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
398 suffocatelimit = 7;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
399
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
400 if (g_multic == 2) return;
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
401
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
402 f = getmultic(x, y, 0);
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
403 if (g_data[int('d')] == 1 && f != g_backg)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
404 return;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
405
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
406 cad = 65536 + mx + (my * MX);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
407
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
408 f0 = int(g_map[1]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
409 f1 = int(g_map[cad]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
410 free1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
411 f2 = int(g_map[cad + 1000]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
412 free2 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
413 f3 = int(g_map[cad + 2000]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
414 free3 = 1;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
415 if (g_machine == PLUS4M)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
416 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
417 free3 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
418 suffocatelimit = 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
419 f3 = int(g_map[2]);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
420 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
421
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
422 if (foreg == g_map[1] && g_control == false) return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
423
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
424 if (foreg != f1 && foreg != f2 && foreg != f3 || g_control == true)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
425 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
426 for (int yy = 0; yy <= 7; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
427 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
428 for (int xx = 0; xx <= 3; xx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
429 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
430 ad = 1024 + (mx * 8 + xx * 2) + (my * 8 + yy) * X;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
431 if (g_map[ad] == 0 && g_map[ad + 1] == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
432 { //00 = 00
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
433 if (f0 == f) order = 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
434 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
435 if (g_map[ad] == 1 && g_map[ad + 1] == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
436 { //01 = 10
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
437 numb = numb | 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
438 free1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
439 if (f1 == f) order = 1;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
440 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
441 if (g_map[ad] == 0 && g_map[ad + 1] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
442 { //02 = 01
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
443 numb = numb | 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
444 free2 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
445 if (f2 == f) order = 2;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
446 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
447 if (g_map[ad] == 1 && g_map[ad + 1] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
448 { //03 = 11
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
449 if (g_machine == C64M)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
450 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
451 numb = numb | 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
452 free3 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
453 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
454 if (f3 == f)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
455 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
456 order = 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
457 targetbit0 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
458 targetbit1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
459 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
460 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
461 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
462 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
463
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
464 boolean zoink = false;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
465 if (order == 4) zoink = true;
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
466 if (order == 3 && g_machine == PLUS4M) zoink = true;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
467
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
468 if ((zoink || numb != suffocatelimit) && g_control == true)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
469 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
470 if (zoink)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
471 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
472 //println("foreg:"+foreg+" f0:"+f0+" f1:"+f1+" f2:"+f2+" f3:"+f3+" free1:"+free1+" free2:"+free2+" free3:"+free3);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
473 b0 = -1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
474 b1 = -1;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
475 if (foreg == f1 && free1 == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
476 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
477 b0 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
478 b1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
479 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
480 if (foreg == f2 && free2 == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
481 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
482 b0 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
483 b1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
484 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
485 if (foreg == f3 && g_machine == C64M && free3 == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
486 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
487 b0 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
488 b1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
489 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
490 if (foreg == f3 && g_machine == PLUS4M)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
491 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
492 b0 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
493 b1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
494 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
495
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
496 if (free1 == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
497 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
498 free2 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
499 free3 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
500 b0 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
501 b1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
502 g_map[cad] = byte(foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
503 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
504 if (free2 == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
505 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
506 free3 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
507 b0 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
508 b1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
509 g_map[cad + 1000] = byte(foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
510 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
511 if (free3 == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
512 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
513 b0 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
514 b1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
515 g_map[cad + 2000] = byte(foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
516 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
517
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
518 for (int yy = 0; yy <= 7; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
519 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
520 for (int xx = 0; xx <= 3; xx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
521 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
522 ad = 1024 + (mx * 8 + xx * 2) + (my * 8 + yy) * X;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
523 if (g_map[ad] == targetbit0 && g_map[ad + 1] == targetbit1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
524 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
525 if (b0 >= 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
526 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
527 g_map[ad] = byte(b0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
528 g_map[ad + 1] = byte(b1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
529 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
530 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
531 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
532 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
533 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
534 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
535
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
536 //if all color positions are filled, we'll just change the existing one
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
537
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
538 if (numb == suffocatelimit || g_control == true)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
539 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
540 if (order == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
541 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
542 g_map[cad] = byte(foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
543 } //10==1
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
544 if (order == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
545 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
546 g_map[cad + 1000] = byte(foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
547 } //01==2
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
548 if (order == 3 && g_machine == C64M)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
549 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
550 g_map[cad + 2000] = byte(foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
551 } //11==3
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
552 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
553
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
554 //color redundancy check
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
555
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
556 for (int yy = 0; yy <= 7; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
557 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
558 for (int xx = 0; xx <= 3; xx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
559 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
560 ad = 1024 + (mx * 8 + xx * 2) + (my * 8 + yy) * X;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
561
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
562 if (g_machine == C64M)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
563 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
564 if (g_map[cad] == g_map[cad + 2000])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
565 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
566 if (g_map[ad] == 1 && g_map[ad + 1] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
567 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
568 g_map[ad] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
569 g_map[ad + 1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
570 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
571 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
572 if (g_map[cad + 1000] == g_map[cad + 2000])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
573 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
574 if (g_map[ad] == 1 && g_map[ad + 1] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
575 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
576 g_map[ad] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
577 g_map[ad + 1] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
578 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
579 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
580 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
581
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
582 if (g_map[cad] == g_map[cad + 1000])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
583 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
584 if (g_map[ad] == 0 && g_map[ad + 1] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
585 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
586 g_map[ad] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
587 g_map[ad + 1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
588 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
589 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
590 if (g_map[1] == g_map[cad])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
591 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
592 if (g_map[ad] == 1 && g_map[ad + 1] == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
593 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
594 g_map[ad] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
595 g_map[ad + 1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
596 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
597 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
598 if (g_map[1] == g_map[cad + 1000])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
599 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
600 if (g_map[ad] == 0 && g_map[ad + 1] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
601 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
602 g_map[ad] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
603 g_map[ad + 1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
604 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
605 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
606
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
607 if (g_machine == PLUS4M)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
608 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
609 if (g_map[2] == g_map[cad])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
610 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
611 if (g_map[ad] == 1 && g_map[ad + 1] == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
612 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
613 g_map[ad] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
614 g_map[ad + 1] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
615 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
616 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
617 if (g_map[2] == g_map[cad + 1000])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
618 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
619 if (g_map[ad] == 0 && g_map[ad + 1] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
620 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
621 g_map[ad] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
622 g_map[ad + 1] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
623 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
624 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
625 if (g_map[1] == g_map[2])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
626 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
627 if (g_map[ad] == 1 && g_map[ad + 1] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
628 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
629 g_map[ad] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
630 g_map[ad + 1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
631 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
632 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
633 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
634
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
635 if (g_machine == C64M)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
636 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
637 if (g_map[1] == g_map[cad + 2000])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
638 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
639 if (g_map[ad] == 1 && g_map[ad + 1] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
640 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
641 g_map[ad] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
642 g_map[ad + 1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
643 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
644 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
645 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
646 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
647 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
648 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
649 updatepoint(x, y);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
650 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
651
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
652
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
653 void kaveri(int x, int y, int foreg, int backg)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
654 {
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
655 if (g_multic == 2)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
656 return;
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
657 if (g_multic != 0 || g_hzoomer == 2 || g_data[int('d')] == 1)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
658 return;
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
659
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
660 int k_max, maxy, miny, val, ad, bad, cad;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
661 int farge0, farge1;
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
662 int mx = int(x / 8);
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
663 int my = int(y / 8);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
664
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
665 if (g_attrimode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
666 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
667 k_max = 64;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
668 miny = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
669 maxy = 7;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
670 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
671 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
672 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
673 k_max = 8;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
674 miny = chop8(y);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
675 maxy = y - miny;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
676 miny = maxy;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
677 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
678
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
679 if (g_britemode == 1 && foreg == 8)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
680 foreg = 0;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
681
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
682 //check the amount of colors in the area
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
683 //if there is only one, return & draw "normally"
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
684
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
685 if (!g_control)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
686 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
687 val = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
688
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
689 for (int yy = miny; yy <= maxy; yy++)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
690 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
691 ad = 1024 + (mx * 8) + (my * 8 + yy) * X;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
692 for (int xx = 0; xx <= 7; xx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
693 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
694 val = val + g_map[ad + xx];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
695 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
696 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
697
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
698 if (val >= k_max || val == 0)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
699 return;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
700
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
701 //check the two colors the color area is made of
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
702 //if either of the intended color already exists inside the color area, return & draw "normally"
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
703
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
704 bad = 65536 + mx + y * MX;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
705 cad = bad + MX * (MY * 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
706 farge0 = g_map[bad]; //if(g_britemode==1&&farge0==8){farge0=0;}
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
707 farge1 = g_map[cad]; //if(g_britemode==1&&farge1==8){farge1=0;}
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
708
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
709 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
710 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
711 if (farge0 < 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
712 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
713 if (foreg == farge0 + 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
714 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
715 fixattr(x, y, foreg, -1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
716 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
717 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
718 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
719 if (farge1 < 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
720 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
721 if (foreg == farge1 + 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
722 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
723 fixattr(x, y, -1, foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
724 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
725 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
726 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
727 if (farge0 >= 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
728 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
729 if (foreg == farge0 - 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
730 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
731 fixattr(x, y, foreg, -1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
732 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
733 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
734 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
735 if (farge1 >= 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
736 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
737 if (foreg == farge1 - 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
738 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
739 fixattr(x, y, -1, foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
740 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
741 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
742 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
743 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
744 if (foreg == farge0) return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
745 if (foreg == farge1) return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
746
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
747 //new IQ: simply change the underlying color into the intended one, return & draw "normally"
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
748
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
749 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
750
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
751 int piksuf;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
752 int bg, fg;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
753 piksuf = getabsa(x, y, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
754 if (g_britemode == 1 && piksuf == 8) piksuf = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
755 bad = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
756 cad = 0;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
757 for (int yy = miny; yy <= maxy; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
758 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
759 bad = 65536 + mx + (my * 8) * MX + yy * MX;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
760 cad = bad + MX * (MY * 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
761 fg = g_map[bad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
762 if (g_britemode == 1 && fg == 8) fg = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
763 bg = g_map[cad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
764 if (g_britemode == 1 && bg == 8) bg = 0;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
765 if (piksuf == fg)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
766 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
767 g_map[bad] = byte(foreg);
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
768 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
769 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
770 if (foreg > 7 && g_map[cad] < 8 && g_map[cad] != 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
771 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
772 g_map[cad] = byte(g_map[cad] + 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
773 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
774 if (foreg < 8 && g_map[cad] > 8 && foreg != 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
775 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
776 g_map[cad] = byte(g_map[cad] - 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
777 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
778 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
779 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
780 if (piksuf == bg)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
781 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
782 g_map[cad] = byte(foreg);
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
783 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
784 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
785 if (foreg > 7 && g_map[bad] < 8 && g_map[bad] != 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
786 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
787 g_map[bad] = byte(g_map[bad] + 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
788 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
789 if (foreg < 8 && g_map[bad] > 8 && foreg != 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
790 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
791 g_map[bad] = byte(g_map[bad] - 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
792 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
793 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
794 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
795 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
796
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
797 // if the result is same color, zero the pixel data
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
798
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
799 if (g_map[bad] == g_map[cad])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
800 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
801 for (int yy = miny; yy <= maxy; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
802 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
803 for (int xx = 0; xx <= 7; xx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
804 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
805 ad = 1024 + (mx * 8 + xx) + (my * 8 + yy) * X;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
806 g_map[ad] = byte(0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
807 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
808 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
809 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
810 updatepoint(x, y);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
811 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
812
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
813
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
814 void kaveri_iq(int x, int y, int f1, int f2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
815 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
816 int k_xx, k_yy, k_ad, k_bad, k_ojox, k_ojoy, k_miny, k_maxy, k_xv, k_yv;
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
817 int k_c1, k_c2, k_v0, k_v1, k_tipping, k_maximum, exist;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
818 byte k_p;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
819
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
820 if (g_multic != 0 || g_hzoomer == 2)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
821 return;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
822
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
823 exist = getabsa(x, y, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
824
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
825 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
826 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
827 if (exist == 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
828 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
829 if (g_farge < 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
830 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
831 exist = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
832 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
833 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
834 if (exist == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
835 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
836 if (g_farge > 7)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
837 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
838 exist = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
839 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
840 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
841 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
842
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
843 k_v0 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
844 k_v1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
845 k_tipping = 4;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
846 k_xx = chop8(x);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
847 k_yy = k_yy * 8;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
848 k_ojox = int(x / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
849 k_ojoy = int(y / 8);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
850 k_ojox = k_ojox * 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
851 k_ojoy = k_ojoy * 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
852 k_miny = (y - k_ojoy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
853 k_maxy = k_miny;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
854 k_maximum = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
855
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
856 if (g_attrimode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
857 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
858 k_miny = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
859 k_maxy = 7;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
860 k_tipping = 32;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
861 k_maximum = 64;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
862 } //spectrum&c64 style
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
863
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
864 k_ad = 65536 + k_xx + (k_yy + k_miny) * MX;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
865 k_bad = k_ad + MX * (MY * 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
866 k_c1 = g_map[k_ad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
867 k_c2 = g_map[k_bad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
868
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
869 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
870 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
871 if (k_c1 == 8) k_c1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
872 if (k_c2 == 8) k_c2 = 0;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
873 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
874
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
875 k_bad = 1024 + k_xx * 8 + k_yy * X;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
876
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
877 //do we have more 0's or 1's
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
878 for (k_yv = k_miny; k_yv <= k_maxy; k_yv++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
879 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
880 k_ad = k_bad + k_yv * X;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
881 for (k_xv = 0; k_xv <= 7; k_xv++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
882 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
883 if (g_map[k_ad] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
884 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
885 k_v1++;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
886 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
887 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
888 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
889 k_v0++;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
890 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
891 k_ad++;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
892 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
893 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
894
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
895 //force color
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
896
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
897 if (g_control)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
898 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
899
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
900 k_v1 = k_tipping + 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
901
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
902 if (k_c1 == exist)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
903 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
904 k_c1 = g_farge;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
905 if (k_c1 == 8 && g_britemode == 1) k_c1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
906 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
907 if (k_c2 == exist)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
908 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
909 k_c2 = g_farge;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
910 if (k_c2 == 8 && g_britemode == 1) k_c2 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
911 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
912
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
913 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
914 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
915 if (g_farge >= 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
916 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
917 if (k_c1 <= 7) k_c1 = k_c1 + 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
918 if (k_c2 <= 7) k_c2 = k_c2 + 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
919 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
920 if (g_farge <= 7)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
921 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
922 if (k_c1 >= 8) k_c1 = k_c1 - 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
923 if (k_c2 >= 8) k_c2 = k_c2 - 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
924 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
925 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
926
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
927 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
928
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
929 if (k_v1 > k_tipping)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
930 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
931 for (k_yv = k_miny; k_yv <= k_maxy; k_yv++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
932 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
933 k_ad = 65536 + k_xx + (k_yy + k_yv) * MX;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
934 k_bad = k_ad + MX * (MY * 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
935 g_map[k_ad] = byte(k_c2);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
936 g_map[k_bad] = byte(k_c1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
937 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
938 for (k_yv = k_miny; k_yv <= k_maxy; k_yv++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
939 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
940 k_ad = 1024 + k_xx * 8 + (k_yy + k_yv) * X;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
941 for (k_xv = 0; k_xv <= 7; k_xv++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
942 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
943 k_p = g_map[k_ad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
944 g_map[k_ad] = byte(1 - k_p);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
945 if (k_c1 == k_c2) g_map[k_ad] = byte(0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
946 k_ad++;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
947 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
948 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
949 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
950 updatepoint(x, y);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
951 }