diff --git a/tornado/fw/txt/t b/tornado/fw/txt/t index ec5a418..2f2c2e6 100755 --- a/tornado/fw/txt/t +++ b/tornado/fw/txt/t @@ -1,2 +1,9 @@ #!/bin/sh -./txt2xbm TEST | ./stretch 6 | ./xbm2gp "$@" | ./plot +T="TEST" +F=6 +if [ "$1" = -g ]; then + shift + ./txt2xbm "$T" | ./stretch $F | ./xbm2gp "$@" | ./plot +else + ./txt2xbm "$T" | ./stretch $F | ./xbm2tornado +fi diff --git a/tornado/fw/txt/xbm2tornado b/tornado/fw/txt/xbm2tornado new file mode 100755 index 0000000..dc21ffe --- /dev/null +++ b/tornado/fw/txt/xbm2tornado @@ -0,0 +1,37 @@ +#!/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";