annotate draw_inputs.pde @ 150:d7c13f427178

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 14 Aug 2018 15:50:15 +0300
parents 0c2610e112c3
children 8d239bd81584
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
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
27 if (g_britemode == 0) return col;
20
72407a4d9539 Cleanup / optimize.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
28 return (col > 7) ? col - 8 : col;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
29 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
30
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
31
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
32 //the "slow" call to mark "dirty block"
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
33 void updatepoint(int xx, int yy)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
34 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
35 if (yy < 0 || xx < 0 || xx >= X || yy >= Y) return;
20
72407a4d9539 Cleanup / optimize.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
36 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
37 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
38 g_remdo[ad] = byte(1); //block update
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
39 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
40
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
41
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
42 int getmultibrush(int x1, int y1)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
43 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
44 //returns the multicolor color on point x1,y1 at brush
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
45 int ad, looks, mmc;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
46 if (g_multic == 2) return g_brush[1024 + x1 + y1 * X];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
47
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
48 ad = 1024 + x1 + y1 * X;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
49 looks = 65536 + int(x1 / 8) + int(y1 / 8) * MX;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
50 mmc = g_brush[ad] + g_brush[ad + 1] * 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
51 switch (mmc) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
52 case 0:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
53 return g_map[1];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
54 case 1:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
55 return g_brush[looks];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
56 case 2:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
57 return g_brush[looks + 1000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
58 case 3:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
59 if (machine == PLUS4M) return int(g_map[2]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
60 return g_brush[looks + 2000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
61 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
62 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
63 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
64
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
65
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
66 int getmultic(int x1, int y1, int mode) //mode 0=screen 1=brush
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
67 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
68 //returns the multicolor color on point x1,y1
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
69 int ad, looks, mmc, source1, source2;
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
70 ad = 1024 + x1 + y1 * X;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
71
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
72 if (g_multic == 2)
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
73 {
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
74 if (mode == 0) return g_map[ad];
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
75 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
76 }
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
77
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
78 source1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
79 source2 = 0;
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
80
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
81 x1 = chop2(x1);
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
82 looks = 65536 + int(x1 / 8) + int(y1 / 8) * MX;
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
83
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
84 if (mode == 0)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
85 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
86 source1 = g_map[ad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
87 source2 = g_map[ad + 1];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
88 }
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
89 else
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
90 if (mode == 1)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
91 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
92 source1 = g_brush[ad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
93 source2 = g_brush[ad + 1];
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
94 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
95 mmc = source1 + source2 * 2;
45
9b77ed046003 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
96
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
97 //source1=0
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
98 //source2=+1
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
99 //00=zeroc =0
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
100 //01=color1=2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
101 //10=color2=1
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
102 //11=color3=3
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
103
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
104 if (mode == 0)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
105 {
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
106 switch (mmc)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
107 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
108 case 0:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
109 return g_map[1];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
110 case 1:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
111 return g_map[looks];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
112 case 2:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
113 return g_map[looks + 1000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
114 case 3:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
115 if (machine == PLUS4M) return int(g_map[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 + 2000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
117 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
118 }
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
119 else
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
120 if (mode == 1)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
121 {
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
122 switch (mmc)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
123 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
124 case 0:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
125 return g_map[1];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
126 case 1:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
127 return g_brush[looks];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
128 case 2:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
129 return g_brush[looks + 1000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
130 case 3:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
131 if (machine == PLUS4M) return int(g_map[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 + 2000];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
133 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
134 }
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
135
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
136 return source1 + source2;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
137 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
138
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
139
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
140 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
141 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
142 //returns the internal foreground / background color on point xx,yy
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
143 if (g_multic == 2) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
144 if (mode == 0) return getmultic(xx, yy, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
145 return g_backg;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
146 }
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
147 else
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
148 if (g_multic == 1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
149 if (mode == 0) return getmultic(xx, yy, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
150 return g_map[1]; // was 0?
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
151 }
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
152
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
153 // XXX ! is this correct? yv is not used
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
154 int val,
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
155 xv = int(xx / 8),
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
156 yv = int(yy / 8);
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
157
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
158 int ad = 65536 + xv + yy * MX;
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
159 if (mode == 0)
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
160 val = g_map[ad];
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
161 else
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
162 val = g_map[ad + (MX * MY) * 8];
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
163
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
164 if (g_britemode == 1 && val == 8)
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
165 return 0;
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
166 else
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
167 return 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 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
189 if (mode == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
190 val = g_map[ad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
191 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
192 val = g_brush[ad];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
193 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
194 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
195 return val;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
196 }
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
197 else
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
198 if (ssap == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
199 if (mode == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
200 val = g_map[ad + (MX * MY) * 8];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
201 } else {
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
202 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
203 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
204 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
205 return val;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
206 }
140
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
207 else
0c2610e112c3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
208 return g_map[sad];
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
209 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
210
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
211
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
212 //the most accessible way to get a color index from a point
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
213 int easygetcolor(int xx, int yy)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
214 {
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
215 if (yy < 0 || xx < 0 || xx >= X || yy >= Y)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
216 return 0;
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
217 else
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
218 if (g_multic > 0)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
219 return getmultic(xx, yy, 0);
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
220 else
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
221 if (g_multic == 0)
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
222 return getabsa(xx, yy, 0);
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
223 else
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
224 return 0;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
225 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
226
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
227
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
228 void infersize()
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
229 {
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
230 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
231 int bx, by;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
232 storeparameters();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
233 xx = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
234 okay = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
235 cp = easygetcolor(0, 0);
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
236 for (xx = 0; xx < X; xx = xx + g_pixelw) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
237 if (easygetcolor(xx, 0) == cp && okay == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
238 g_animx = xx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
239 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
240 okay = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
241 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
242 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
243 okay = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
244 for (yy = 0; yy < Y; yy++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
245 if (easygetcolor(0, yy) == cp && okay == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
246 g_animy = yy;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
247 } else {
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 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
251
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
252 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
253 g_animy = g_animy + 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
254 if (g_animx > 63 || g_animy > 63 || g_animx <= 2 || g_animy <= 2) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
255 message("BAD SIZE|See manual");
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
256 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
257 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
258 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
259 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
260 int boldsourcex = g_bsourcex;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
261 int boldsourcey = g_bsourcey;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
262 int boldsourcex2 = g_bsourcex2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
263 int boldsourcey2 = g_bsourcey2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
264
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
265 g_bsourcex = g_animx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
266 g_bsourcey = 0;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
267 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
268 g_bsourcey2 = g_animy - 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
269 g_animframes = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
270 g_animno = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
271 int raamit = -1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
272 for (yy = 0; yy <= Y; yy = yy + g_animy) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
273 for (xx = 0; xx <= X; xx = xx + g_animx) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
274 okay = 1;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
275 for (bx = 0; bx < g_animx; bx = bx + g_pixelw) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
276 for (by = 0; by < g_animy; by++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
277 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
278 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
279 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
280 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
281 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
282 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
283 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
284 if (g_animframes <= 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
285 message("BAD BOOKEND|See manual");
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
286 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
287 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
288 g_bsourcex = boldsourcex;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
289 g_bsourcey = boldsourcey;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
290 g_bsourcex2 = boldsourcex2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
291 g_bsourcey2 = boldsourcey2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
292 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
293 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
294 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
295 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
296
139
e899ca447a69 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
297
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
298 void animbrush_do() {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
299 int bx, by;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
300 int horisize;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
301 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
302 g_animno = g_animno + 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
303 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
304 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
305 bx = g_animno - (by * horisize);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
306 g_bsourcex = bx * g_animx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
307 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
308 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
309 g_bsourcey2 = g_bsourcey + g_animy - 1;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
310 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
311
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
312 void set_fixed_raster(int set) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
313 for (int i = 0; i < 64; i++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
314 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
315 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
316 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
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 get_raster(int xx, int yy) {
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
319 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
320 yy = yy + g_raster_offset_y;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
321 if (g_pixelw == 2) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
322 xx = int(xx / 2);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
323 }
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
324 int mx = chop8(xx);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
325 int my = chop8(yy);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
326 xx = xx - mx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
327 yy = yy - my;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
328 return g_fixedraster[xx + yy * 8];
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
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
331 void refreshpalette() {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
332 //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
333 if (g_palsteps == 0) return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
334 for (int i = 0; i < g_maxcolors; i++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
335 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
336 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
337 }