From f40f4a12a16b3bd378670f07ec8823fbb547de68 Mon Sep 17 00:00:00 2001 From: ehouse Date: Sat, 1 Nov 2003 18:36:13 +0000 Subject: [PATCH] first checkin --- xwords4/franklin/pbitm2frank.pl | 124 ++++++++++++++++++++++++++++++ xwords4/franklin/xwords4_icon.bmp | Bin 0 -> 798 bytes 2 files changed, 124 insertions(+) create mode 100755 xwords4/franklin/pbitm2frank.pl create mode 100644 xwords4/franklin/xwords4_icon.bmp diff --git a/xwords4/franklin/pbitm2frank.pl b/xwords4/franklin/pbitm2frank.pl new file mode 100755 index 000000000..05bfb1fad --- /dev/null +++ b/xwords4/franklin/pbitm2frank.pl @@ -0,0 +1,124 @@ +#!/usr/bin/perl +# Copyright 2001 by Eric House (fixin@peak.org). All rights reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# write a pbitm out in franklin "format" +# +# usage: pbitm2frank.pl infile outName + +use strict; + +my $infile = $ARGV[0]; +my $outname = $ARGV[1]; + +my @lines; +my $width = -1; +my $height = 0; + +open (INFILE, $infile) or die "can't find file $infile\n"; + +print qq ( +/* This file generated from $infile; do not edit!!! */ + +); + +while ( ) { + ++$height; + + s/\s//; # get rid of whitespace + push( @lines, $_ ); + + my $len = length($_); + if ( $width == -1 ) { + $width = $len; + } elsif ( $len != $width ) { + die "line $height width differs"; + } +} + +my $rowbytes = ($width + 7) >> 3; +my $structName = "${outname}_struct" ; + +print qq( typedef struct $structName { + IMAGE img; + U8 data[$height * $rowbytes]; +} $structName; + +); + +printStruct(0); + +print "#ifdef USE_INVERTED\n"; +printStruct(1); +print "#endif /* USE_INVERTED */\n"; + + +sub printStruct() { + my ($invert) = @_; + + my $thisName = $outname; + + if ( $invert ) { + $thisName .= "_inverted"; + } + + print qq( +$structName $thisName = { + { $width, $height, $rowbytes, + COLOR_MODE_MONO, 0, (const COLOR *) 0, (U8*)NULL }, + { + ); + + foreach my $line (@lines) { + printLine( $width, $line, $invert ); + } + + print " }\n};\n"; +} # printStruct + +sub printLine() { + my ($len, $line, $invert) = @_; + + $line .= '-------'; # pad with 7 0s + + if ( $invert ) { + $line =~ s/#/h/g; + $line =~ s/\-/#/g; + $line =~ s/h/\-/g; + } + + for ( my $i = 0; $len > 0; ++$i ) { + my $byte = 0; + my $subline = substr($line, $i*8, 8 ); + + for ( my $j = 0; $j < 8; ++$j ) { + my $ch = substr( $subline, $j, 1 ); + if ( $ch eq '-' ) { + } elsif ( $ch eq '#' ) { + $byte |= 1 << (7-$j); + } else { + print STDERR ("unexpected char $ch at offset ", + ($i*8)+$j, " in line $height\n"); + die; + } + } + + printf( "\t0x%x, ", $byte ); + $len -= 8; + } + + print "\t/* ", substr($line, 0, -7), " */\n"; +} # printLine diff --git a/xwords4/franklin/xwords4_icon.bmp b/xwords4/franklin/xwords4_icon.bmp new file mode 100644 index 0000000000000000000000000000000000000000..6c72e524879088ddc56a89e92fb430e16fd882da GIT binary patch literal 798 zcmcJM%?-jZ4250X0a}SOLU7?2kp&Rq$~p{|opQ|#yu@ym5?4h?xQZ2h_1|;u&jVAj z7yJe1q^G04@HLlGqH!E4gg`OIwJ?)E#D?i-hl?`yYOZD6GNP8T5$8S`dwk1W2lIZ( zO4wi6O~gZQmdvGxivNuv3*&1E(ZRyb^-fJDiPzmxhRQF`bFp5YCNr!|YHcy6b8N*K a^{l=Y6Kxo$>hUd`7EwN=PW^R=L literal 0 HcmV?d00001