-
Notifications
You must be signed in to change notification settings - Fork 4
/
merge_dsd.pl
executable file
·49 lines (39 loc) · 1.21 KB
/
merge_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
#!/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 $src0=$BeebUtils::BBC_FILE;
my ($src2,$dest)=@ARGV;
die "Syntax: $BeebUtils::PROG [-concat] side0.ssd side2.ssd merged_disk.dsd\n" unless $dest;
die "$dest already exists\n" if -e $dest;
my $SIZE=256*10; # 10 sectors per track
my $src0_image=BeebUtils::load_external_ssd($src0,0);
my $src2_image=BeebUtils::load_external_ssd($src2,0);
# Ensure the disks are big enough; crummy non-ssd SSD images!
$src0_image .= "\0" x ($SIZE*80*2);
$src2_image .= "\0" x ($SIZE*80*2);
my $dest_image="";
# In concat mode, just append, otherwise interleave at the track level
if ($concat)
{
$dest_image = substr($src0_image,0,$SIZE*80) . substr($src2_image,0,$SIZE*80);
}
else
{
foreach my $track (0..79)
{
my $offset=$track*$SIZE;
$dest_image .= substr($src0_image,$offset,$SIZE);
$dest_image .= substr($src2_image,$offset,$SIZE);
}
}
BeebUtils::write_ssd(\$dest_image,$dest);
print "Disks merged\n";