aboutsummaryrefslogtreecommitdiff
path: root/scripts/off2sec.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/off2sec.pl')
-rwxr-xr-xscripts/off2sec.pl19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/off2sec.pl b/scripts/off2sec.pl
new file mode 100755
index 0000000..0751be5
--- /dev/null
+++ b/scripts/off2sec.pl
@@ -0,0 +1,19 @@
1#!/usr/bin/perl --
2# Given an offset of a byte number on disk,
3# this little script converts the given offset to the sector number
4# where the audio starts that is allocated by the given byte in the
5# usage table.
6# It is assumed that the drive usage table starts on offset 0xa00
7# (sector 5).
8# The blocks per cluster must be looked up in the boot record of the
9# drive before using this script; it varies based on drive capacity.
10my $blockspercluster=5;
11my $sectorsperblock=0x480;
12my $firstaudiosec=0x1397f6;
13my $usagetablestart=0xa00;
14my $recordingoffset=hex($ARGV[0]);
15my $bitsperbyte=8;
16my $startcluster=$recordingoffset-$usagetablestart;
17my $audiosec=$firstaudiosec+($sectorsperblock*$blockspercluster*$bitsperbyte*$startcluster);
18
19print sprintf("%x",$audiosec)."\n";