diff options
Diffstat (limited to 'bin/pnm2chr')
-rw-r--r-- | bin/pnm2chr | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bin/pnm2chr b/bin/pnm2chr new file mode 100644 index 0000000..4f0dc33 --- /dev/null +++ b/bin/pnm2chr @@ -0,0 +1,26 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use Games::NES::SpriteMaker 'image_to_sprite'; + +my $data; +if (@ARGV) { + $data = $ARGV[0]; +} +else { + $data = \(do { local $/; <> }); +} + +my $sprite_data = image_to_sprite($data); + +if (@ARGV) { + (my $outfile = $data) =~ s/\..*$/.chr/; + open my $fh, '>', $outfile + or die "Couldn't open $outfile for writing: $!"; + $fh->print($sprite_data); + $fh->close; +} +else { + print $sprite_data; +} |