annotate draw_inputs.pde @ 233:1d9f9c3d8ab1

Fixes to multicolor/pixelw==2 flood fill.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 06 Sep 2018 13:25:15 +0300
parents 1c9deae71fb1
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 // Collect all that "reads" the virtual image in some way or other
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
2 // plus other passive manipulations
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
3
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
4 int odd(int v)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
5 {
20
72407a4d9539 Cleanup / optimize.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
6 return (v & 1);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
7 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
8
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
9
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
10 int even(int v)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
11 {
20
72407a4d9539 Cleanup / optimize.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
12 return 1 - (v & 1);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
13 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
14
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
15
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
16 float getangel(float xx, float yy)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
17 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
18 float ang = degrees(atan2(xx, -yy));
20
72407a4d9539 Cleanup / optimize.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
19 return (ang < 0) ? 360 + ang : ang;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
20 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
21
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
22
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
23 int zxcolor(int col)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
24 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
25 //something that allows different zx brightness colors treated logically as the same
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
26 //i.e. bright red and dark red the same. handy for brush transparency
167
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
27 if (g_britemode == 0)
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
28 return col;
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
29 else
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
30 return (col > 7) ? col - 8 : col;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
31 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
32
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
33
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
34 //the "slow" call to mark "dirty block"
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
35 void updatepoint(int xx, int yy)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
36 {
167
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
37 if (yy < 0 || xx < 0 || xx >= X || yy >= Y)
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
38 return;
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
39
20
72407a4d9539 Cleanup / optimize.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
40 int ad = int(xx / 8) + int(yy / 8) * MX;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
41 g_redo[ad] = byte(0); //block update
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
42 g_remdo[ad] = byte(1); //block update
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
43 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
44
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
45
167
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
46 int getmultibrush(int xc, int yc)
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
47 {
167
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
48 //returns the multicolor color on point xc,yc at brush
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
49 int ad, looks, mmc;
167
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
50 if (g_multic == 2) return g_brush[1024 + xc + yc * X];
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
51
167
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
52 ad = 1024 + xc + yc * X;
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
53 looks = 65536 + int(xc / 8) + int(yc / 8) * MX;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
54 mmc = g_brush[ad] + g_brush[ad + 1] * 2;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
55 switch (mmc)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
56 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
57 case 0:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
58 return g_map[1];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
59 case 1:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
60 return g_brush[looks];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
61 case 2:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
62 return g_brush[looks + 1000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
63 case 3:
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
64 if (g_machine == PLUS4M) return int(g_map[2]);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
65 return g_brush[looks + 2000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
66 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
67 return g_brush[ad] + g_brush[ad + 1] * 2;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
68 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
69
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
70
167
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
71 int getmultic(int xc, int yc, int mode) //mode 0=screen 1=brush
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
72 {
167
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
73 //returns the multicolor color on point xc,yc
211
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
74 int ad = 1024 + xc + yc * X;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
75
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
76 if (g_multic == 2)
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
77 {
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
78 if (mode == 0) return g_map[ad];
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
79 if (mode == 1) return g_brush[ad];
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
80 }
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
81
211
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
82 int source1 = 0,
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
83 source2 = 0,
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
84 looks = 65536 + int(chop2(xc) / 8) + int(yc / 8) * MX;
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
85
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
86 if (mode == 0)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
87 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
88 source1 = g_map[ad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
89 source2 = g_map[ad + 1];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
90 }
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
91 else
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
92 if (mode == 1)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
93 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
94 source1 = g_brush[ad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
95 source2 = g_brush[ad + 1];
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
96 }
167
8d239bd81584 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
97
211
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
98 int mmc = source1 + source2 * 2;
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
99
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
100 //source1=0
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
101 //source2=+1
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
102 //00=zeroc =0
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
103 //01=color1=2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
104 //10=color2=1
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
105 //11=color3=3
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
106
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
107 if (mode == 0)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
108 {
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
109 switch (mmc)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
110 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
111 case 0:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
112 return g_map[1];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
113 case 1:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
114 return g_map[looks];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
115 case 2:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
116 return g_map[looks + 1000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
117 case 3:
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
118 if (g_machine == PLUS4M) return int(g_map[2]);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
119 return g_map[looks + 2000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
120 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
121 }
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
122 else
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
123 if (mode == 1)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
124 {
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
125 switch (mmc)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
126 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
127 case 0:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
128 return g_map[1];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
129 case 1:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
130 return g_brush[looks];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
131 case 2:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
132 return g_brush[looks + 1000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
133 case 3:
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
134 if (g_machine == PLUS4M) return int(g_map[2]);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
135 return g_brush[looks + 2000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
136 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
137 }
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
138
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
139 return source1 + source2;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
140 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
141
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
142
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
143 int getattra(int xx, int yy, int mode) //mode foreground backround
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
144 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
145 //returns the internal foreground / background color on point xx,yy
211
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
146 if (g_multic == 2)
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
147 {
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
148 return (mode == 0) ? getmultic(xx, yy, 0) : g_backg;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
149 }
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
150 else
211
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
151 if (g_multic == 1)
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
152 {
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
153 return (mode == 0) ? getmultic(xx, yy, 0) : g_map[1]; // was 0?
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
154 }
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
155
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
156 // XXX ! is this correct? yv is not used
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
157 int val,
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
158 xv = int(xx / 8),
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
159 yv = int(yy / 8);
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
160
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
161 int ad = 65536 + xv + yy * MX;
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
162 if (mode == 0)
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
163 val = g_map[ad];
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
164 else
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
165 val = g_map[ad + (MX * MY) * 8];
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
166
211
6d866e284dd2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
167 return (g_britemode == 1 && val == 8) ? 0 : val;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
168 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
169
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
170
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
171 int getabsa(int xx, int yy, int mode) //mode 0=screen 1=brush
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
172 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
173 // returns the visible colour on point xx,yy
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
174 int ssap, val = 0,
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
175 sad = 1024 + xx + yy * X,
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
176 ad = 65536 + int(xx / 8) + yy * MX;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
177
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
178 int chek = int(g_map[sad]);
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
179 if (chek == 100 || chek == 200)
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
180 return chek;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
181
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
182 if (mode == 0)
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
183 ssap = int(g_map[sad]);
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
184 else
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
185 ssap = int(g_brush[sad]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
186
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
187 if (ssap == 1)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
188 {
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
189 if (mode == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
190 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
191 val = g_map[ad];
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
192 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
193 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
194 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
195 val = g_brush[ad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
196 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
197 if (g_britemode == 1 && val == 8) return 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
198 return val;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
199 }
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
200 else
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
201 if (ssap == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
202 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
203 if (mode == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
204 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
205 val = g_map[ad + (MX * MY) * 8];
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
206 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
207 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
208 {
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
209 val = g_brush[ad + (MX * MY) * 8];
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
210 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
211 if (g_britemode == 1 && val == 8) return 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
212 return val;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
213 }
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
214 else
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
215 return g_map[sad];
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
216 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
217
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
218
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
219 //the most accessible way to get a color index from a point
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
220 int easygetcolor(int xx, int yy)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
221 {
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
222 if (yy < 0 || xx < 0 || xx >= X || yy >= Y)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
223 return 0;
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
224 else
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
225 if (g_multic > 0)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
226 return getmultic(xx, yy, 0);
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
227 else
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
228 return getabsa(xx, yy, 0);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
229 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
230
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
231
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
232 void infersize()
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
233 {
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
234 int xx, yy, cp, okay;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
235 int bx, by;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
236 storeparameters();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
237 xx = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
238 okay = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
239 cp = easygetcolor(0, 0);
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
240 for (xx = 0; xx < X; xx = xx + g_pixelw)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
241 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
242 if (easygetcolor(xx, 0) == cp && okay == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
243 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
244 g_animx = xx;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
245 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
246 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
247 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
248 okay = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
249 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
250 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
251 okay = 0;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
252 for (yy = 0; yy < Y; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
253 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
254 if (easygetcolor(0, yy) == cp && okay == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
255 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
256 g_animy = yy;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
257 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
258 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
259 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
260 okay = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
261 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
262 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
263
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
264 g_animx = g_animx + g_pixelw;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
265 g_animy = g_animy + 1;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
266 if (g_animx > 63 || g_animy > 63 || g_animx <= 2 || g_animy <= 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
267 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
268 message("BAD SIZE|See manual");
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
269 restoreparameters();
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
270 g_data[int('n')] = 0;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
271 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
272 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
273 int boldsourcex = g_bsourcex;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
274 int boldsourcey = g_bsourcey;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
275 int boldsourcex2 = g_bsourcex2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
276 int boldsourcey2 = g_bsourcey2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
277
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
278 g_bsourcex = g_animx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
279 g_bsourcey = 0;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
280 g_bsourcex2 = g_animx + g_animx - g_pixelw;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
281 g_bsourcey2 = g_animy - 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
282 g_animframes = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
283 g_animno = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
284 int raamit = -1;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
285 for (yy = 0; yy <= Y; yy = yy + g_animy)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
286 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
287 for (xx = 0; xx <= X; xx = xx + g_animx)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
288 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
289 okay = 1;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
290 for (bx = 0; bx < g_animx; bx = bx + g_pixelw)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
291 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
292 for (by = 0; by < g_animy; by++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
293 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
294 if (easygetcolor(xx + bx, yy + by) != cp) okay = 0;
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 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
297 if (okay == 1 && g_animframes <= 1) g_animframes = raamit;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
298 if (xx + g_animx < X || xx + g_animx == X) raamit++;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
299 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
300 }
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
301 if (g_animframes <= 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
302 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
303 message("BAD BOOKEND|See manual");
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
304 restoreparameters();
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
305 g_data[int('n')] = 0;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
306 g_bsourcex = boldsourcex;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
307 g_bsourcey = boldsourcey;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
308 g_bsourcex2 = boldsourcex2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
309 g_bsourcey2 = boldsourcey2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
310 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
311 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
312 message("Play Brush|" + g_animx + " x " + g_animy + "|" + g_animframes + " frames");
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
313 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
314
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
315
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
316 void animbrush_do()
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
317 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
318 int bx, by;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
319 int horisize;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
320 horisize = int(X / g_animx);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
321 g_animno = g_animno + 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
322 if (g_animno > g_animframes) g_animno = 1;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
323 by = int(g_animno / horisize);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
324 bx = g_animno - (by * horisize);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
325 g_bsourcex = bx * g_animx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
326 g_bsourcey = by * g_animy;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
327 g_bsourcex2 = g_bsourcex + g_animx - g_pixelw;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
328 g_bsourcey2 = g_bsourcey + g_animy - 1;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
329 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
330
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
331 void set_fixed_raster(int set)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
332 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
333 for (int i = 0; i < 64; i++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
334 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
335 g_fixedraster[i] = g_rasterpatterns[set * 64 + i];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
336 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
337 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
338
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
339 int get_raster(int xx, int yy)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
340 {
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
341 xx = xx + g_raster_offset_x * g_pixelw;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
342 yy = yy + g_raster_offset_y;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
343 if (g_pixelw == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
344 {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
345 xx = int(xx / 2);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
346 }
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
347 int mx = chop8(xx);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
348 int my = chop8(yy);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
349 xx = xx - mx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
350 yy = yy - my;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
351 return g_fixedraster[xx + yy * 8];
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
352 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
353
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
354 void refreshpalette()
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
355 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
356 //relevant for alterable palettes, such as amiga or cpc
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
357 if (g_palsteps == 0) return;
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
358 for (int i = 0; i < g_maxcolors; i++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 211
diff changeset
359 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
360 makecolor(i, int(g_map[256 + i * 3]), int(g_map[256 + i * 3 + 1]), int(g_map[256 + i * 3 + 2]));
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
361 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
362 }