-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsplit_dsd.pl
executable file
·51 lines (41 loc) · 1.26 KB
/
split_dsd.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl -w
use strict;
# Beeb Utilities to manipulate MMB and SSD files
# Copyright (C) 2012 Stephen Harris
#
# See file "COPYING" for GPLv2 licensing
use FindBin;
use lib "$FindBin::Bin";
use BeebUtils;
my $concat=0;
if (@ARGV && $ARGV[0] eq '-concat') { $concat=1; shift @ARGV; }
@ARGV=BeebUtils::init_ssd(@ARGV);
my $src=$BeebUtils::BBC_FILE;
my ($dest1,$dest2)=@ARGV;
die "Syntax: $BeebUtils::PROG [-concat] src.dsd side0.ssd side2.ssd\n" unless $dest2;
die "$dest1 already exists\n" if -e $dest1;
die "$dest2 already exists\n" if -e $dest2;
my $SIZE=256*10; # 10 sectors per track
my $src_image=BeebUtils::load_external_ssd(undef,0);
# Ensure the disk is big enough; crummy non-dsd DSD images!
$src_image .= "\0" x ($SIZE*80*2);
my ($disk1,$disk2);
# In concat mode the first 200K is for disk1, the second is for disk2
# Otherwise we're interleaved at the track level
if ($concat)
{
$disk1 = substr($src_image,0,$SIZE*80);
$disk2 = substr($src_image,$SIZE*80,$SIZE*80);
}
else
{
foreach my $track (0..79)
{
my $offset=$track*$SIZE*2; # interleaved
$disk1 .= substr($src_image,$offset,$SIZE);
$disk2 .= substr($src_image,$offset+$SIZE,$SIZE);
}
}
BeebUtils::write_ssd(\$disk1,$dest1);
BeebUtils::write_ssd(\$disk2,$dest2);
print "Disks created\n";