1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-12-01 20:03:10 +02:00
antorcha/tornado/fw/txt/xbm2tornado

38 lines
533 B
Plaintext
Raw Normal View History

#!/usr/bin/perl
sub pick
{
local ($x, $y) = @_;
my $i = $x+$y*$X;
return ((hex $p[$i >> 3]) >> ($i & 7)) & 1;
}
while (<>) {
chop;
if (/#define\s+\S+_width\s+(\d+)/) {
$X = $1;
next;
}
if (/#define\s+\S+_height\s+(\d+)/) {
$Y = $1;
next;
}
next unless /\s*0x/;
s/^\s*//;
s/(,|};)$//;
push(@p, split /,/);
}
for ($x = 0; $x != $X; $x++) {
for ($y = 0; $y != $Y; $y += 8) {
$v = 0;
for ($i = 0; $i != 8; $i++) {
$v |= 1 << $i if &pick($x, $y+$i);
}
print sprintf("0x%02x, ", $v);
}
}
print "\n";