File: icontopix

package info (click to toggle)
blockade 20041028-9
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k, lenny
  • size: 500 kB
  • ctags: 804
  • sloc: ansic: 7,485; sh: 177; makefile: 86
file content (144 lines) | stat: -rwxr-xr-x 2,824 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#! /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