Root/tornado/fw/txt/xbm2tornado

1#!/usr/bin/perl
2
3sub pick
4{
5    local ($x, $y) = @_;
6
7    my $i = $x+$y*$X;
8    return ((hex $p[$i >> 3]) >> ($i & 7)) & 1;
9}
10
11
12while (<>) {
13    chop;
14    if (/#define\s+\S+_width\s+(\d+)/) {
15        $X = $1;
16        next;
17    }
18    if (/#define\s+\S+_height\s+(\d+)/) {
19        $Y = $1;
20        next;
21    }
22    next unless /\s*0x/;
23    s/^\s*//;
24    s/(,|};)$//;
25    push(@p, split /,/);
26}
27
28for ($x = 0; $x != $X; $x++) {
29    for ($y = 0; $y != $Y; $y += 8) {
30        $v = 0;
31        for ($i = 0; $i != 8; $i++) {
32            $v |= 1 << $i if &pick($x, $y+$i);
33        }
34        print sprintf("0x%02x, ", $v);
35    }
36}
37print "\n";
38

Archive Download this file

Branches:
master
tornado-v1



interactive