diff options
author | B. Watson <yalhcru@gmail.com> | 2021-05-05 01:50:12 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2021-05-05 01:50:12 -0400 |
commit | 1989c02b763a04d0f941114056f11bb96bdb2550 (patch) | |
tree | 459faeceae7280c2cd2c18e703e863b8ab9cc5e0 /shipshape.pl | |
parent | 682bb2a6174a30578f1dd770ebd3d1f39938bf6c (diff) | |
download | taipan-1989c02b763a04d0f941114056f11bb96bdb2550.tar.gz |
Finally fix damaged ship gfx
Diffstat (limited to 'shipshape.pl')
-rw-r--r-- | shipshape.pl | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/shipshape.pl b/shipshape.pl new file mode 100644 index 0000000..89cfacd --- /dev/null +++ b/shipshape.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl -w + +# draws an ASCII art representation of the lorcha. + +use bytes; + +if(!@ARGV) { + push @ARGV, "LORCHA.DAT"; +} + +undef $/; +$_ = <>; +@shape = unpack "C*", $_; + +open $in, "<taifont" or die $!; +$f = <$in>; +close $in; + +@out = (); + +for($row = 0; $row < 7; $row++) { + for($col = 0; $col < 7; $col++) { + draw_tile($row, $col); + } +} + +for($row = 0; $row < @out; $row++) { + for($col = 0; $col < 7; $col++) { + print $out[$row][$col]; + } + print "\n"; +} + + +sub draw_tile { + my $row = shift; + my $col = shift; + my $tile = $shape[$row * 7 + $col]; + my $reverse = 0; + my $i; + my $j; + my $y = $row * 8; + #$out[$row][$col] = sprintf(" %03x", $tile); + + if($tile > 127) { + $tile -= 128; + $reverse = 1; + } + for($i = 0; $i < 8; $i++) { + my $data = sprintf "%08b", ord substr($f, $tile * 8 + $i, 1); + if($reverse) { + $data =~ s/0/X/g; + $data =~ s/1/ /g; + } else { + $data =~ s/1/X/g; + $data =~ s/0/ /g; + } + + $out[$y + $i][$col] = $data; + } +} |