#! /bin/sh # Copyright status: this file is in the public domain. # This script knows that icons are 32x32 (see editicon.c, ICON_W and ICON_H) # and that small icons are 8x8 (ICON_SW and ICON_SH). These have to match # the values in blockade-pix.h (PIX_W/PIX_H/PIX_SW/PIX_SH). exec >blockade-pix.c echo '#include "blockade-pix.h"' echo '/*' egrep '^#' < blockade-pix.ei echo '*/' < blockade-pix.ei sed -e 1d -e '/^#/d' | cat -s | sed -e 1d > blockade-pix.TMP echo 'unsigned short int b_p_colours[B_NCOLOURS][3] = {' < blockade-pix.TMP sed -e 1d -e '/^$/,$d' -e 's/ /,/g' -e 's/^[0-9]*,//' -e 's/.*/{&},/' echo '};' echo 'unsigned char b_p_pix_colour[B_NPIX][PIC_H][PIC_W] = {' < blockade-pix.TMP sed -e 1d -e '/^[0-9][0-9]*$/,/^$/d' | awk 'BEGIN { incols = 1; c = 48; i = 0; r = 0; } incols>0 { if ($0 == "") { incols = 0; for (i in colc) { if (colc[i] > 58) printf("#define %c %d\n",colc[i],coln[i]); } } else { colc[$1] = c; coln[$1] = i; i ++; c ++; if (c == 58) c = 65; else if (c == 91) c = 97; } next; } NF==0 { r = 0; next; } { if (NF == 0) next; if (r < 32) { if (r == 0) printf("{\n"); printf("{"); for (i=1;i<=NF;i++) { printf("%c,",colc[$i]); } printf("},\n"); if (r == 31) printf("},\n"); } r ++; } ' echo '};' echo 'unsigned char b_p_pix_bw[B_NPIX][PIC_H][PIC_W] = {' < blockade-pix.TMP sed -e '1,/^$/d' | sed -e '1,/^$/d' | awk 'BEGIN { r = 0; } NF==0 { r = 0; next; } { if ((r >= 32) && (r < 64)) { if (r == 32) printf("{\n"); printf("{"); for (i=1;i<=NF;i++) { printf("%s,",$i); } printf("},\n"); if (r == 63) printf("},\n"); } r ++; } ' echo '};' echo 'unsigned char b_sp_pix_colour[B_NPIX][PIC_SH][PIC_SW] = {' < blockade-pix.TMP sed -e '/^[0-9][0-9]*$/d' | awk 'BEGIN { incols = 1; c = 48; i = 0; r = 0; } incols>0 { if ($0 == "") { incols = 0; } else { colc[$1] = c; coln[$1] = i; i ++; c ++; if (c == 58) c = 65; else if (c == 91) c = 97; } next; } NF==0 { r = 0; next; } { if ((r >= 64) && (r < 72)) { if (r == 64) printf("{\n"); printf("{"); for (i=1;i<=NF;i++) { printf("%c,",colc[$i]); } printf("},\n"); if (r == 71) printf("},\n"); } r ++; } ' echo '};' echo 'unsigned char b_sp_pix_bw[B_NPIX][PIC_SH][PIC_SW] = {' < blockade-pix.TMP sed -e '1,/^$/d' | sed -e '1,/^$/d' | awk 'BEGIN { r = 0; } NF==0 { r = 0; next; } { if ((r >= 72) && (r < 80)) { if (r == 72) printf("{\n"); printf("{"); for (i=1;i<=NF;i++) { printf("%s,",$i); } printf("},\n"); if (r == 79) printf("},\n"); } r ++; } ' echo '};' rm -f blockade-pix.TMP