The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

D64::Disk::Layout - Handling entire Commodore (D64/D71/D81) disk image data in pure Perl

SYNOPSIS

    use D64::Disk::Layout;

    # Create an empty disk layout instance:
    my $layout = D64::Disk::Layout->new();

    # Read disk image layout from existing file:
    my $layout = D64::Disk::Layout->new('image.d64');

    # Get disk sector object from a disk layout:
    my $sector_layout = $layout->sector(track => $track, sector => $sector);

    # Put new data into specific disk layout sector:
    $layout->sector(data => $sector_layout);
    # Update an arbitrary disk layout sector with data:
    $layout->sector(data => $sector_layout, track => $track, sector => $sector);

    # Fetch disk layout data as an array of 683 sector objects:
    my @sector_layouts = $layout->sectors();

    # Update disk layout given an array of arbitrary sector objects:
    $layout->sectors(sectors => \@sector_layouts);

    # Fetch disk layout data as a scalar of 683 * 256 bytes:
    my $data = $layout->data();

    # Update disk layout providing 683 * 256 bytes of scalar data:
    $layout->data(data => $data);

    # Print out nicely formatted human-readable form of a track/sector data:
    $layout->print(fh => $fh, track => $track, sector => $sector);

DESCRIPTION

D64::Disk::Layout provides a helper class for D64::Disk module, enabling users to easily access and manipulate entire D64/D71/D81 disk image data in an object oriented way without the hassle of worrying about the meaning of individual bits and bytes located on every track and sector of a physical disk image. The whole family of D64::Disk::Layout modules has been implemented in pure Perl as an alternative to Per Olofsson's "diskimage.c" library originally written in an ANSI C.

D64::Disk::Layout is completely unaware of an internal structure, configuration and meaning of individual sectors on disk. It only knows how to fetch and store bytes of data. Standard D64 disk image of 170 kbytes is split into 683 sectors on 35 tracks, each of the sectors holding 256 bytes. See description of the D64::Disk module for a detailed description on accessing individual disk image files and preserving disk directory structure.

METHODS

new

Create empty unformatted D64 disk image layout:

    my $d64DiskLayoutObj = D64::Disk::Layout->new();

Read D64 disk image layout from existing file:

    my $d64DiskLayoutObj = D64::Disk::Layout->new('image.d64');

A valid D64::Disk::Layout object is returned upon success, an undefined value otherwise.

sector

Retrieve disk sector object from a disk layout:

    my $sectorObj = $d64DiskLayoutObj->sector(track => $track, sector => $sector);

Insert new data into specific disk layout sector:

    $d64DiskLayoutObj->sector(data => $sectorObj);

Update an arbitrary disk layout sector with data:

    $d64DiskLayoutObj->sector(data => $sectorObj, track => $track, sector => $sector);

sectors

Fetch disk layout data as a flattened array of 683 sector objects:

    my @sector_layouts = $d64DiskLayoutObj->sectors();

Update disk layout given an array of arbitrary sector objects:

    $d64DiskLayoutObj->sectors(sectors => \@sector_layouts);

tracks

Fetch disk layout data as an array of 35 arrays of sector objects allocated by their respective track numbers:

    my @track_layouts = $d64DiskLayoutObj->tracks();

data

Fetch disk layout data as a scalar of 683 * 256 bytes:

    my $data = $d64DiskLayoutObj->data();

Update disk layout providing 683 * 256 bytes of scalar data:

    $d64DiskLayoutObj->data(data => $data);

print

Print out nicely formatted human-readable form of a track/sector data into any given IO::Handle:

    $d64DiskLayoutObj->print(fh => $fh, track => $track, sector => $sector);

BUGS

There are no known bugs at the moment. Please report any bugs or feature requests.

EXPORT

None. No method is exported into the caller's namespace either by default or explicitly.

SEE ALSO

D64::Disk::Image, D64::Disk::Layout::Sector, D64::Disk::Layout::Base.

AUTHOR

Pawel Krol, <pawelkrol@cpan.org>.

VERSION

Version 0.01 (2021-01-12)

COPYRIGHT AND LICENSE

Copyright 2021 by Pawel Krol <pawelkrol@cpan.org>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.