summaryrefslogtreecommitdiffstats
path: root/bin/pnm2chr
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-10-08 17:26:28 -0400
committerJesse Luehrs <doy@tozt.net>2014-10-08 17:26:28 -0400
commitdaa8c5eca5a9fac0747599061b0159007a2440dc (patch)
treec83048ee4bb68e9ff9d653731fff8f6cc95e92f0 /bin/pnm2chr
parent3c4b248c80df103c4b94d77822b1a33ce772480c (diff)
downloadgames-nes-spritemaker-daa8c5eca5a9fac0747599061b0159007a2440dc.tar.gz
games-nes-spritemaker-daa8c5eca5a9fac0747599061b0159007a2440dc.zip
rename the script
Diffstat (limited to 'bin/pnm2chr')
-rw-r--r--bin/pnm2chr26
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;
+}