annotate draw_inputs.pde @ 211:6d866e284dd2

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