-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdmmb_info.pl
executable file
·89 lines (72 loc) · 2 KB
/
dmmb_info.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/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;
@ARGV=BeebUtils::init(@ARGV);
my $dest=$BeebUtils::BBC_FILE || 'BEEB.MMB';
die "$dest does not exists\n" unless -e $dest;
my $fh=new FileHandle "< $dest";
die "Can not open $dest for reading\n" unless $fh;
binmode($fh);
# How many extents do we have
sysseek($fh,8,0);
my $ext_byte;
sysread($fh,$ext_byte,1);
$ext_byte=ord($ext_byte);
$ext_byte=160 if $ext_byte==0;
if ($ext_byte < 160 || $ext_byte > 175)
{
die "Base MMB image has unexpected character indicating length\n We got $ext_byte but it should be 0 or between 160 and 175\n";
}
# Get the base value
my $base;
sysread($fh,$base,1);
$base=ord($base);
my ($disktable,%boot)=BeebUtils::load_onboot();
my %disk=BeebUtils::load_dcat(\$disktable);
my ($disktable2,%boot2)=BeebUtils::load_onboot($base);
my $form=0;
my $tot=0;
foreach (keys %disk)
{
$tot++;
$form++ unless $disk{$_}{Formatted};
}
print "MMB Filename: $dest\n" .
" Number of extents: " . ($ext_byte-159) . " (0->" . ($ext_byte-160) . ")\n" .
" Base extent: $base (image IDs will be offset by " . ($base*511) . ")\n" .
" Number of disks: $tot\n" .
" #Unformatted: $form\n" .
" Onboot disks:\n";
print " Extent 0: (MMB Base)\n" if $base;
foreach (0..3)
{
my $d=$boot{$_};
my $t="<empty>";
if ($disk{$d}{Formatted})
{
my $L=$disk{$d}{ReadOnly}?" (L)":"";
$t="$disk{$d}{DiskTitle}$L";
}
printf(" %s: %4d - %-12s\n",$_,$d,$t);
}
if ($base)
{
print "\n Extent $base: (Currently selected)\n" if $base;
foreach (0..3)
{
my $d=$boot2{$_};
my $t="<empty>";
if ($disk{$d+$base*511}{Formatted})
{
my $L=$disk{$d+$base*511}{ReadOnly}?" (L)":"";
$t="$disk{$d+$base*511}{DiskTitle}$L";
}
printf(" %s: %4d - %-12s\n",$_,$d,$t);
}
}