annotate draw_smart.pde @ 244:c7748c19e1ff default tip

Update notes.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 23 Oct 2018 11:34:25 +0300
parents 3a85cf4a4fef
children
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 {
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
320 int miny, maxy;
2
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 {
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
340 int bad = 65536 + int(x / 8) + (y + i) * MX,
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
341 cad = bad + MX * (MY * 8);
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
342
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
343 if (foreg >= 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
344 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
345 g_map[bad] = byte(foreg);
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 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
348 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
349 if (backg >= 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
350 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
351 g_map[cad] = byte(backg);
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 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
354 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
355 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
356 updatepoint(x, y);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
357 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
358
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
359
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
360 //multicolor color behavior
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
361 //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
362 //or if forcecolor is pressed.
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
363 //bit different for C64 and PLUS4M
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
364
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
365 void skaveri(int x, int y, int foreg, int backg)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
366 {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
367 int mx = int(x / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
368 int my = int(y / 8);
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
369
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
370 if (g_control == false)
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
371 return;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
372
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
373 int cc = easygetcolor(x, y);
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
374 mx *= 8;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
375 my *= 8;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
376
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
377 for (int xx = 0; xx <= 7; xx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
378 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
379 for (int yy = 0; yy <= 7; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
380 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
381 if (easygetcolor(mx + xx, my + yy) == cc)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
382 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
383 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
384 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
385 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
386 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
387 updatepoint(x, y);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
388 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
389
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
390
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
391 void mkaveri(int x, int y, int foreg, int backg)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
392 {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
393 int mx = int(x / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
394 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
395 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
396 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
397 int f, order, numb, suffocatelimit;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
398 int targetbit0, targetbit1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
399 order = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
400 numb = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
401 targetbit0 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
402 targetbit1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
403 suffocatelimit = 7;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
404
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
405 if (g_multic == 2) return;
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
406
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
407 f = getmultic(x, y, 0);
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
408 if (g_data[int('d')] == 1 && f != g_backg)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
409 return;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
410
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
411 cad = 65536 + mx + (my * MX);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
412
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
413 f0 = int(g_map[1]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
414 f1 = int(g_map[cad]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
415 free1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
416 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
417 free2 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
418 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
419 free3 = 1;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
420 if (g_machine == PLUS4M)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
421 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
422 free3 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
423 suffocatelimit = 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
424 f3 = int(g_map[2]);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
425 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
426
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
427 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
428
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
429 if (foreg != f1 && foreg != f2 && foreg != f3 || g_control == true)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
430 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
431 for (int yy = 0; yy <= 7; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
432 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
433 for (int xx = 0; xx <= 3; xx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
434 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
435 ad = 1024 + (mx * 8 + xx * 2) + (my * 8 + yy) * X;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
436 if (g_map[ad] == 0 && g_map[ad + 1] == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
437 { //00 = 00
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
438 if (f0 == f) order = 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
439 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
440 if (g_map[ad] == 1 && g_map[ad + 1] == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
441 { //01 = 10
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
442 numb = numb | 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
443 free1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
444 if (f1 == f) order = 1;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
445 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
446 if (g_map[ad] == 0 && g_map[ad + 1] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
447 { //02 = 01
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
448 numb = numb | 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
449 free2 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
450 if (f2 == f) order = 2;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
451 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
452 if (g_map[ad] == 1 && g_map[ad + 1] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
453 { //03 = 11
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
454 if (g_machine == C64M)
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 numb = numb | 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
457 free3 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
458 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
459 if (f3 == f)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
460 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
461 order = 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
462 targetbit0 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
463 targetbit1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
464 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
465 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
466 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
467 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
468
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
469 boolean zoink = false;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
470 if (order == 4) zoink = true;
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
471 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
472
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
473 if ((zoink || numb != suffocatelimit) && g_control == true)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
474 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
475 if (zoink)
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 //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
478 b0 = -1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
479 b1 = -1;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
480 if (foreg == f1 && free1 == 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 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
483 b1 = 0;
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 == f2 && free2 == 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 = 0;
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 == C64M && free3 == 0)
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 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
495 if (foreg == f3 && g_machine == PLUS4M)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
496 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
497 b0 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
498 b1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
499 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
500
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
501 if (free1 == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
502 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
503 free2 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
504 free3 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
505 b0 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
506 b1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
507 g_map[cad] = byte(foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
508 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
509 if (free2 == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
510 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
511 free3 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
512 b0 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
513 b1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
514 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
515 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
516 if (free3 == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
517 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
518 b0 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
519 b1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
520 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
521 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
522
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
523 for (int yy = 0; yy <= 7; yy++)
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
524 for (int xx = 0; xx <= 3; xx++)
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
525 {
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
526 ad = 1024 + (mx * 8 + xx * 2) + (my * 8 + yy) * X;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
527 if (g_map[ad] == targetbit0 && g_map[ad + 1] == targetbit1)
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
528 {
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
529 if (b0 >= 0)
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
530 {
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
531 g_map[ad] = byte(b0);
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
532 g_map[ad + 1] = byte(b1);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
533 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
534 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
535 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
536 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
537 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
538
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
539 //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
540
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
541 if (numb == suffocatelimit || g_control == true)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
542 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
543 if (order == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
544 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
545 g_map[cad] = byte(foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
546 } //10==1
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
547 if (order == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
548 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
549 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
550 } //01==2
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
551 if (order == 3 && g_machine == C64M)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
552 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
553 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
554 } //11==3
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
555 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
556
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
557 //color redundancy check
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
558
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
559 for (int yy = 0; yy <= 7; yy++)
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
560 for (int xx = 0; xx <= 3; xx++)
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
561 {
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
562 ad = 1024 + (mx * 8 + xx * 2) + (my * 8 + yy) * X;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
563
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
564 if (g_machine == C64M)
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
565 {
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
566 if (g_map[cad] == g_map[cad + 2000])
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
567 {
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
568 if (g_map[ad] == 1 && g_map[ad + 1] == 1)
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
569 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
570 g_map[ad] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
571 g_map[ad + 1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
572 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
573 }
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
574 if (g_map[cad + 1000] == g_map[cad + 2000])
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
575 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
576 if (g_map[ad] == 1 && g_map[ad + 1] == 1)
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
577 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
578 g_map[ad] = 0;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
579 g_map[ad + 1] = 1;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
580 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
581 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
582 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
583
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
584 if (g_map[cad] == g_map[cad + 1000])
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
585 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
586 if (g_map[ad] == 0 && g_map[ad + 1] == 1)
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
587 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
588 g_map[ad] = 1;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
589 g_map[ad + 1] = 0;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
590 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
591 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
592 if (g_map[1] == g_map[cad])
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
593 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
594 if (g_map[ad] == 1 && g_map[ad + 1] == 0)
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
595 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
596 g_map[ad] = 0;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
597 g_map[ad + 1] = 0;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
598 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
599 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
600 if (g_map[1] == g_map[cad + 1000])
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
601 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
602 if (g_map[ad] == 0 && g_map[ad + 1] == 1)
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
603 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
604 g_map[ad] = 0;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
605 g_map[ad + 1] = 0;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
606 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
607 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
608
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
609 if (g_machine == PLUS4M)
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
610 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
611 if (g_map[2] == g_map[cad])
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
612 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
613 if (g_map[ad] == 1 && g_map[ad + 1] == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
614 {
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
615 g_map[ad] = 1;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
616 g_map[ad + 1] = 1;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
617 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
618 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
619 if (g_map[2] == g_map[cad + 1000])
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
620 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
621 if (g_map[ad] == 0 && g_map[ad + 1] == 1)
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
622 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
623 g_map[ad] = 1;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
624 g_map[ad + 1] = 1;
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
625 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
626 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
627 if (g_map[1] == g_map[2])
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
628 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
629 if (g_map[ad] == 1 && g_map[ad + 1] == 1)
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
630 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
631 g_map[ad] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
632 g_map[ad + 1] = 0;
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 }
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
635 }
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
636
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
637 if (g_machine == C64M)
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
638 {
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
639 if (g_map[1] == g_map[cad + 2000])
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
640 {
238
3a85cf4a4fef Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 237
diff changeset
641 if (g_map[ad] == 1 && g_map[ad + 1] == 1)
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
642 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
643 g_map[ad] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
644 g_map[ad + 1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
645 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
646 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
647 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
648 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
649 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
650 updatepoint(x, y);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
651 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
652
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
653
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
654 void kaveri(int x, int y, int foreg, int backg)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
655 {
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
656 if (g_multic == 2)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
657 return;
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
658 if (g_multic != 0 || g_hzoomer == 2 || g_data[int('d')] == 1)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
659 return;
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
660
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
661 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
662 int farge0, farge1;
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
663 int mx = int(x / 8);
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
664 int my = int(y / 8);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
665
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
666 if (g_attrimode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
667 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
668 k_max = 64;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
669 miny = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
670 maxy = 7;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
671 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
672 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
673 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
674 k_max = 8;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
675 miny = chop8(y);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
676 maxy = y - miny;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
677 miny = maxy;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
678 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
679
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
680 if (g_britemode == 1 && foreg == 8)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
681 foreg = 0;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
682
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
683 //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
684 //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
685
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
686 if (!g_control)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
687 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
688 val = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
689
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
690 for (int yy = miny; yy <= maxy; yy++)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
691 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
692 ad = 1024 + (mx * 8) + (my * 8 + yy) * X;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
693 for (int xx = 0; xx <= 7; xx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
694 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
695 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
696 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
697 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
698
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
699 if (val >= k_max || val == 0)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
700 return;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
701
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
702 //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
703 //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
704
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
705 bad = 65536 + mx + y * MX;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
706 cad = bad + MX * (MY * 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
707 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
708 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
709
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
710 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
711 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
712 if (farge0 < 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
713 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
714 if (foreg == farge0 + 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
715 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
716 fixattr(x, y, foreg, -1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
717 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
718 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
719 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
720 if (farge1 < 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
721 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
722 if (foreg == farge1 + 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
723 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
724 fixattr(x, y, -1, foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
725 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
726 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
727 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
728 if (farge0 >= 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
729 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
730 if (foreg == farge0 - 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
731 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
732 fixattr(x, y, foreg, -1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
733 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
734 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
735 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
736 if (farge1 >= 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
737 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
738 if (foreg == farge1 - 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
739 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
740 fixattr(x, y, -1, foreg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
741 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
742 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
743 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
744 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
745 if (foreg == farge0) return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
746 if (foreg == farge1) return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
747
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
748 //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
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
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
752 int piksuf;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
753 int bg, fg;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
754 piksuf = getabsa(x, y, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
755 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
756 bad = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
757 cad = 0;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
758 for (int yy = miny; yy <= maxy; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
759 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
760 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
761 cad = bad + MX * (MY * 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
762 fg = g_map[bad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
763 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
764 bg = g_map[cad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
765 if (g_britemode == 1 && bg == 8) bg = 0;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
766 if (piksuf == fg)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
767 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
768 g_map[bad] = byte(foreg);
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
769 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
770 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
771 if (foreg > 7 && g_map[cad] < 8 && g_map[cad] != 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
772 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
773 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
774 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
775 if (foreg < 8 && g_map[cad] > 8 && foreg != 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
776 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
777 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
778 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
779 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
780 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
781 if (piksuf == bg)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
782 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
783 g_map[cad] = byte(foreg);
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
784 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
785 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
786 if (foreg > 7 && g_map[bad] < 8 && g_map[bad] != 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
787 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
788 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
789 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
790 if (foreg < 8 && g_map[bad] > 8 && foreg != 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
791 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
792 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
793 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
794 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
795 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
796 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
797
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
798 // 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
799
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
800 if (g_map[bad] == g_map[cad])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
801 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
802 for (int yy = miny; yy <= maxy; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
803 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
804 for (int xx = 0; xx <= 7; xx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
805 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
806 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
807 g_map[ad] = byte(0);
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 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
811 updatepoint(x, y);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
812 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
813
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
814
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
815 void kaveri_iq(int x, int y, int f1, int f2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
816 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
817 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
818 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
819 byte k_p;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
820
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
821 if (g_multic != 0 || g_hzoomer == 2)
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
822 return;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
823
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
824 exist = getabsa(x, y, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
825
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
826 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
827 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
828 if (exist == 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
829 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
830 if (g_farge < 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
831 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
832 exist = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
833 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
834 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
835 if (exist == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
836 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
837 if (g_farge > 7)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
838 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
839 exist = 0;
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 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
842 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
843
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
844 k_v0 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
845 k_v1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
846 k_tipping = 4;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
847 k_xx = chop8(x);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
848 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
849 k_ojox = int(x / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
850 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
851 k_ojox = k_ojox * 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
852 k_ojoy = k_ojoy * 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
853 k_miny = (y - k_ojoy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
854 k_maxy = k_miny;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
855 k_maximum = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
856
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
857 if (g_attrimode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
858 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
859 k_miny = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
860 k_maxy = 7;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
861 k_tipping = 32;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
862 k_maximum = 64;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
863 } //spectrum&c64 style
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
864
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
865 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
866 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
867 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
868 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
869
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
870 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
871 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
872 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
873 if (k_c2 == 8) k_c2 = 0;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
874 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
875
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
876 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
877
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
878 //do we have more 0's or 1's
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
879 for (k_yv = k_miny; k_yv <= k_maxy; k_yv++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
880 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
881 k_ad = k_bad + k_yv * X;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
882 for (k_xv = 0; k_xv <= 7; k_xv++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
883 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
884 if (g_map[k_ad] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
885 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
886 k_v1++;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
887 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
888 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
889 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
890 k_v0++;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
891 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
892 k_ad++;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
893 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
894 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
895
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
896 //force color
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
897
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
898 if (g_control)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
899 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
900
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
901 k_v1 = k_tipping + 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
902
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
903 if (k_c1 == exist)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
904 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
905 k_c1 = g_farge;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
906 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
907 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
908 if (k_c2 == exist)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
909 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
910 k_c2 = g_farge;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
911 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
912 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
913
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
914 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
915 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
916 if (g_farge >= 8)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
917 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
918 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
919 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
920 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
921 if (g_farge <= 7)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
922 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
923 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
924 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
925 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
926 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
927
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
928 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
929
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
930 if (k_v1 > k_tipping)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
931 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
932 for (k_yv = k_miny; k_yv <= k_maxy; k_yv++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
933 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
934 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
935 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
936 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
937 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
938 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
939 for (k_yv = k_miny; k_yv <= k_maxy; k_yv++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
940 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
941 k_ad = 1024 + k_xx * 8 + (k_yy + k_yv) * X;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
942 for (k_xv = 0; k_xv <= 7; k_xv++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
943 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
944 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
945 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
946 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
947 k_ad++;
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 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
951 updatepoint(x, y);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
952 }