From e0a67eec631adf312e8eec7eff30381c445a6afa Mon Sep 17 00:00:00 2001 From: Leeland Heins Date: Thu, 17 Jan 2019 09:39:13 -0600 Subject: [PATCH] Added start of copy and write for DOS 3.3 --- DOS33.pm | 27 +++++++++++++++++++++ README | 2 +- dos33copy.pl | 32 +++++++++++++++++++++++++ dos33write.pl | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 dos33copy.pl create mode 100644 dos33write.pl diff --git a/DOS33.pm b/DOS33.pm index a17b693..ce66267 100644 --- a/DOS33.pm +++ b/DOS33.pm @@ -610,5 +610,32 @@ sub rename_file { } } +# +# Copy a file +# +sub copy_file { + my ($dskfile, $filename, $new_filename, $dbg) = @_; + + $debug = 1 if (defined $dbg && $dbg); + + my ($file, $cat_trk, $cat_sec, $cat_buf) = find_file($dskfile, $filename); + if ($file->{'trk'}) { + ##FIXME + + } +} + +# +# Write a file to disk image. +# +sub write_file { + my ($dskfile, $filename, $new_filename, $mode, $conv, $dbg) = @_; + + $debug = 1 if (defined $dbg && $dbg); + + ##FIXME +} + + 1; diff --git a/README b/README index d1cd5c1..b42abd0 100644 --- a/README +++ b/README @@ -8,7 +8,7 @@ dos33umlock.pl -- mostly working dos33lock.pl -- mostly working dos33rename.pl -- started dos33delete.pl -- started -dos33copy.pl +dos33copy.pl -- started zap.pl -- partially working prozap.pl -- partially working procat.pl -- partially working diff --git a/dos33copy.pl b/dos33copy.pl new file mode 100644 index 0000000..4a24b15 --- /dev/null +++ b/dos33copy.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl -w + +# +# dos33copy.pl: +# +# Utility to copy a file on an Apple II DOS 3.3 disk image. +# +# 20190117 LSH +# + +use strict; + +use DOS33; + +my $debug = 0; + +while (defined $ARGV[0] && $ARGV[0] =~ /^-/) { + # Debug + if ($ARGV[0] eq '-d') { + $debug = 1; + shift; + } +} + +my $dskfile = shift or die "Must supply .dsk filename\n"; +my $filename = shift or die "Must supply filename (on disk image)\n"; +my $new_filename = shift or die "Must supply new filename\n"; + +copy_file($dskfile, $filename, $new_filename, $debug); + +1; + diff --git a/dos33write.pl b/dos33write.pl new file mode 100644 index 0000000..99c6ab0 --- /dev/null +++ b/dos33write.pl @@ -0,0 +1,65 @@ +#!/usr/bin/perl -w + +# +# dos33write.pl: +# +# Utility to write a file into an Apple II DOS 3.3 disk image. +# +# 20190117 LSH +# + +use strict; + +use DOS33; + +my $mode = 'T'; +my $conv = 1; +my $debug = 0; + +while (defined $ARGV[0] && $ARGV[0] =~ /^-/) { + # Mode + if ($ARGV[0] eq '-m' && defined $ARGV[1] && $ARGV[1] ne '') { + # Text + if ($ARGV[1] eq 'T') { + $mode = 'T'; + $conv = 1; + # Integer BASIC + } elsif ($ARGV[1] eq 'I') { + $mode = 'I'; + $conv = 0; + # Applesoft + } elsif ($ARGV[1] eq 'A') { + $mode = 'A'; + $conv = 0; + # Binary + } elsif ($ARGV[1] eq 'B') { + $mode = 'B'; + $conv = 0; + # S + } elsif ($ARGV[1] eq 'S') { + $mode = 'S'; + $conv = 0; + } else { + die "Unknown mode for -m, must be T, I, A, B or S\n"; + } + shift; + shift; + # Convert (carriage return to linefeed) + } elsif ($ARGV[0] eq '-c') { + $conv = 0; + shift; + # Debug + } elsif ($ARGV[0] eq '-d') { + $debug = 1; + shift; + } +} + +my $dskfile = shift or die "Must supply .dsk filename\n"; +my $filename = shift or die "Must supply filename (local file system)\n"; +my $new_filename = shift or die "Must supply filename (on disk image)\n"; + +write_file($dskfile, $filename, $new_filename, $mode, $conv, $debug); + +1; +