xref: /plan9/sys/src/games/blabs/mkface (revision 3e5d0078acdadead679c94c0daec143041c4b41e)
1#!/bin/rc
2
3fn unhex {
4	tr '	' ' ' | sed 's/0x//g;s/[, ]//g;s/../0x&, /g;s/^/	/'
5}
6
7if(! ~ $#* 1) {
8	echo 'usage: mkface who' >[1=2]
9	exit usage
10}
11
12who=$1
13x='^astro/'^$who^' '
14z='^([^ ]+)/'^$who^' '
15
16file=notfound
17for(i in 1 2 4 8)
18	if(y=`{grep $x /lib/face/48x48x$i/.dict} || y=`{grep $z /lib/face/48x48x$i/.dict})
19		file=/lib/face/48x48x$i/$y(2)
20
21if(~ $file notfound) {
22	echo 'cannot find face for '$who >[1=2]
23	exit noface
24}
25
26{
27	echo 'uchar '$who'bits[] = {'
28	switch($file) {
29	case *48x48x8* *48x48x4*
30		fb/enc2bit $file | dd -bs 60 -skip 1 >[2]/dev/null | xd |
31		sed 's#^.......##' | unhex
32	case *48x48x2* *48x48x1*
33		cat $file | unhex
34	}
35	echo '};'
36} >$who.bits
37
38