diff options
author | B. Watson <yalhcru@gmail.com> | 2016-01-06 19:31:41 -0500 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2016-01-06 19:31:41 -0500 |
commit | e6ad2ef0c8083c603d014d4b37addb9b1bf98294 (patch) | |
tree | 5eda6b152383ce086b2d7dc470a17f18729412d2 /text2screen.pl | |
parent | 7ac76fb4e4117887f6fd80ca7d6659be88209313 (diff) | |
download | taipan-e6ad2ef0c8083c603d014d4b37addb9b1bf98294.tar.gz |
change bg/text colors in title screen, plus Esc for help
Diffstat (limited to 'text2screen.pl')
-rw-r--r-- | text2screen.pl | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/text2screen.pl b/text2screen.pl new file mode 100644 index 0000000..7fe4849 --- /dev/null +++ b/text2screen.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl -w + +# Turn each line of stdin into one 32-byte line of Atari screen codes, +# truncating or padding with nulls as needed. + +# Input format is plain text, except any character can be preceded +# by a \ to inverse it. No way to get a non-inverse \ in there, sorry. + +use bytes; + +$linelen = $1 || 32; # 32 for narrow playfield, would be 40 for normal. + +while(<>) { + chomp; + + s/\\(.)/chr(ord($1)|0x80)/ge; + + if(length > $linelen) { + warn "$0: line $. truncated to 32 characters!\n"; + substr($_, 32) = ""; + } + + my $blanks = $linelen; + for(map { ord } split "", $_) { + my $byte = $_ & 0x7f; + my $inv = $_ & 0x80; +#warn sprintf("\$_ %02x, \$byte %02x, \$inv %02x", $_, $byte, $inv); + if($byte < 32) { + $byte += 64; + } elsif($byte >= 32 && $byte <= 96) { + $byte -= 32; + } +#warn sprintf("result: %02x", ($byte | $inv)); + print chr($byte | $inv); + $blanks--; + } + print chr(0) x $blanks; +} |