Date:2012-12-04 11:23:24 (11 years 3 months ago)
Author:Werner Almesberger
Commit:2161eec066dd351947fff8e6039c5eed1b4d6075
Message:tornado/fw/txt: xbm2tornado to create #include-able tornado binary; -g for t

Files: tornado/fw/txt/t (1 diff)
tornado/fw/txt/xbm2tornado (1 diff)

Change Details

tornado/fw/txt/t
11#!/bin/sh
2./txt2xbm TEST | ./stretch 6 | ./xbm2gp "$@" | ./plot
2T="TEST"
3F=6
4if [ "$1" = -g ]; then
5    shift
6    ./txt2xbm "$T" | ./stretch $F | ./xbm2gp "$@" | ./plot
7else
8    ./txt2xbm "$T" | ./stretch $F | ./xbm2tornado
9fi
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";

Archive Download the corresponding diff file

Branches:
master
tornado-v1



interactive