aboutsummaryrefslogtreecommitdiff
path: root/multixex.pl
diff options
context:
space:
mode:
Diffstat (limited to 'multixex.pl')
-rw-r--r--multixex.pl25
1 files changed, 25 insertions, 0 deletions
diff --git a/multixex.pl b/multixex.pl
new file mode 100644
index 0000000..e843cab
--- /dev/null
+++ b/multixex.pl
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+
+# concatenate 2 or more atari binary load files, removing the $FFFF
+# headers from the 2nd and further ones.
+
+# this shouldn't be necessary: Atari DOS 2.0S can handle the extra
+# $FFFF headers, and it sets the gold standard for Atari executables.
+# any loader that can't handle them, is broken. however, people apparently
+# use these broken loaders a lot these days, so we'll be nice and
+# support them.
+
+use bytes;
+
+die "Usage: $0 <xex-file> [<xex-file>] ... > output.xex\n" unless @ARGV;
+
+undef $/;
+$header_emitted = 0;
+
+for(@ARGV) {
+ open my $fh, "<$_" or die "$0: $_: $!\n";
+ my $data = <$fh>;
+ substr($data, 0, 2) = "" if substr($data, 0, 2) eq "\xff\xff";
+ $header_emitted++, print "\xff\xff" unless $header_emitted;
+ print $data;
+}