X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=16%2Fscrasm%2FGENSQ.C;fp=16%2Fscrasm%2FGENSQ.C;h=402853f3011ed5a66d24334b87b474eedca8575b;hb=b50a0eb714c64dee65050539243e02ef2aa308b5;hp=0000000000000000000000000000000000000000;hpb=c703087fbf8156953e47763ca81fd07227e3358c;p=16.git diff --git a/16/scrasm/GENSQ.C b/16/scrasm/GENSQ.C new file mode 100644 index 00000000..402853f3 --- /dev/null +++ b/16/scrasm/GENSQ.C @@ -0,0 +1,102 @@ +#include +#include +#include +#include + +#define WIDTH 256 + +#define FILENAME "DIAGONAL.TIL" +char fn[100] = FILENAME; +typedef unsigned char BYTE; +typedef BYTE ROW[16]; +typedef ROW BITMAP[16]; + +BITMAP b; +BITMAP c; + +BITMAP pattern={{1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0}, + {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + {1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0}, + {1,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0}, + {1,0,0,1,0,0,0,0,0,0,0,2,0,0,0,0}, + {0,0,1,0,0,1,1,0,1,1,0,0,2,0,0,0}, + {0,0,1,0,0,1,2,0,1,2,0,0,2,0,0,0}, + {0,1,0,0,0,0,0,0,0,0,0,0,0,2,0,0}, + {0,1,0,0,0,0,0,0,0,0,0,0,0,2,0,0}, + {0,1,0,0,1,2,0,0,0,1,2,0,0,2,0,0}, + {0,0,1,0,1,2,1,1,1,1,2,0,2,0,0,0}, + {0,0,1,0,0,2,2,2,2,2,0,0,2,0,0,2}, + {0,0,0,1,0,0,0,0,0,0,0,2,0,0,0,2}, + {0,0,0,0,2,2,0,0,0,2,2,0,0,0,0,2}, + {0,0,0,0,0,0,2,2,2,0,0,0,0,0,2,2}, + {0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2}}; + +void copy_pattern(BITMAP b,BITMAP patt, BYTE l, BYTE m, BYTE h) + { + int x,y; + + for (y=0; y<16; y++) { + for (x=0; x<16; x++) { + switch (patt[y][x]) { + case 0: + b[y][x] = m; + break; + case 1: + b[y][x] = l; + break; + case 2: + b[y][x] = h; + break; + } + } + } + } + +/* Transforms linear to planar */ +void transform(BITMAP b,BITMAP c) + { + int x,y,p; + BYTE *pb = (BYTE *)c; + + for (p=0; p<4; p++) { + for (y=0; y<16; y++) { + for (x=0; x<16; x+=4) { + *(pb++) = b[y][x+p]; + } + } + } + } + +void main(int argc,char *argv[]) + { + FILE *fp; + int i; + int width = WIDTH; + + fp = fopen(fn,"wb"); + if (!fp) { + printf("Couldn't open %s for write.\n",fn); + exit(1); + } + if (argc > 1) { + width = atoi(argv[1]); + if (width > WIDTH) + width = WIDTH; + printf("Width = %d\n",width); + } + + for (i = 0; i< width; i++) { + BYTE less,more; + + less = (BYTE)((i + width - 1) % width); + more = (BYTE)((i + 1) % width); + copy_pattern(b, pattern, less, (BYTE)i, more); + transform(b,c); + fwrite(c, 16,16, fp); + printf("Square %d\r",i); + } + fclose(fp); + printf("All done! \n"); + exit(0); + } + \ No newline at end of file