From 2161eec066dd351947fff8e6039c5eed1b4d6075 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 4 Dec 2012 07:23:24 -0300 Subject: [PATCH] tornado/fw/txt: xbm2tornado to create #include-able tornado binary; -g for t --- tornado/fw/txt/t | 9 ++++++++- tornado/fw/txt/xbm2tornado | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 tornado/fw/txt/xbm2tornado 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";