annotate draw_inputs.pde @ 167:8d239bd81584

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