Archive-ByteBoozer2
view release on metacpan or search on metacpan
Archive::ByteBoozer2 Version 0.03
=================================
Archive::ByteBoozer2 package provides a Perl interface to David Malmborg's
"ByteBoozer 2.0", a data cruncher for Commodore files written in C. The
following operations are supported: crunching files, crunching files and
making an executable with start address $xxxx, crunching files and relocating
data to hex address $xxxx.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
lib/Archive/ByteBoozer2.pm view on Meta::CPAN
=head1 SYNOPSIS
use Archive::ByteBoozer2 qw(:all);
# Crunch file:
crunch($file_name);
# Crunch file and make executable with start address $xxxx:
ecrunch($file_name, $address);
# Crunch file and relocate data to hex address $xxxx:
rcrunch($file_name, $address);
=head1 DESCRIPTION
David Malmborg's C<ByteBoozer 2.0> is a data cruncher for Commodore files written in C. C<ByteBoozer 2.0> is very much the same as C<ByteBoozer 1.0>, but it generates smaller files and decrunches at about 2x the speed. An additional effort was put in...
In Perl the following operations are implemented via C<Archive::ByteBoozer2> package:
=over
=item *
Compressing a file.
=item *
Compressing a file and making an executable with start address C<$xxxx>.
=item *
Compressing a file and relocating data to hex address C<$xxxx>.
=back
Compressed data is by default written into a file named with C<.b2> suffix. Target file must not exist. If you want an executable, use C<ecrunch>. If you want to decrunch yourself, use C<crunch> or C<rcrunch>. The decruncher should be called with C<X...
=head1 METHODS
=cut
use bytes;
lib/Archive/ByteBoozer2.pm view on Meta::CPAN
=cut
sub ecrunch {
my ($file_name, $address) = @_;
_crunch($file_name, $address, 1, 0);
}
=head2 rcrunch
Crunch file and relocate data to hex address C<$xxxx>:
rcrunch($file_name, $address);
=cut
sub rcrunch {
my ($file_name, $address) = @_;
_crunch($file_name, $address, 0, 1);
}
sub _crunch {
my ($file_name, $address, $is_executable, $is_relocated) = @_;
unless ($address =~ m/^\d+$/ && $address >= 0x0000 && $address <= 0xffff) {
die qq{Don't understand, aborting...};
}
my $file = _read_file($file_name);
my $bb_file = _crunch_file($file, $address, $is_executable, $is_relocated);
_write_file($bb_file, $file);
printf qq{B2: "%s" -> "%s"\n}, file_name($file), file_name($bb_file);
free_file($file, $bb_file);
}
sub _read_file {
my ($file_name) = @_;
my $file = alloc_file();
unless (read_file($file, $file_name)) {
free_file($file);
die qq{Error: Open file "$file_name" failed, aborting...};
}
return $file;
}
sub _crunch_file {
my ($file, $address, $is_executable, $is_relocated) = @_;
my $bb_file = alloc_file();
unless (crunch_file($file, $bb_file, $address, $is_executable, $is_relocated)) {
free_file($file, $bb_file);
die qq{Error: Crunch data failed, aborting...};
}
return $bb_file;
}
sub _write_file {
my ($bb_file, $file) = @_;
( run in 0.584 second using v1.01-cache-2.11-cpan-71847e10f99 )