comparison draw_outputs.pde @ 225:1c9deae71fb1

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 05 Sep 2018 20:28:23 +0300
parents 934934bb1fbb
children ea6eb6541607
comparison
equal deleted inserted replaced
224:33a5c7670e66 225:1c9deae71fb1
6 return (v < vmin) ? vmin : (v > vmax ? vmax : v); 6 return (v < vmin) ? vmin : (v > vmax ? vmax : v);
7 } 7 }
8 8
9 int chop2(int v) 9 int chop2(int v)
10 { 10 {
11 return int(v / 2) * 2; 11 return int(v / 2) * 2;
12 } 12 }
13 13
14 int chop8(int v) 14 int chop8(int v)
15 { 15 {
16 return int(v / 8) * 8; 16 return int(v / 8) * 8;
17 } 17 }
18 18
19 int chopv(int v, int qv) 19 int chopv(int v, int qv)
20 { 20 {
21 return int(v / qv) * qv; 21 return int(v / qv) * qv;
22 } 22 }
23 23
24 24
25 void createpoint(int x, int y, int mo) 25 void createpoint(int x, int y, int mo)
26 { 26 {
42 void docircx(int xf, int yf, int hh, int vv) 42 void docircx(int xf, int yf, int hh, int vv)
43 { 43 {
44 //circle for brush drawing 44 //circle for brush drawing
45 float prop, fh = hh, fv = vv; 45 float prop, fh = hh, fv = vv;
46 46
47 if (vv > 0) { 47 if (vv > 0)
48 {
48 prop = fh / fv; 49 prop = fh / fv;
49 } else { 50 }
51 else
52 {
50 prop = 1; 53 prop = 1;
51 } 54 }
52 hh++; 55 hh++;
53 56
54 for (int ii = -hh; ii <= hh; ii++) 57 for (int ii = -hh; ii <= hh; ii++)
67 int calc, mb; 70 int calc, mb;
68 int a1, b1, s1, x0, y0, midx, midy, passes, ofx, ofy; 71 int a1, b1, s1, x0, y0, midx, midy, passes, ofx, ofy;
69 ofx = x; 72 ofx = x;
70 ofy = y; 73 ofy = y;
71 mb = g_button; 74 mb = g_button;
72 if (g_btype == 1) { 75 if (g_btype == 1)
73 if (g_bsize < 4) { 76 {
77 if (g_bsize < 4)
78 {
74 //some hardcoded brushes 79 //some hardcoded brushes
75 switch (g_bsize) { 80 switch (g_bsize)
81 {
76 case 0: 82 case 0:
77 doborx(ofx, ofy, ofx + 1, ofy + 1); 83 doborx(ofx, ofy, ofx + 1, ofy + 1);
78 break; 84 break;
79 case 1: 85 case 1:
80 if (g_data[int('c')] == 1 || g_shift == true) { 86 if (g_data[int('c')] == 1 || g_shift == true)
87 {
81 ofx = ofx + 1; 88 ofx = ofx + 1;
82 ofy = ofy + 1; 89 ofy = ofy + 1;
83 } 90 }
84 doborx(ofx - 1, ofy - 1, ofx + 1, ofy + 1); 91 doborx(ofx - 1, ofy - 1, ofx + 1, ofy + 1);
85 break; 92 break;
86 case 2: 93 case 2:
87 if (g_data[int('c')] == 1 || g_shift == true) { 94 if (g_data[int('c')] == 1 || g_shift == true)
95 {
88 ofx = ofx + 2; 96 ofx = ofx + 2;
89 ofy = ofy + 2; 97 ofy = ofy + 2;
90 } 98 }
91 doborx(ofx - 2, ofy - 2, ofx + 1, ofy + 1); 99 doborx(ofx - 2, ofy - 2, ofx + 1, ofy + 1);
92 break; 100 break;
93 case 3: 101 case 3:
94 if (g_data[int('c')] == 1 || g_shift == true) { 102 if (g_data[int('c')] == 1 || g_shift == true)
103 {
95 ofx = ofx + 3; 104 ofx = ofx + 3;
96 ofy = ofy + 3; 105 ofy = ofy + 3;
97 } 106 }
98 doborx(ofx - 3, ofy - 3, ofx + 4, ofy + 4); 107 doborx(ofx - 3, ofy - 3, ofx + 4, ofy + 4);
99 break; 108 break;
100 } 109 }
101 } else { //larger size brushes 110 }
111 else
112 { //larger size brushes
102 calc = g_bsize - 3; 113 calc = g_bsize - 3;
103 calc = calc * calc; 114 calc = calc * calc;
104 calc = calc + 4; 115 calc = calc + 4;
105 doborx(x - calc, y - calc, x + calc, y + calc); 116 doborx(x - calc, y - calc, x + calc, y + calc);
106 } 117 }
107 return; 118 return;
108 } 119 }
109 120
110 if (g_btype == 9) { //bitmap brush 121 if (g_btype == 9)
122 { //bitmap brush
111 passes = 2; 123 passes = 2;
112 int tempox, tempoy, tempx, tempy, moloy; 124 int tempox, tempoy, tempx, tempy, moloy;
113 moloy = 1; 125 moloy = 1;
114 tempox = g_bsourcex; 126 tempox = g_bsourcex;
115 tempoy = g_bsourcey; 127 tempoy = g_bsourcey;
116 tempx = g_bsourcex2; 128 tempx = g_bsourcex2;
117 tempy = g_bsourcey2; 129 tempy = g_bsourcey2;
118 if (g_data[int('t')] == 1) { 130 if (g_data[int('t')] == 1)
131 {
119 if (tempx > g_bsourcex + 16) tempx = g_bsourcex + 16; 132 if (tempx > g_bsourcex + 16) tempx = g_bsourcex + 16;
120 if (tempy > g_bsourcey + 16) tempy = g_bsourcey + 16; 133 if (tempy > g_bsourcey + 16) tempy = g_bsourcey + 16;
121 } 134 }
122 midx = int((g_bsourcex2 - g_bsourcex) / 2); 135 midx = int((g_bsourcex2 - g_bsourcex) / 2);
123 midy = int((g_bsourcey2 - g_bsourcey) / 2); 136 midy = int((g_bsourcey2 - g_bsourcey) / 2);
124 if (g_data[int('c')] == 1 || g_shift == true) { 137 if (g_data[int('c')] == 1 || g_shift == true)
125 if (g_data[int('q')] == 1) { 138 {
139 if (g_data[int('q')] == 1)
140 {
126 // XXX is this g_gridx an error? 141 // XXX is this g_gridx an error?
127 midy = chopv(midy, g_gridx); 142 midy = chopv(midy, g_gridx);
128 midx = chopv(midx, g_gridx); 143 midx = chopv(midx, g_gridx);
129 } 144 }
130 } 145 }
131 int orient = g_data[int('x')] * 100 + g_data[int('y')] * 10 + g_data[int('q')]; 146 int orient = g_data[int('x')] * 100 + g_data[int('y')] * 10 + g_data[int('q')];
132 if (g_pixelw == 2) { 147 if (g_pixelw == 2)
148 {
133 x = chop2(x); 149 x = chop2(x);
134 passes = 1; 150 passes = 1;
135 } 151 }
136 152
137 for (int pp = 1; pp <= passes; pp++) { 153 for (int pp = 1; pp <= passes; pp++)
138 for (int yy = tempoy; yy <= tempy; yy = yy + moloy) { 154 {
139 for (int xx = tempox; xx <= tempx; xx = xx + g_pixelw) { 155 for (int yy = tempoy; yy <= tempy; yy = yy + moloy)
156 {
157 for (int xx = tempox; xx <= tempx; xx = xx + g_pixelw)
158 {
140 s1 = int(g_brush[1024 + xx + yy * X]); 159 s1 = int(g_brush[1024 + xx + yy * X]);
141 if (g_multic == 0) s1 = getabsa(xx, yy, 1); 160 if (g_multic == 0) s1 = getabsa(xx, yy, 1);
142 if (g_multic > 0) s1 = getmultibrush(xx, yy); 161 if (g_multic > 0) s1 = getmultibrush(xx, yy);
143 if (s1 != g_backg) { 162 if (s1 != g_backg)
163 {
144 x0 = x + xx - g_bsourcex; 164 x0 = x + xx - g_bsourcex;
145 y0 = y + yy - g_bsourcey; 165 y0 = y + yy - g_bsourcey;
146 166
147 if (g_data[int('q')] == 1) { 167 if (g_data[int('q')] == 1)
168 {
148 x0 = x - (yy - g_bsourcey2); 169 x0 = x - (yy - g_bsourcey2);
149 y0 = y + (xx - g_bsourcex); 170 y0 = y + (xx - g_bsourcex);
150 x0 = x0 + midx; 171 x0 = x0 + midx;
151 x0 = x0 - midy; 172 x0 = x0 - midy;
152 y0 = y0 + midy; 173 y0 = y0 + midy;
153 y0 = y0 - midx; 174 y0 = y0 - midx;
154 } 175 }
155 176
156 if (g_data[int('x')] == 1) { 177 if (g_data[int('x')] == 1)
178 {
157 x0 = x0 - (x + midx); 179 x0 = x0 - (x + midx);
158 x0 = -x0; 180 x0 = -x0;
159 x0 = x0 + (x + midx); 181 x0 = x0 + (x + midx);
160 } 182 }
161 183
162 if (g_data[int('y')] == 1) { 184 if (g_data[int('y')] == 1)
185 {
163 y0 = y0 - (y + midy); 186 y0 = y0 - (y + midy);
164 y0 = -y0; 187 y0 = -y0;
165 y0 = y0 + (y + midy); 188 y0 = y0 + (y + midy);
166 } 189 }
167 190
168 if (g_data[int('c')] == 1 || g_shift) { 191 if (g_data[int('c')] == 1 || g_shift)
192 {
169 if (orient == 10) y0 = y0 + 1; 193 if (orient == 10) y0 = y0 + 1;
170 if (orient == 11) y0 = y0 + g_gridy - g_pixelw; 194 if (orient == 11) y0 = y0 + g_gridy - g_pixelw;
171 if (orient == 100) x0 = x0 + 1; 195 if (orient == 100) x0 = x0 + 1;
172 if (orient == 101) x0 = x0 + g_gridx - 1; 196 if (orient == 101) x0 = x0 + g_gridx - 1;
173 if (orient == 110) { 197 if (orient == 110)
198 {
174 x0 = x0 + 1; 199 x0 = x0 + 1;
175 y0 = y0 + 1; 200 y0 = y0 + 1;
176 } 201 }
177 if (orient == 111) { 202 if (orient == 111)
203 {
178 x0 = x0 + g_gridx - 1; 204 x0 = x0 + g_gridx - 1;
179 y0 = y0 + g_gridy - g_pixelw; 205 y0 = y0 + g_gridy - g_pixelw;
180 } 206 }
181 } 207 }
182 208
183 if (mb == LEFT) { 209 if (mb == LEFT)
184 if (g_multic > 0) { 210 {
211 if (g_multic > 0)
212 {
185 g_farge = s1; 213 g_farge = s1;
186 if (g_data[int('p')] == 1) g_farge = g_ofarge; 214 if (g_data[int('p')] == 1) g_farge = g_ofarge;
187 if (g_pixelw == 2) { 215 if (g_pixelw == 2)
216 {
188 if (g_data[int('q')] == 0) makepoint(x0, y0); 217 if (g_data[int('q')] == 0) makepoint(x0, y0);
189 if (g_data[int('q')] == 1) { 218 if (g_data[int('q')] == 1)
219 {
190 makepoint(x0 - x + x0, y + (y0 - y)); 220 makepoint(x0 - x + x0, y + (y0 - y));
191 makepoint(x0 - x + x0, y + (y0 - y) + 1); 221 makepoint(x0 - x + x0, y + (y0 - y) + 1);
192 } 222 }
193 } else { 223 }
224 else
225 {
194 makepoint(x0, y0); 226 makepoint(x0, y0);
195 } 227 }
196 } else { 228 }
229 else
230 {
197 g_farge = s1; 231 g_farge = s1;
198 if (zxcolor(g_farge) != zxcolor(g_backg)) { 232 if (zxcolor(g_farge) != zxcolor(g_backg))
233 {
199 if (g_data[int('p')] == 1) g_farge = g_ofarge; 234 if (g_data[int('p')] == 1) g_farge = g_ofarge;
200 makepoint(x0, y0); 235 makepoint(x0, y0);
201 } 236 }
202 } 237 }
203 } 238 }
204 239
205 if (mb == RIGHT) { 240 if (mb == RIGHT)
206 if (g_multic > 0) { 241 {
207 if (g_pixelw == 2) { 242 if (g_multic > 0)
243 {
244 if (g_pixelw == 2)
245 {
208 if (g_data[int('q')] == 0) clearpoint(x0, y0); 246 if (g_data[int('q')] == 0) clearpoint(x0, y0);
209 if (g_data[int('q')] == 1) { 247 if (g_data[int('q')] == 1)
248 {
210 clearpoint(x0 - x + x0, y + (y0 - y)); 249 clearpoint(x0 - x + x0, y + (y0 - y));
211 clearpoint(x0 - x + x0, y + (y0 - y) + 1); 250 clearpoint(x0 - x + x0, y + (y0 - y) + 1);
212 } 251 }
213 } else { 252 }
253 else
254 {
214 clearpoint(x0, y0); 255 clearpoint(x0, y0);
215 } 256 }
216 } else { 257 }
258 else
259 {
217 clearpoint(x0, y0); 260 clearpoint(x0, y0);
218 } 261 }
219 } 262 }
220 } 263 }
221 } 264 }
223 } 266 }
224 g_farge = g_ofarge; 267 g_farge = g_ofarge;
225 return; 268 return;
226 } 269 }
227 270
228 if (g_bsize < 4) { 271 if (g_bsize < 4)
229 switch (g_bsize) { 272 {
273 switch (g_bsize)
274 {
230 case 0: 275 case 0:
231 createpoint(x, y, g_button); 276 createpoint(x, y, g_button);
232 break; 277 break;
233 case 1: 278 case 1:
234 createpoint(x, y + 1, g_button); 279 createpoint(x, y + 1, g_button);
245 doborx(x - 3, y - 1, x + 3, y + 1); 290 doborx(x - 3, y - 1, x + 3, y + 1);
246 doborx(x - 1, y - 3, x + 1, y + 3); 291 doborx(x - 1, y - 3, x + 1, y + 3);
247 doborx(x - 2, y - 2, x + 2, y + 2); 292 doborx(x - 2, y - 2, x + 2, y + 2);
248 break; 293 break;
249 } 294 }
250 } else { 295 }
296 else
297 {
251 calc = g_bsize - 3; 298 calc = g_bsize - 3;
252 calc = calc * calc; 299 calc = calc * calc;
253 calc = calc + 4; 300 calc = calc + 4;
254 docircx(x, y, calc, calc); 301 docircx(x, y, calc, calc);
255 } 302 }
260 { 307 {
261 //bresenham almost exactly from Wikipedia 308 //bresenham almost exactly from Wikipedia
262 int swap, pex, pey; 309 int swap, pex, pey;
263 boolean steep; 310 boolean steep;
264 //multicolor 160 pixel reso 311 //multicolor 160 pixel reso
265 if (g_pixelw == 2) { 312 if (g_pixelw == 2)
313 {
266 xfrom = chop2(xfrom); 314 xfrom = chop2(xfrom);
267 xto = chop2(xto); 315 xto = chop2(xto);
268 } 316 }
269 317
270 craft(xfrom, yfrom, 0); 318 craft(xfrom, yfrom, 0);
271 pex = xfrom; 319 pex = xfrom;
272 pey = yfrom; 320 pey = yfrom;
273 321
274 if (prevent == 0) craft(xto, yto, 0); 322 if (prevent == 0) craft(xto, yto, 0);
275 323
276 if (g_pixelw == 2) { 324 if (g_pixelw == 2)
325 {
277 xfrom = int(xfrom / 2); 326 xfrom = int(xfrom / 2);
278 xto = int(xto / 2); 327 xto = int(xto / 2);
279 } 328 }
280 329
281 int x0 = xfrom; 330 int x0 = xfrom;
283 int x1 = xto; 332 int x1 = xto;
284 int y1 = yto; 333 int y1 = yto;
285 334
286 steep = abs(y1 - y0) > abs(x1 - x0); 335 steep = abs(y1 - y0) > abs(x1 - x0);
287 336
288 if (steep) { 337 if (steep)
338 {
289 swap = x0; 339 swap = x0;
290 x0 = y0; 340 x0 = y0;
291 y0 = swap; 341 y0 = swap;
292 swap = x1; 342 swap = x1;
293 x1 = y1; 343 x1 = y1;
302 if (deltax == 0) return; 352 if (deltax == 0) return;
303 353
304 int y = y0; 354 int y = y0;
305 int inc; 355 int inc;
306 356
307 if (x0 < x1) { 357 if (x0 < x1)
358 {
308 inc = 1; 359 inc = 1;
309 } else { 360 }
361 else
362 {
310 inc = -1; 363 inc = -1;
311 } 364 }
312 if (y0 < y1) { 365 if (y0 < y1)
366 {
313 ystep = 1; 367 ystep = 1;
314 } else { 368 }
369 else
370 {
315 ystep = -1; 371 ystep = -1;
316 } 372 }
317 int x; 373 int x;
318 x = x0; 374 x = x0;
319 while (x != x1) { 375 while (x != x1)
320 if (steep) { 376 {
321 if (y * g_pixelw != pex || x != pey) { 377 if (steep)
378 {
379 if (y * g_pixelw != pex || x != pey)
380 {
322 craft(y * g_pixelw, x, 0); 381 craft(y * g_pixelw, x, 0);
323 pex = y * g_pixelw; 382 pex = y * g_pixelw;
324 pey = x; 383 pey = x;
325 } 384 }
326 } else { 385 }
327 if (x * g_pixelw != pex || y != pey) { 386 else
387 {
388 if (x * g_pixelw != pex || y != pey)
389 {
328 craft(x * g_pixelw, y, 0); 390 craft(x * g_pixelw, y, 0);
329 pex = x * g_pixelw; 391 pex = x * g_pixelw;
330 pey = y; 392 pey = y;
331 } 393 }
332 } 394 }
333 395
334 error = error - deltay; 396 error = error - deltay;
335 if (error < 0) { 397 if (error < 0)
398 {
336 y = y + ystep; 399 y = y + ystep;
337 error = error + deltax; 400 error = error + deltax;
338 } 401 }
339 x = x + inc; 402 x = x + inc;
340 } 403 }
354 yf = y1; 417 yf = y1;
355 hh = x2 - x1; 418 hh = x2 - x1;
356 vv = y2 - y1; 419 vv = y2 - y1;
357 fh = hh; 420 fh = hh;
358 fv = vv; 421 fv = vv;
359 if (vv > 0) { 422 if (vv > 0)
423 {
360 prop = fh / fv; 424 prop = fh / fv;
361 } else { 425 }
426 else
427 {
362 prop = 1; 428 prop = 1;
363 } 429 }
364 hh++; 430 hh++;
365 for (int ii = -hh; ii <= hh; ii++) 431 for (int ii = -hh; ii <= hh; ii++)
366 for (int jj = -vv; jj <= vv; jj++) 432 for (int jj = -vv; jj <= vv; jj++)
386 if (y2 < y1) y2 = y1 - (y2 - y1); 452 if (y2 < y1) y2 = y1 - (y2 - y1);
387 453
388 if (g_data[int('t')] == 1 && x2 > x1 + 15) x2 = x1 + 16; 454 if (g_data[int('t')] == 1 && x2 > x1 + 15) x2 = x1 + 16;
389 if (g_data[int('t')] == 1 && y2 > y1 + 15) y2 = y1 + 16; 455 if (g_data[int('t')] == 1 && y2 > y1 + 15) y2 = y1 + 16;
390 456
391 if (g_data[int('f')] == 1 && g_btype != 9) { 457 if (g_data[int('f')] == 1 && g_btype != 9)
392 if (g_multic == 1 && g_data[int('d')] == 0) { 458 {
459 if (g_multic == 1 && g_data[int('d')] == 0)
460 {
393 g_farge = g_map[1]; 461 g_farge = g_map[1];
394 docircx(x1, y1, abs(x2 - int(x1)), abs(y2 - int(y1))); 462 docircx(x1, y1, abs(x2 - int(x1)), abs(y2 - int(y1)));
395 g_farge = g_ofarge; 463 g_farge = g_ofarge;
396 } 464 }
397 docircx(x1, y1, abs(x2 - int(x1)), abs(y2 - int(y1))); 465 docircx(x1, y1, abs(x2 - int(x1)), abs(y2 - int(y1)));
398 } 466 }
399 467
400 prex = 0; 468 prex = 0;
401 prey = 0; 469 prey = 0;
402 for (t = 0; t <= (gear2); t++) { 470 for (t = 0; t <= (gear2); t++)
471 {
403 a = t / (gear1) * PI; 472 a = t / (gear1) * PI;
404 sx = (x2 - x1) * sin(a); 473 sx = (x2 - x1) * sin(a);
405 sy = (y1 - y2) * cos(a); 474 sy = (y1 - y2) * cos(a);
406 if (t > 0) do_line(prex, prey, x1 + int(sx), y1 + int(sy), 1); 475 if (t > 0) do_line(prex, prey, x1 + int(sx), y1 + int(sy), 1);
407 prex = (x1 + int(sx)); 476 prex = (x1 + int(sx));
421 yt = chop8(y2); 490 yt = chop8(y2);
422 491
423 yt = yt + 7; 492 yt = yt + 7;
424 xt = xt + 6; 493 xt = xt + 6;
425 494
426 if (x2 < x1) { 495 if (x2 < x1)
496 {
427 x0 = x2; 497 x0 = x2;
428 x2 = x1; 498 x2 = x1;
429 x1 = x0; 499 x1 = x0;
430 } 500 }
431 if (y2 < y1) { 501 if (y2 < y1)
502 {
432 y0 = y2; 503 y0 = y2;
433 y2 = y1; 504 y2 = y1;
434 y1 = y0; 505 y1 = y0;
435 } 506 }
436 507
437 if (g_data[int('t')] == 1 && x2 > x1 + 15) x2 = x1 + 16; 508 if (g_data[int('t')] == 1 && x2 > x1 + 15) x2 = x1 + 16;
438 if (g_data[int('t')] == 1 && y2 > y1 + 15) y2 = y1 + 16; 509 if (g_data[int('t')] == 1 && y2 > y1 + 15) y2 = y1 + 16;
439 510
440 if (g_btype != 9) { 511 if (g_btype != 9)
441 if (g_data[int('c')] == 1 || g_shift) { 512 {
513 if (g_data[int('c')] == 1 || g_shift)
514 {
442 if (x2 > x1) x2--; 515 if (x2 > x1) x2--;
443 if (y2 > y1) y2--; 516 if (y2 > y1) y2--;
444 } 517 }
445 } 518 }
446 519
447 if (g_data[int('f')] == 1 && g_btype != 9) { 520 if (g_data[int('f')] == 1 && g_btype != 9)
448 if (g_multic == 1 && g_data[int('d')] == 0) { 521 {
522 if (g_multic == 1 && g_data[int('d')] == 0)
523 {
449 g_farge = g_map[1]; 524 g_farge = g_map[1];
450 for (int y = y1; y <= y2; y++) { 525 for (int y = y1; y <= y2; y++)
451 for (int x = x1; x <= x2; x = x + g_pixelw) { 526 {
452 if (x >= xf && y >= yf && x <= xt && y <= yt) { 527 for (int x = x1; x <= x2; x = x + g_pixelw)
528 {
529 if (x >= xf && y >= yf && x <= xt && y <= yt)
530 {
453 makepoint(x, y); 531 makepoint(x, y);
454 } 532 }
455 } 533 }
456 } 534 }
457 } 535 }
458 g_farge = g_ofarge; 536 g_farge = g_ofarge;
459 if (g_button == RIGHT) g_farge = g_backg; 537 if (g_button == RIGHT) g_farge = g_backg;
460 for (int y = y1; y <= y2; y++) { 538 for (int y = y1; y <= y2; y++)
461 for (int x = x1; x <= x2; x = x + g_pixelw) { 539 {
540 for (int x = x1; x <= x2; x = x + g_pixelw)
541 {
462 makepoint(x, y); 542 makepoint(x, y);
463 } 543 }
464 } 544 }
465 } 545 }
466 if (g_data[int('f')] == 0 || g_btype == 9) { 546 if (g_data[int('f')] == 0 || g_btype == 9)
467 if (g_data[int('c')] == 1 && g_btype == 1) { 547 {
468 if (x2 > x1) { 548 if (g_data[int('c')] == 1 && g_btype == 1)
549 {
550 if (x2 > x1)
551 {
469 if (g_bsize == 0) x2--; 552 if (g_bsize == 0) x2--;
470 if (g_bsize == 1) x2 = x2 - 2; 553 if (g_bsize == 1) x2 = x2 - 2;
471 if (g_bsize == 2) x2 = x2 - 3; 554 if (g_bsize == 2) x2 = x2 - 3;
472 if (g_bsize == 3) x2++; 555 if (g_bsize == 3) x2++;
473 } 556 }
474 if (y2 > y1) { 557 if (y2 > y1)
558 {
475 if (g_bsize == 0) y2--; 559 if (g_bsize == 0) y2--;
476 if (g_bsize == 1) y2 = y2 - 2; 560 if (g_bsize == 1) y2 = y2 - 2;
477 if (g_bsize == 2) y2 = y2 - 3; 561 if (g_bsize == 2) y2 = y2 - 3;
478 if (g_bsize == 3) y2++; 562 if (g_bsize == 3) y2++;
479 } 563 }
499 int ignore = 0; 583 int ignore = 0;
500 int fari; 584 int fari;
501 585
502 //for the X/Y mirrors & tiler, the function calls itself with x+10000 or y+10000 586 //for the X/Y mirrors & tiler, the function calls itself with x+10000 or y+10000
503 //resolved here 587 //resolved here
504 if (xx >= 20000) { 588 if (xx >= 20000)
589 {
505 xx = xx - 20000; 590 xx = xx - 20000;
506 mirrix = 0; 591 mirrix = 0;
507 mirriy = 0; 592 mirriy = 0;
508 tiler = 1; 593 tiler = 1;
509 } 594 }
510 if (xx >= 10000) { 595 if (xx >= 10000)
596 {
511 xx = xx - 10000; 597 xx = xx - 10000;
512 mirrix = 1; 598 mirrix = 1;
513 mirriy = 1; 599 mirriy = 1;
514 } 600 }
515 if (yy >= 10000) { 601 if (yy >= 10000)
602 {
516 yy = yy - 10000; 603 yy = yy - 10000;
517 mirriy = 1; 604 mirriy = 1;
518 mirrix = 1; 605 mirrix = 1;
519 } 606 }
520 607
542 kaveri_iq(xx, yy, g_farge, 0); 629 kaveri_iq(xx, yy, g_farge, 0);
543 } 630 }
544 } 631 }
545 } 632 }
546 633
547 if (g_pixelw == 2) { 634 if (g_pixelw == 2)
635 {
548 xx = chop2(xx); 636 xx = chop2(xx);
549 } 637 }
550 638
551 if (g_data[int('r')] == 1) { //simple raster 639 if (g_data[int('r')] == 1)
640 { //simple raster
552 if (get_raster(xx, yy) == 0) ignore = 1; 641 if (get_raster(xx, yy) == 0) ignore = 1;
553 } 642 }
554 643
555 if (g_data[int('R')] == 1) { //user defined raster 644 if (g_data[int('R')] == 1)
556 if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey) { 645 { //user defined raster
646 if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey)
647 {
557 648
558 int x0 = int(xx / ((g_bsourcex2 + 1) - g_bsourcex)); 649 int x0 = int(xx / ((g_bsourcex2 + 1) - g_bsourcex));
559 int y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey)); 650 int y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey));
560 int x1 = xx - x0 * ((g_bsourcex2 + 1) - g_bsourcex); 651 int x1 = xx - x0 * ((g_bsourcex2 + 1) - g_bsourcex);
561 int y1 = yy - y0 * ((g_bsourcey2 + 1) - g_bsourcey); 652 int y1 = yy - y0 * ((g_bsourcey2 + 1) - g_bsourcey);
562 int xr = g_bsourcex + x1; 653 int xr = g_bsourcex + x1;
563 int yr = g_bsourcey + y1; 654 int yr = g_bsourcey + y1;
564 if (g_pixelw == 2) { 655 if (g_pixelw == 2)
656 {
565 x0 = int(xx / ((g_bsourcex2 + 2) - g_bsourcex)); 657 x0 = int(xx / ((g_bsourcex2 + 2) - g_bsourcex));
566 y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey)); 658 y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey));
567 x1 = xx - x0 * ((g_bsourcex2 + 2) - g_bsourcex); 659 x1 = xx - x0 * ((g_bsourcex2 + 2) - g_bsourcex);
568 x1 = chop2(x1); 660 x1 = chop2(x1);
569 y1 = yy - y0 * ((g_bsourcey2 + 1) - g_bsourcey); 661 y1 = yy - y0 * ((g_bsourcey2 + 1) - g_bsourcey);
570 xr = g_bsourcex + x1; 662 xr = g_bsourcex + x1;
571 xr = chop2(xr); 663 xr = chop2(xr);
572 yr = g_bsourcey + y1; 664 yr = g_bsourcey + y1;
573 if (getmultic(xr, yr, 1) == g_backg) ignore = 1; 665 if (getmultic(xr, yr, 1) == g_backg) ignore = 1;
574 } else { 666 }
667 else
668 {
575 if (getabsa(xr, yr, 1) == g_backg) ignore = 1; 669 if (getabsa(xr, yr, 1) == g_backg) ignore = 1;
576 } 670 }
577 // if(g_brush[1024+xr+yr*X]==0){ignore=1;} 671 // if(g_brush[1024+xr+yr*X]==0){ignore=1;}
578 } 672 }
579 } 673 }
580 674
581 int xc, yc; 675 int xc, yc;
582 676
583 if (ignore == 0 && g_data[int('d')] == 1 && g_attrimode <= 1) { 677 if (ignore == 0 && g_data[int('d')] == 1 && g_attrimode <= 1)
678 {
584 int aba, baba, ii, jj, miny, maxy, ojox, ojoy; 679 int aba, baba, ii, jj, miny, maxy, ojox, ojoy;
585 aba = getattra(xx, yy, 0); 680 aba = getattra(xx, yy, 0);
586 baba = getattra(xx, yy, 1); 681 baba = getattra(xx, yy, 1);
587 if (g_multic == 0) { 682 if (g_multic == 0)
683 {
588 ojox = chop8(xx); 684 ojox = chop8(xx);
589 ojoy = chop8(yy); 685 ojoy = chop8(yy);
590 miny = yy - ojoy; 686 miny = yy - ojoy;
591 maxy = miny; 687 maxy = miny;
592 688
593 if (g_attrimode == 1) { 689 if (g_attrimode == 1)
690 {
594 miny = 0; 691 miny = 0;
595 maxy = 7; 692 maxy = 7;
596 } 693 }
597 694
598 if (baba == g_backg) simplepaint(xx, yy, 1, g_farge); 695 if (baba == g_backg) simplepaint(xx, yy, 1, g_farge);
599 if (aba == g_backg) simplepaint(xx, yy, 0, g_farge); 696 if (aba == g_backg) simplepaint(xx, yy, 0, g_farge);
600 ignore = 1; 697 ignore = 1;
601 if (g_farge == baba && g_farge == aba) { 698 if (g_farge == baba && g_farge == aba)
602 for (jj = miny; jj <= maxy; jj++) { 699 {
603 for (ii = 0; ii < 8; ii++) { 700 for (jj = miny; jj <= maxy; jj++)
701 {
702 for (ii = 0; ii < 8; ii++)
703 {
604 g_map[1024 + ojox + ojoy * X + ii + jj * X] = 0; 704 g_map[1024 + ojox + ojoy * X + ii + jj * X] = 0;
605 } 705 }
606 } 706 }
607 } 707 }
608 } else { 708 }
609 if (aba == g_backg) { 709 else
710 {
711 if (aba == g_backg)
712 {
610 ignore = 0; 713 ignore = 0;
611 } else { 714 }
715 else
716 {
612 ignore = 1; 717 ignore = 1;
613 } 718 }
614 } 719 }
615 xc = int(xx / 8); 720 xc = int(xx / 8);
616 yc = int(yy / 8); 721 yc = int(yy / 8);
617 g_redo[xc + yc * MX] = byte(0); //block update 722 g_redo[xc + yc * MX] = byte(0); //block update
618 g_remdo[xc + yc * MX] = byte(1); //block update 723 g_remdo[xc + yc * MX] = byte(1); //block update
619 } 724 }
620 725
621 if (ignore == 0) { 726 if (ignore == 0)
727 {
622 xc = int(xx / 8); 728 xc = int(xx / 8);
623 yc = int(yy / 8); 729 yc = int(yy / 8);
624 g_redo[xc + yc * MX] = byte(0); //block update 730 g_redo[xc + yc * MX] = byte(0); //block update
625 g_remdo[xc + yc * MX] = byte(1); //block update 731 g_remdo[xc + yc * MX] = byte(1); //block update
626 732
627 switch (g_multic) { 733 switch (g_multic)
734 {
628 case 0: //1-bit + attribute i.e. spectrum 735 case 0: //1-bit + attribute i.e. spectrum
629 fari = g_farge; 736 fari = g_farge;
630 if (g_machine == MSX && fari == int(g_map[1])) fari = 0; 737 if (g_machine == MSX && fari == int(g_map[1])) fari = 0;
631 if (g_britemode == 1 && fari == 8) fari = 0; 738 if (g_britemode == 1 && fari == 8) fari = 0;
632 739
633 if (getattra(xx, yy, 1) == 0 && fari == g_map[1]) { 740 if (getattra(xx, yy, 1) == 0 && fari == g_map[1])
741 {
634 g_map[1024 + xx + yy * X] = byte(0); 742 g_map[1024 + xx + yy * X] = byte(0);
635 } else { 743 }
636 if (getattra(xx, yy, 1) == fari) { 744 else
745 {
746 if (getattra(xx, yy, 1) == fari)
747 {
637 g_map[1024 + xx + yy * X] = byte(0); 748 g_map[1024 + xx + yy * X] = byte(0);
638 } else { 749 }
750 else
751 {
639 int ojox = chop8(xx); 752 int ojox = chop8(xx);
640 int ojoy = chop8(yy); 753 int ojoy = chop8(yy);
641 int mac, macpre, maxos; 754 int mac, macpre, maxos;
642 int maxoy, miny, maxy; 755 int maxoy, miny, maxy;
643 mac = 0; 756 mac = 0;
644 macpre = 0; 757 macpre = 0;
645 miny = 0; 758 miny = 0;
646 maxy = 7; 759 maxy = 7;
647 maxos = 64; 760 maxos = 64;
648 if (g_attrimode == 0) { 761 if (g_attrimode == 0)
762 {
649 miny = (yy - ojoy); 763 miny = (yy - ojoy);
650 maxy = miny; 764 maxy = miny;
651 maxos = 8; 765 maxos = 8;
652 } //MSX 766 } //MSX
653 for (int j = miny; j <= maxy; j++) { 767 for (int j = miny; j <= maxy; j++)
654 for (int i = 0; i < 8; i++) { 768 {
769 for (int i = 0; i < 8; i++)
770 {
655 if (g_map[1024 + ojox + ojoy * X + j * X] == 1) macpre++; 771 if (g_map[1024 + ojox + ojoy * X + j * X] == 1) macpre++;
656 } 772 }
657 } 773 }
658 g_map[1024 + xx + yy * X] = byte(1); 774 g_map[1024 + xx + yy * X] = byte(1);
659 for (int j = miny; j <= maxy; j++) { 775 for (int j = miny; j <= maxy; j++)
660 for (int i = 0; i < 8; i++) { 776 {
777 for (int i = 0; i < 8; i++)
778 {
661 if (g_map[1024 + ojox + ojoy * X + i + j * X] == 1) mac++; 779 if (g_map[1024 + ojox + ojoy * X + i + j * X] == 1) mac++;
662 } 780 }
663 } 781 }
664 if (mac == maxos) { 782 if (mac == maxos)
665 for (int j = miny; j <= maxy; j++) { 783 {
784 for (int j = miny; j <= maxy; j++)
785 {
666 int vad = 1024 + ojox + (ojoy + j) * X; 786 int vad = 1024 + ojox + (ojoy + j) * X;
667 for (int i = 0; i < 8; i++) { 787 for (int i = 0; i < 8; i++)
788 {
668 g_map[vad] = 0; 789 g_map[vad] = 0;
669 vad++; 790 vad++;
670 } 791 }
671 } 792 }
672 simplepaint(xx, yy, 1, fari); 793 simplepaint(xx, yy, 1, fari);
673 } else { 794 }
795 else
796 {
674 simplepaint(xx, yy, 0, fari); 797 simplepaint(xx, yy, 0, fari);
675 } 798 }
676 } 799 }
677 } 800 }
678 break; 801 break;
684 int metax, metay, mex, mey, metamax; 807 int metax, metay, mex, mey, metamax;
685 fari = g_farge; 808 fari = g_farge;
686 int zeroc = int(g_map[1]); 809 int zeroc = int(g_map[1]);
687 int zeroc2 = int(g_map[2]); 810 int zeroc2 = int(g_map[2]);
688 boolean cut = false; 811 boolean cut = false;
689 if (fari == zeroc) { //shortcut 812 if (fari == zeroc)
813 { //shortcut
690 g_map[1024 + xx + yy * X] = byte(0); 814 g_map[1024 + xx + yy * X] = byte(0);
691 g_map[1024 + xx + yy * X + 1] = byte(0); 815 g_map[1024 + xx + yy * X + 1] = byte(0);
692 cut = true; 816 cut = true;
693 } 817 }
694 if (g_machine == PLUS4M && fari == zeroc2) { //shortcut 818 if (g_machine == PLUS4M && fari == zeroc2)
819 { //shortcut
695 g_map[1024 + xx + yy * X] = byte(1); 820 g_map[1024 + xx + yy * X] = byte(1);
696 g_map[1024 + xx + yy * X + 1] = byte(1); 821 g_map[1024 + xx + yy * X + 1] = byte(1);
697 cut = true; 822 cut = true;
698 } 823 }
699 if (cut) { 824 if (cut)
825 {
700 // X Y mirrors 826 // X Y mirrors
701 if (g_data[int('t')] == 1) { 827 if (g_data[int('t')] == 1)
702 if (tiler == 0) { 828 {
829 if (tiler == 0)
830 {
703 int ex = int(X / g_gridx); 831 int ex = int(X / g_gridx);
704 int ey = int(Y / g_gridy); 832 int ey = int(Y / g_gridy);
705 for (int tilx = -ex; tilx <= ex; tilx++) { 833 for (int tilx = -ex; tilx <= ex; tilx++)
706 for (int tily = -ey; tily <= ey; tily++) { 834 {
835 for (int tily = -ey; tily <= ey; tily++)
836 {
707 makepoint(20000 + xx + int(X / ex) * tilx, yy + int(Y / ey) * tily); 837 makepoint(20000 + xx + int(X / ex) * tilx, yy + int(Y / ey) * tily);
708 } 838 }
709 } 839 }
710 } 840 }
711 return; 841 return;
712 } 842 }
713 if (g_data[int('X')] == 1 && mirrix == 0) makepoint(10000 + (X - 1) - xx, yy); 843 if (g_data[int('X')] == 1 && mirrix == 0) makepoint(10000 + (X - 1) - xx, yy);
714 if (g_data[int('Y')] == 1 && mirriy == 0) makepoint(xx, 10000 + (Y - 1) - yy); 844 if (g_data[int('Y')] == 1 && mirriy == 0) makepoint(xx, 10000 + (Y - 1) - yy);
715 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1) { 845 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1)
716 if (mirrix == 0) { 846 {
847 if (mirrix == 0)
848 {
717 makepoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy); 849 makepoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy);
718 } 850 }
719 } 851 }
720 return; 852 return;
721 } 853 }
733 looks = 65536 + mex + mey * MX; 865 looks = 65536 + mex + mey * MX;
734 mex = int(mex * 8); 866 mex = int(mex * 8);
735 mey = int(mey * 8); 867 mey = int(mey * 8);
736 int saps = 1024 + mex + mey * X; 868 int saps = 1024 + mex + mey * X;
737 869
738 for (metay = 0; metay <= 7; metay++) { 870 for (metay = 0; metay <= 7; metay++)
739 for (metax = 0; metax <= 3; metax++) { 871 {
872 for (metax = 0; metax <= 3; metax++)
873 {
740 int pars = g_map[saps] + g_map[saps + 1] * 2; 874 int pars = g_map[saps] + g_map[saps + 1] * 2;
741 uses[pars] = 1; 875 uses[pars] = 1;
742 if (pars == 0) fars[0] = zeroc; 876 if (pars == 0) fars[0] = zeroc;
743 if (pars == 1) fars[1] = int(g_map[looks]); 877 if (pars == 1) fars[1] = int(g_map[looks]);
744 if (pars == 2) fars[2] = int(g_map[looks + 1000]); 878 if (pars == 2) fars[2] = int(g_map[looks + 1000]);
745 if (pars == 3) { 879 if (pars == 3)
880 {
746 if (g_machine == C64M) fars[3] = int(g_map[looks + 2000]); 881 if (g_machine == C64M) fars[3] = int(g_map[looks + 2000]);
747 if (g_machine == PLUS4M) fars[3] = zeroc2; 882 if (g_machine == PLUS4M) fars[3] = zeroc2;
748 } 883 }
749 saps = saps + 2; 884 saps = saps + 2;
750 } 885 }
754 bit1 = 0; 889 bit1 = 0;
755 bit2 = 0; 890 bit2 = 0;
756 skippo = 0; 891 skippo = 0;
757 892
758 // mega-escape, if it's not possible to draw at all don't bother 893 // mega-escape, if it's not possible to draw at all don't bother
759 if (uses[0] == 1 && uses[1] == 1 && uses[2] == 1 && uses[3] == 1) { 894 if (uses[0] == 1 && uses[1] == 1 && uses[2] == 1 && uses[3] == 1)
895 {
760 if (fari != fars[0] && fari != fars[1] && fari != fars[2] && fari != fars[3]) skippo = 100; 896 if (fari != fars[0] && fari != fars[1] && fari != fars[2] && fari != fars[3]) skippo = 100;
761 } 897 }
762 898
763 if (skippo == 0) { 899 if (skippo == 0)
900 {
764 int okay = 0; 901 int okay = 0;
765 metamax = 3; 902 metamax = 3;
766 if (g_machine == PLUS4M) metamax = 2; 903 if (g_machine == PLUS4M) metamax = 2;
767 904
768 // if the color is already in the 4x8 area? 905 // if the color is already in the 4x8 area?
769 906
770 for (metay = 0; metay <= metamax; metay++) { 907 for (metay = 0; metay <= metamax; metay++)
771 if (uses[metay] == 1) { 908 {
772 if (fars[metay] == fari) { 909 if (uses[metay] == 1)
773 if (metay == 1) { 910 {
911 if (fars[metay] == fari)
912 {
913 if (metay == 1)
914 {
774 bit1 = 1; 915 bit1 = 1;
775 bit2 = 0; 916 bit2 = 0;
776 g_map[looks] = byte(fari); 917 g_map[looks] = byte(fari);
777 } 918 }
778 if (metay == 2) { 919 if (metay == 2)
920 {
779 bit1 = 0; 921 bit1 = 0;
780 bit2 = 1; 922 bit2 = 1;
781 g_map[looks + 1000] = byte(fari); 923 g_map[looks + 1000] = byte(fari);
782 } 924 }
783 if (metay == 3) { 925 if (metay == 3)
926 {
784 bit1 = 1; 927 bit1 = 1;
785 bit2 = 1; 928 bit2 = 1;
786 if (g_machine == C64M) g_map[looks + 2000] = byte(fari); 929 if (g_machine == C64M) g_map[looks + 2000] = byte(fari);
787 if (g_machine == PLUS4M) g_map[looks + 2000] = byte(zeroc2); 930 if (g_machine == PLUS4M) g_map[looks + 2000] = byte(zeroc2);
788 } 931 }
793 } 936 }
794 } 937 }
795 938
796 //if the color is not in the 4x8 area 939 //if the color is not in the 4x8 area
797 940
798 if (okay == 0) { 941 if (okay == 0)
799 for (metay = 1; metay <= metamax; metay++) { 942 {
800 if (uses[metay] == 0) { 943 for (metay = 1; metay <= metamax; metay++)
944 {
945 if (uses[metay] == 0)
946 {
801 uses[metay] = 1; 947 uses[metay] = 1;
802 if (metay == 1) { 948 if (metay == 1)
949 {
803 bit1 = 1; 950 bit1 = 1;
804 bit2 = 0; 951 bit2 = 0;
805 g_map[looks] = byte(fari); 952 g_map[looks] = byte(fari);
806 uses[2] = 1; 953 uses[2] = 1;
807 } 954 }
808 if (metay == 2) { 955 if (metay == 2)
956 {
809 bit1 = 0; 957 bit1 = 0;
810 bit2 = 1; 958 bit2 = 1;
811 g_map[looks + 1000] = byte(fari); 959 g_map[looks + 1000] = byte(fari);
812 uses[3] = 1; 960 uses[3] = 1;
813 } 961 }
814 if (metay == 3) { 962 if (metay == 3)
963 {
815 bit1 = 1; 964 bit1 = 1;
816 bit2 = 1; 965 bit2 = 1;
817 if (g_machine == C64M) g_map[looks + 2000] = byte(fari); 966 if (g_machine == C64M) g_map[looks + 2000] = byte(fari);
818 if (g_machine == PLUS4M) g_map[looks + 2000] = byte(zeroc2); 967 if (g_machine == PLUS4M) g_map[looks + 2000] = byte(zeroc2);
819 } 968 }
828 break; 977 break;
829 978
830 case 2: // VGA style i.e. Amiga, CPC 979 case 2: // VGA style i.e. Amiga, CPC
831 fari = g_farge; 980 fari = g_farge;
832 981
833 if (g_data[int('d')] == 1) { 982 if (g_data[int('d')] == 1)
834 if (g_map[1024 + xx + yy * X] == byte(g_backg)) { 983 {
984 if (g_map[1024 + xx + yy * X] == byte(g_backg))
985 {
835 g_map[1024 + xx + yy * X] = byte(g_farge); 986 g_map[1024 + xx + yy * X] = byte(g_farge);
836 if (g_hzoomer == 2) g_map[1024 + xx + yy * X + 1] = byte(g_farge); 987 if (g_hzoomer == 2) g_map[1024 + xx + yy * X + 1] = byte(g_farge);
837 } 988 }
838 } else { 989 }
990 else
991 {
839 g_map[1024 + xx + yy * X] = byte(g_farge); 992 g_map[1024 + xx + yy * X] = byte(g_farge);
840 if (g_hzoomer == 2) g_map[1024 + xx + yy * X + 1] = byte(g_farge); 993 if (g_hzoomer == 2) g_map[1024 + xx + yy * X + 1] = byte(g_farge);
841 } 994 }
842 break; 995 break;
843 } 996 }
845 998
846 // end ignore 999 // end ignore
847 1000
848 // X Y mirrors & tiler 1001 // X Y mirrors & tiler
849 1002
850 if (g_data[int('t')] == 1) { 1003 if (g_data[int('t')] == 1)
851 if (tiler == 0) { 1004 {
1005 if (tiler == 0)
1006 {
852 int ex = int(X / g_gridx); 1007 int ex = int(X / g_gridx);
853 int ey = int(Y / g_gridy); 1008 int ey = int(Y / g_gridy);
854 for (int tilx = -(ex); tilx <= ex; tilx++) { 1009 for (int tilx = -(ex); tilx <= ex; tilx++)
855 for (int tily = -(ey); tily <= ey; tily++) { 1010 {
1011 for (int tily = -(ey); tily <= ey; tily++)
1012 {
856 makepoint(20000 + xx + int(X / ex) * tilx, yy + int(Y / ey) * tily); 1013 makepoint(20000 + xx + int(X / ex) * tilx, yy + int(Y / ey) * tily);
857 } 1014 }
858 } 1015 }
859 } 1016 }
860 return; 1017 return;
861 } 1018 }
862 if (g_data[int('X')] == 1 && mirrix == 0) makepoint(10000 + (X - 1) - xx, yy); 1019 if (g_data[int('X')] == 1 && mirrix == 0) makepoint(10000 + (X - 1) - xx, yy);
863 if (g_data[int('Y')] == 1 && mirriy == 0) makepoint(xx, 10000 + (Y - 1) - yy); 1020 if (g_data[int('Y')] == 1 && mirriy == 0) makepoint(xx, 10000 + (Y - 1) - yy);
864 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1) { 1021 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1)
865 if (mirrix == 0) { 1022 {
1023 if (mirrix == 0)
1024 {
866 makepoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy); 1025 makepoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy);
867 } 1026 }
868 } 1027 }
869 } 1028 }
870 1029
871 void clearpoint(int xx, int yy) 1030 void clearpoint(int xx, int yy)
872 { 1031 {
873 if (g_multic == 2) { 1032 if (g_multic == 2)
1033 {
874 g_farge = g_backg; 1034 g_farge = g_backg;
875 makepoint(xx, yy); 1035 makepoint(xx, yy);
876 g_farge = g_ofarge; 1036 g_farge = g_ofarge;
877 return; 1037 return;
878 } 1038 }
879 if (g_multic == 1) { 1039 if (g_multic == 1)
1040 {
880 xx = chop2(xx); 1041 xx = chop2(xx);
881 } 1042 }
882 g_farge = g_backg; 1043 g_farge = g_backg;
883 makepoint(xx, yy); 1044 makepoint(xx, yy);
884 g_farge = g_ofarge; 1045 g_farge = g_ofarge;
888 void absolute_clearpoint(int xx, int yy) 1049 void absolute_clearpoint(int xx, int yy)
889 { 1050 {
890 int mirrix = 0; 1051 int mirrix = 0;
891 int mirriy = 0; 1052 int mirriy = 0;
892 int ignore = 0; 1053 int ignore = 0;
893 if (xx >= 10000) { 1054 if (xx >= 10000)
1055 {
894 xx = xx - 10000; 1056 xx = xx - 10000;
895 mirrix = 1; 1057 mirrix = 1;
896 mirriy = 1; 1058 mirriy = 1;
897 } 1059 }
898 if (yy >= 10000) { 1060 if (yy >= 10000)
1061 {
899 yy = yy - 10000; 1062 yy = yy - 10000;
900 mirriy = 1; 1063 mirriy = 1;
901 mirrix = 1; 1064 mirrix = 1;
902 } 1065 }
903 1066
904 if (xx < 0 || yy < 0 || xx >= X || yy >= Y) 1067 if (xx < 0 || yy < 0 || xx >= X || yy >= Y)
905 return; 1068 return;
906 1069
907 if (g_multic == 2 && g_hzoomer != 2) { 1070 if (g_multic == 2 && g_hzoomer != 2)
1071 {
908 g_farge = g_backg; 1072 g_farge = g_backg;
909 makepoint(xx, yy); 1073 makepoint(xx, yy);
910 g_farge = g_ofarge; 1074 g_farge = g_ofarge;
911 return; 1075 return;
912 } 1076 }
913 if (g_pixelw == 2) { 1077 if (g_pixelw == 2)
1078 {
914 xx = chop2(xx); 1079 xx = chop2(xx);
915 } 1080 }
916 if (g_data[int('b')] == 1) return; 1081 if (g_data[int('b')] == 1) return;
917 1082
918 if (g_data[int('r')] == 1) { //raster 1083 if (g_data[int('r')] == 1)
1084 { //raster
919 if (get_raster(xx, yy) == 0) ignore = 1; 1085 if (get_raster(xx, yy) == 0) ignore = 1;
920 } 1086 }
921 1087
922 if (g_data[int('R')] == 1) { //user defined raster 1088 if (g_data[int('R')] == 1)
923 if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey) { 1089 { //user defined raster
1090 if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey)
1091 {
924 int x0 = int(xx / ((g_bsourcex2 + 1) - g_bsourcex)); 1092 int x0 = int(xx / ((g_bsourcex2 + 1) - g_bsourcex));
925 int y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey)); 1093 int y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey));
926 int x1 = xx - x0 * ((g_bsourcex2 + 1) - g_bsourcex); 1094 int x1 = xx - x0 * ((g_bsourcex2 + 1) - g_bsourcex);
927 int y1 = yy - y0 * ((g_bsourcey2 + 1) - g_bsourcey); 1095 int y1 = yy - y0 * ((g_bsourcey2 + 1) - g_bsourcey);
928 int xr = g_bsourcex + x1; 1096 int xr = g_bsourcex + x1;
929 int yr = g_bsourcey + y1; 1097 int yr = g_bsourcey + y1;
930 if (g_brush[1024 + xr + yr * X] == 0) ignore = 1; 1098 if (g_brush[1024 + xr + yr * X] == 0) ignore = 1;
931 } 1099 }
932 } 1100 }
933 1101
934 if (ignore == 0) { 1102 if (ignore == 0)
1103 {
935 g_map[1024 + xx + yy * X] = byte(0); 1104 g_map[1024 + xx + yy * X] = byte(0);
936 if (g_pixelw == 2) g_map[1024 + xx + yy * X + 1] = byte(0); 1105 if (g_pixelw == 2) g_map[1024 + xx + yy * X + 1] = byte(0);
937 int xc = int(xx / 8); 1106 int xc = int(xx / 8);
938 int yc = int(yy / 8); 1107 int yc = int(yy / 8);
939 g_redo[xc + yc * MX] = byte(0); //block update 1108 g_redo[xc + yc * MX] = byte(0); //block update
940 g_remdo[xc + yc * MX] = byte(1); //block update 1109 g_remdo[xc + yc * MX] = byte(1); //block update
941 } 1110 }
942 1111
943 if (g_data[int('X')] == 1 && mirrix == 0) clearpoint(10000 + (X - 1) - xx, yy); 1112 if (g_data[int('X')] == 1 && mirrix == 0) clearpoint(10000 + (X - 1) - xx, yy);
944 if (g_data[int('Y')] == 1 && mirriy == 0) clearpoint(xx, 10000 + (Y - 1) - yy); 1113 if (g_data[int('Y')] == 1 && mirriy == 0) clearpoint(xx, 10000 + (Y - 1) - yy);
945 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1) { 1114 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1)
1115 {
946 if (mirrix == 0) clearpoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy); 1116 if (mirrix == 0) clearpoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy);
947 } 1117 }
948 } 1118 }
949 1119
950 1120
965 maxy = 7; 1135 maxy = 7;
966 } 1136 }
967 1137
968 for (int j = miny; j <= maxy; j++) 1138 for (int j = miny; j <= maxy; j++)
969 { 1139 {
970 if (mode == 0) { 1140 if (mode == 0)
1141 {
971 ad = 65536 + xx + (ojyx + j) * MX; 1142 ad = 65536 + xx + (ojyx + j) * MX;
972 swad = 65536 + xx + (ojyx + j) * MX + (MX * MY) * 8; 1143 swad = 65536 + xx + (ojyx + j) * MX + (MX * MY) * 8;
973 } 1144 }
974 if (mode == 1) { 1145 if (mode == 1)
1146 {
975 ad = 65536 + xx + (ojyx + j) * MX + (MX * MY) * 8; 1147 ad = 65536 + xx + (ojyx + j) * MX + (MX * MY) * 8;
976 swad = 65536 + xx + (ojyx + j) * MX; 1148 swad = 65536 + xx + (ojyx + j) * MX;
977 } 1149 }
978 if (g_britemode == 1) { 1150 if (g_britemode == 1)
1151 {
979 if (attr == 8) attr = 0; 1152 if (attr == 8) attr = 0;
980 if (attr > 0) { 1153 if (attr > 0)
1154 {
981 if (attr >= 8 && g_map[swad] <= 7) g_map[swad] = byte(g_map[swad] + 8); 1155 if (attr >= 8 && g_map[swad] <= 7) g_map[swad] = byte(g_map[swad] + 8);
982 if (attr <= 7 && g_map[swad] >= 8) g_map[swad] = byte(g_map[swad] - 8); 1156 if (attr <= 7 && g_map[swad] >= 8) g_map[swad] = byte(g_map[swad] - 8);
983 } 1157 }
984 } 1158 }
985 g_map[ad] = byte(attr); 1159 g_map[ad] = byte(attr);
1059 1233
1060 g_btype = 9; 1234 g_btype = 9;
1061 return; 1235 return;
1062 } 1236 }
1063 else 1237 else
1064 if (mbut == 255) { // color picker 1238 if (mbut == 255)
1065 if (g_multic == 2) { 1239 { // color picker
1066 if (g_hzoomer == 2) { 1240 if (g_multic == 2)
1241 {
1242 if (g_hzoomer == 2)
1243 {
1067 ox = chop2(ox); 1244 ox = chop2(ox);
1068 } 1245 }
1069 selectcolor(0, getmultic(ox, oy, 0)); 1246 selectcolor(0, getmultic(ox, oy, 0));
1070 return; 1247 return;
1071 } 1248 }
1072 selectcolor(0, getabsa(ox, oy, 0)); 1249 selectcolor(0, getabsa(ox, oy, 0));
1073 if (g_pixelw == 2) { 1250 if (g_pixelw == 2)
1251 {
1074 ox = chop2(ox); 1252 ox = chop2(ox);
1075 selectcolor(0, getattra(ox, oy, 0)); 1253 selectcolor(0, getattra(ox, oy, 0));
1076 } 1254 }
1077 g_ofarge = g_farge; 1255 g_ofarge = g_farge;
1078 if (g_btype == 9) g_data[int('p')] = 1; 1256 if (g_btype == 9) g_data[int('p')] = 1;
1098 //if(random(100)<50){fixed_raster_command(int('y'));} 1276 //if(random(100)<50){fixed_raster_command(int('y'));}
1099 for (int i = 0; i <= 12; i++) 1277 for (int i = 0; i <= 12; i++)
1100 { 1278 {
1101 int rx = x - 10 + int(random((10) * 2)); 1279 int rx = x - 10 + int(random((10) * 2));
1102 int ry = y - 10 + int(random((10) * 2)); 1280 int ry = y - 10 + int(random((10) * 2));
1103 if (mbut == LEFT) { 1281 if (mbut == LEFT)
1282 {
1104 if (dist(x, y, rx, ry) < 10) craft(rx, ry, 0); 1283 if (dist(x, y, rx, ry) < 10) craft(rx, ry, 0);
1105 } else { 1284 }
1285 else
1286 {
1106 if (dist(x, y, rx, ry) < 10) craft(rx, ry, 0); 1287 if (dist(x, y, rx, ry) < 10) craft(rx, ry, 0);
1107 } 1288 }
1108 } 1289 }
1109 } 1290 }
1110 else 1291 else
1196 } 1377 }
1197 else 1378 else
1198 if (tt == 4) 1379 if (tt == 4)
1199 { 1380 {
1200 //brush grabber grab brush 1381 //brush grabber grab brush
1201 if (g_phase == 0) { 1382 if (g_phase == 0)
1383 {
1202 g_rx = x; 1384 g_rx = x;
1203 g_orx = x; 1385 g_orx = x;
1204 g_ry = y; 1386 g_ry = y;
1205 g_ory = y; 1387 g_ory = y;
1206 g_rx2 = x; 1388 g_rx2 = x;
1207 g_ry2 = y; 1389 g_ry2 = y;
1208 } 1390 }
1209 else 1391 else
1210 if (g_phase == 1) { 1392 if (g_phase == 1)
1393 {
1211 g_rx2 = x; 1394 g_rx2 = x;
1212 g_rx = g_orx; 1395 g_rx = g_orx;
1213 g_ry2 = y; 1396 g_ry2 = y;
1214 g_ry = g_ory; 1397 g_ry = g_ory;
1215 if (x < g_orx) { 1398 if (x < g_orx)
1399 {
1216 g_rx2 = g_orx; 1400 g_rx2 = g_orx;
1217 g_rx = x; 1401 g_rx = x;
1218 } 1402 }
1219 if (y < g_ory) { 1403 if (y < g_ory)
1404 {
1220 g_ry2 = g_ory; 1405 g_ry2 = g_ory;
1221 g_ry = y; 1406 g_ry = y;
1222 } 1407 }
1223 if (g_data[int('c')] == 1 || g_shift) { 1408 if (g_data[int('c')] == 1 || g_shift)
1409 {
1224 g_rx2--; 1410 g_rx2--;
1225 g_ry2--; 1411 g_ry2--;
1226 if (g_pixelw == 2) g_rx2--; 1412 if (g_pixelw == 2) g_rx2--;
1227 } 1413 }
1228 } 1414 }
1229 g_rubbermode = 1; 1415 g_rubbermode = 1;
1230 } 1416 }
1231 1417
1232 if (tt == 0 || tt == 4) 1418 if (tt == 0 || tt == 4)
1233 { 1419 {
1234 if (g_rubbermode == 1) { 1420 if (g_rubbermode == 1)
1235 for (int xx = g_rx; xx <= g_rx2 + 2; xx++) { 1421 {
1422 for (int xx = g_rx; xx <= g_rx2 + 2; xx++)
1423 {
1236 updatepoint(xx, g_ry); 1424 updatepoint(xx, g_ry);
1237 updatepoint(xx, g_ry2); 1425 updatepoint(xx, g_ry2);
1238 } 1426 }
1239 for (int yy = g_ry; yy <= g_ry2; yy++) { 1427 for (int yy = g_ry; yy <= g_ry2; yy++)
1428 {
1240 updatepoint(g_rx, yy); 1429 updatepoint(g_rx, yy);
1241 updatepoint(g_rx2, yy); 1430 updatepoint(g_rx2, yy);
1242 } 1431 }
1243 } 1432 }
1244 } 1433 }