comparison draw_inputs.pde @ 225:1c9deae71fb1

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 05 Sep 2018 20:28:23 +0300
parents 6d866e284dd2
children
comparison
equal deleted inserted replaced
224:33a5c7670e66 225:1c9deae71fb1
50 if (g_multic == 2) return g_brush[1024 + xc + yc * X]; 50 if (g_multic == 2) return g_brush[1024 + xc + yc * X];
51 51
52 ad = 1024 + xc + yc * X; 52 ad = 1024 + xc + yc * X;
53 looks = 65536 + int(xc / 8) + int(yc / 8) * MX; 53 looks = 65536 + int(xc / 8) + int(yc / 8) * MX;
54 mmc = g_brush[ad] + g_brush[ad + 1] * 2; 54 mmc = g_brush[ad] + g_brush[ad + 1] * 2;
55 switch (mmc) { 55 switch (mmc)
56 {
56 case 0: 57 case 0:
57 return g_map[1]; 58 return g_map[1];
58 case 1: 59 case 1:
59 return g_brush[looks]; 60 return g_brush[looks];
60 case 2: 61 case 2:
183 else 184 else
184 ssap = int(g_brush[sad]); 185 ssap = int(g_brush[sad]);
185 186
186 if (ssap == 1) 187 if (ssap == 1)
187 { 188 {
188 if (mode == 0) { 189 if (mode == 0)
190 {
189 val = g_map[ad]; 191 val = g_map[ad];
190 } else { 192 }
193 else
194 {
191 val = g_brush[ad]; 195 val = g_brush[ad];
192 } 196 }
193 if (g_britemode == 1 && val == 8) return 0; 197 if (g_britemode == 1 && val == 8) return 0;
194 return val; 198 return val;
195 } 199 }
196 else 200 else
197 if (ssap == 0) { 201 if (ssap == 0)
198 if (mode == 0) { 202 {
203 if (mode == 0)
204 {
199 val = g_map[ad + (MX * MY) * 8]; 205 val = g_map[ad + (MX * MY) * 8];
200 } else { 206 }
207 else
208 {
201 val = g_brush[ad + (MX * MY) * 8]; 209 val = g_brush[ad + (MX * MY) * 8];
202 } 210 }
203 if (g_britemode == 1 && val == 8) return 0; 211 if (g_britemode == 1 && val == 8) return 0;
204 return val; 212 return val;
205 } 213 }
227 int bx, by; 235 int bx, by;
228 storeparameters(); 236 storeparameters();
229 xx = 0; 237 xx = 0;
230 okay = 0; 238 okay = 0;
231 cp = easygetcolor(0, 0); 239 cp = easygetcolor(0, 0);
232 for (xx = 0; xx < X; xx = xx + g_pixelw) { 240 for (xx = 0; xx < X; xx = xx + g_pixelw)
233 if (easygetcolor(xx, 0) == cp && okay == 0) { 241 {
242 if (easygetcolor(xx, 0) == cp && okay == 0)
243 {
234 g_animx = xx; 244 g_animx = xx;
235 } else { 245 }
246 else
247 {
236 okay = 1; 248 okay = 1;
237 } 249 }
238 } 250 }
239 okay = 0; 251 okay = 0;
240 for (yy = 0; yy < Y; yy++) { 252 for (yy = 0; yy < Y; yy++)
241 if (easygetcolor(0, yy) == cp && okay == 0) { 253 {
254 if (easygetcolor(0, yy) == cp && okay == 0)
255 {
242 g_animy = yy; 256 g_animy = yy;
243 } else { 257 }
258 else
259 {
244 okay = 1; 260 okay = 1;
245 } 261 }
246 } 262 }
247 263
248 g_animx = g_animx + g_pixelw; 264 g_animx = g_animx + g_pixelw;
249 g_animy = g_animy + 1; 265 g_animy = g_animy + 1;
250 if (g_animx > 63 || g_animy > 63 || g_animx <= 2 || g_animy <= 2) { 266 if (g_animx > 63 || g_animy > 63 || g_animx <= 2 || g_animy <= 2)
267 {
251 message("BAD SIZE|See manual"); 268 message("BAD SIZE|See manual");
252 restoreparameters(); 269 restoreparameters();
253 g_data[int('n')] = 0; 270 g_data[int('n')] = 0;
254 return; 271 return;
255 } 272 }
263 g_bsourcex2 = g_animx + g_animx - g_pixelw; 280 g_bsourcex2 = g_animx + g_animx - g_pixelw;
264 g_bsourcey2 = g_animy - 1; 281 g_bsourcey2 = g_animy - 1;
265 g_animframes = 0; 282 g_animframes = 0;
266 g_animno = 1; 283 g_animno = 1;
267 int raamit = -1; 284 int raamit = -1;
268 for (yy = 0; yy <= Y; yy = yy + g_animy) { 285 for (yy = 0; yy <= Y; yy = yy + g_animy)
269 for (xx = 0; xx <= X; xx = xx + g_animx) { 286 {
287 for (xx = 0; xx <= X; xx = xx + g_animx)
288 {
270 okay = 1; 289 okay = 1;
271 for (bx = 0; bx < g_animx; bx = bx + g_pixelw) { 290 for (bx = 0; bx < g_animx; bx = bx + g_pixelw)
272 for (by = 0; by < g_animy; by++) { 291 {
292 for (by = 0; by < g_animy; by++)
293 {
273 if (easygetcolor(xx + bx, yy + by) != cp) okay = 0; 294 if (easygetcolor(xx + bx, yy + by) != cp) okay = 0;
274 } 295 }
275 } 296 }
276 if (okay == 1 && g_animframes <= 1) g_animframes = raamit; 297 if (okay == 1 && g_animframes <= 1) g_animframes = raamit;
277 if (xx + g_animx < X || xx + g_animx == X) raamit++; 298 if (xx + g_animx < X || xx + g_animx == X) raamit++;
278 } 299 }
279 } 300 }
280 if (g_animframes <= 0) { 301 if (g_animframes <= 0)
302 {
281 message("BAD BOOKEND|See manual"); 303 message("BAD BOOKEND|See manual");
282 restoreparameters(); 304 restoreparameters();
283 g_data[int('n')] = 0; 305 g_data[int('n')] = 0;
284 g_bsourcex = boldsourcex; 306 g_bsourcex = boldsourcex;
285 g_bsourcey = boldsourcey; 307 g_bsourcey = boldsourcey;
289 } 311 }
290 message("Play Brush|" + g_animx + " x " + g_animy + "|" + g_animframes + " frames"); 312 message("Play Brush|" + g_animx + " x " + g_animy + "|" + g_animframes + " frames");
291 } 313 }
292 314
293 315
294 void animbrush_do() { 316 void animbrush_do()
317 {
295 int bx, by; 318 int bx, by;
296 int horisize; 319 int horisize;
297 horisize = int(X / g_animx); 320 horisize = int(X / g_animx);
298 g_animno = g_animno + 1; 321 g_animno = g_animno + 1;
299 if (g_animno > g_animframes) g_animno = 1; 322 if (g_animno > g_animframes) g_animno = 1;
303 g_bsourcey = by * g_animy; 326 g_bsourcey = by * g_animy;
304 g_bsourcex2 = g_bsourcex + g_animx - g_pixelw; 327 g_bsourcex2 = g_bsourcex + g_animx - g_pixelw;
305 g_bsourcey2 = g_bsourcey + g_animy - 1; 328 g_bsourcey2 = g_bsourcey + g_animy - 1;
306 } 329 }
307 330
308 void set_fixed_raster(int set) { 331 void set_fixed_raster(int set)
309 for (int i = 0; i < 64; i++) { 332 {
333 for (int i = 0; i < 64; i++)
334 {
310 g_fixedraster[i] = g_rasterpatterns[set * 64 + i]; 335 g_fixedraster[i] = g_rasterpatterns[set * 64 + i];
311 } 336 }
312 } 337 }
313 338
314 int get_raster(int xx, int yy) { 339 int get_raster(int xx, int yy)
340 {
315 xx = xx + g_raster_offset_x * g_pixelw; 341 xx = xx + g_raster_offset_x * g_pixelw;
316 yy = yy + g_raster_offset_y; 342 yy = yy + g_raster_offset_y;
317 if (g_pixelw == 2) { 343 if (g_pixelw == 2)
344 {
318 xx = int(xx / 2); 345 xx = int(xx / 2);
319 } 346 }
320 int mx = chop8(xx); 347 int mx = chop8(xx);
321 int my = chop8(yy); 348 int my = chop8(yy);
322 xx = xx - mx; 349 xx = xx - mx;
323 yy = yy - my; 350 yy = yy - my;
324 return g_fixedraster[xx + yy * 8]; 351 return g_fixedraster[xx + yy * 8];
325 } 352 }
326 353
327 void refreshpalette() { 354 void refreshpalette()
355 {
328 //relevant for alterable palettes, such as amiga or cpc 356 //relevant for alterable palettes, such as amiga or cpc
329 if (g_palsteps == 0) return; 357 if (g_palsteps == 0) return;
330 for (int i = 0; i < g_maxcolors; i++) { 358 for (int i = 0; i < g_maxcolors; i++)
359 {
331 makecolor(i, int(g_map[256 + i * 3]), int(g_map[256 + i * 3 + 1]), int(g_map[256 + i * 3 + 2])); 360 makecolor(i, int(g_map[256 + i * 3]), int(g_map[256 + i * 3 + 1]), int(g_map[256 + i * 3 + 2]));
332 } 361 }
333 } 362 }