// dither.c #include "dither.h" #define NUMGRAYS 49 unsigned char dither[NUMGRAYS][4]; unsigned char *ditherpalette[256]; int order[16][2] = { {0,0}, {2,2}, {2,0}, {0,2}, {1,1}, {3,3}, {3,1}, {1,3}, {1,0}, {3,2}, {3,0}, {1,2}, {0,1}, {2,3}, {2,1}, {0,3} }; /* =============== = = MakeDither = = Creates NUMGRAYS bit patterns = Must be called before any updates =============== */ void MakeDither (void) { int b,g,o,x,y,dgray; unsigned char dith[4]; char pal[768]; // the dither starts out all black dgray = 0; for (b=0 ; b<4 ; b++) dither[dgray][b] = dith[b] = 0; dgray++; for (g=1 ; g<= 3 ; g++) { for (o=0 ; o<=15 ; o++) { // set one more pixel to the new gray level x = order[o][0]*2; y = order[o][1]; dith[y] &= ~(3<>1; // OPTIMIZE: this could be faster by making multiple copies of the dither // with the apropriate bits already masked off for (y=0 ; y>2; // OPTIMIZE: this could be faster by making multiple copies of the dither // with the apropriate bits already masked off for (y=0 ; y