git @ Cat's Eye Technologies Dipple / master perl / stripbin
master

Tree @master (Download .tar.gz)

stripbin @masterraw · history · blame

#!/usr/bin/perl

# Strip a few leading bytes (the # specified on the command line)
# from a binary file.  Used to remove the load address from C64 .PRG
# files so they can be included at your chosen address in a .P65 source
# using the incbin directive.

# SPDX-FileCopyrightText: Chris Pressey, the original author of this work, has dedicated it to the public domain.
# For more information, please refer to <https://unlicense.org/>
# SPDX-License-Identifier: Unlicense

$file = $ARGV[0];
$outfile = $ARGV[1];
$bytes = $ARGV[2];

print "$file\n";
open FILE, "<$file";
binmode FILE;
read FILE, $contents, 65536;
close FILE;

print length($contents) . "\n";

$contents = substr($contents, $bytes);

print length($contents) . "\n";

open OUTFILE, ">$outfile";
binmode OUTFILE;
print OUTFILE $contents;
close OUTFILE;