# HG changeset patch # User Matti Hamalainen # Date 1533816233 -10800 # Node ID e899ca447a69a99470df72c3bf7fadaf64a2fabf # Parent a6af71199946360ce36ef9b4ac6bbbf4e729e3fd Cosmetics. diff -r a6af71199946 -r e899ca447a69 draw_inputs.pde --- a/draw_inputs.pde Thu Aug 09 14:40:25 2018 +0300 +++ b/draw_inputs.pde Thu Aug 09 15:03:53 2018 +0300 @@ -1,38 +1,47 @@ // Collect all that "reads" the virtual image in some way or other // plus other passive manipulations -int odd(int v) { +int odd(int v) +{ return (v & 1); } -int even(int v) { + +int even(int v) +{ return 1 - (v & 1); } -float getangel(float xx, float yy) { + +float getangel(float xx, float yy) +{ float ang = degrees(atan2(xx, -yy)); return (ang < 0) ? 360 + ang : ang; } -int zxcolor(int col) { + +int zxcolor(int col) +{ //something that allows different zx brightness colors treated logically as the same //i.e. bright red and dark red the same. handy for brush transparency if (g_britemode == 0) return col; return (col > 7) ? col - 8 : col; } + //the "slow" call to mark "dirty block" -void updatepoint(int xx, int yy) { +void updatepoint(int xx, int yy) +{ if (yy < 0 || xx < 0 || xx >= X || yy >= Y) return; int ad = int(xx / 8) + int(yy / 8) * MX; g_redo[ad] = byte(0); //block update g_remdo[ad] = byte(1); //block update } -int getmultibrush(int x1, int y1) { +int getmultibrush(int x1, int y1) +{ //returns the multicolor color on point x1,y1 at brush - int ad, looks, mmc; if (g_multic == 2) return g_brush[1024 + x1 + y1 * X]; @@ -53,6 +62,7 @@ return g_brush[ad] + g_brush[ad + 1] * 2; } + int getmultic(int x1, int y1, int mode) //mode 0=screen 1=brush { //returns the multicolor color on point x1,y1 @@ -71,11 +81,14 @@ x1 = chop2(x1); looks = 65536 + int(x1 / 8) + int(y1 / 8) * MX; - if (mode == 0) { + if (mode == 0) + { source1 = g_map[ad]; source2 = g_map[ad + 1]; } - if (mode == 1) { + else + if (mode == 1) + { source1 = g_brush[ad]; source2 = g_brush[ad + 1]; } @@ -88,8 +101,10 @@ //10=color2=1 //11=color3=3 - if (mode == 0) { - switch (mmc) { + if (mode == 0) + { + switch (mmc) + { case 0: return g_map[1]; case 1: @@ -101,8 +116,11 @@ return g_map[looks + 2000]; } } - if (mode == 1) { - switch (mmc) { + else + if (mode == 1) + { + switch (mmc) + { case 0: return g_map[1]; case 1: @@ -114,9 +132,11 @@ return g_brush[looks + 2000]; } } + return source1 + source2; } + int getattra(int xx, int yy, int mode) //mode foreground backround { //returns the internal foreground / background color on point xx,yy @@ -143,6 +163,7 @@ return val; } + int getabsa(int xx, int yy, int mode) //mode 0=screen 1=brush { // returns the visible colour on point xx,yy @@ -161,7 +182,8 @@ else ssap = int(g_brush[sad]); - if (ssap == 1) { + if (ssap == 1) + { if (mode == 0) { val = g_map[ad]; } else { @@ -182,15 +204,25 @@ return g_map[sad]; } + //the most accessible way to get a color index from a point -int easygetcolor(int xx, int yy) { - if (yy < 0 || xx < 0 || xx >= X || yy >= Y) return 0; - if (g_multic > 0) return getmultic(xx, yy, 0); - if (g_multic == 0) return getabsa(xx, yy, 0); - return 0; +int easygetcolor(int xx, int yy) +{ + if (yy < 0 || xx < 0 || xx >= X || yy >= Y) + return 0; + else + if (g_multic > 0) + return getmultic(xx, yy, 0); + else + if (g_multic == 0) + return getabsa(xx, yy, 0); + else + return 0; } -void infersize() { + +void infersize() +{ int xx, yy, cp, okay; int bx, by; storeparameters(); @@ -258,6 +290,7 @@ message("Play Brush|" + g_animx + " x " + g_animy + "|" + g_animframes + " frames"); } + void animbrush_do() { int bx, by; int horisize;