#include #include #include int *big_map=NULL, *temp_map=NULL; int map_edge; /*{{{ friggy stuff*/ static int clut[16] = { 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56 }; /*}}} */ /*{{{ static int funny_fourbits ( int eight )*/ static int funny_fourbits ( int eight ) { int ix=0, c0, c1; if ((eight & 15) > 7) { eight+=15; if (eight > 255) return 15; } return eight>>4; eight>>=2; if (eight > clut[15]) eight=clut[15]; while (clut[ix+1] < eight) ix++; c0=clut[ix]; c1=clut[ix+1]; c0-=eight; c1-=eight; if ((c0*c0) < (c1*c1)) return ix; else return ix+1; } /*}}} */ /*{{{ static void fourbit_mono ( int field, int *temp_map, int *big_map )*/ static void fourbit_mono ( int field, int *temp_map, int *big_map ) { int i, mask, shift; mask=~(0xf<>8); r=0xff & (v>>16); g=0xff & (v>>24); v=0xff & (((180*g)+(51*r)+(25*b)) >> 8); v=funny_fourbits(v); w=*big_map; *big_map=(w&mask)|(v<>8); r=0xff & (v>>16); g=0xff & (v>>24); v=0xff & (((180*g)+(51*r)+(25*b)) >> 8); w=*big_map; *big_map=(w&mask)|(v<>8); g=0xff & (v>>16); r=0xff & (v>>24); r = (r>>5) & 0x7; g = (g>>5) & 0x7; b = (b>>6) & 0x3; v=r|(g<<3)|(b<<6); w=*big_map; *big_map=(w&mask)|(v<>8); g=0xff & (v>>16); r=0xff & (v>>24); r=funny_fourbits ( r ); g=funny_fourbits ( g ); b=funny_fourbits ( b ); v=r|(g<<4)|(b<<8); w=*big_map; *big_map=(w&mask)|(v<