Root/tools/xbm2ant

Source at commit 63a4b895d3d7da5a8b71ab383976ae835db52e99 created 10 years 11 months ago.
By Werner Almesberger, tornado/cpu/cpu.sch (CON3): nISP and nRESET were swapped
1#!/usr/bin/perl
2#
3# tools/xbm2ant - Convert X bitmap file to Antorcha image binary
4#
5# Written 2012 by Werner Almesberger
6# Copyright 2012 Werner Almesberger
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13
14sub add
15{
16    local $v = $_[0];
17
18    for (my $i = 0; $i != 8; $i++) {
19        push(@v, ($v >> $i) & 1);
20    }
21}
22
23
24while (<>) {
25    if (/width (\d+)/) {
26        $xm = $1;
27        next;
28    }
29    if (/height (\d+)/) {
30        $ym = $1;
31        die "no more than 16 rows" if $ym > 16;
32        next;
33    }
34    next unless /^\s*(0x.*[0-9abcdef])/;
35    for (split(/,\s*/, $1)) {
36        &add(hex($_));
37    }
38}
39
40$span = ($xm+7) & ~7;
41for ($x = 0; $x != $xm; $x++) {
42    $v = 0;
43    for ($y = 0; $y != 16; $y++) {
44        $v |= 1 << $y if $v[$x+$y*$span];
45    }
46    print pack("v", $v);
47}
48

Archive Download this file

Branches:
master
tornado-v1



interactive