diff options
Diffstat (limited to 'scripts/off2sec.pl')
-rwxr-xr-x | scripts/off2sec.pl | 19 |
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. | ||
10 | my $blockspercluster=5; | ||
11 | my $sectorsperblock=0x480; | ||
12 | my $firstaudiosec=0x1397f6; | ||
13 | my $usagetablestart=0xa00; | ||
14 | my $recordingoffset=hex($ARGV[0]); | ||
15 | my $bitsperbyte=8; | ||
16 | my $startcluster=$recordingoffset-$usagetablestart; | ||
17 | my $audiosec=$firstaudiosec+($sectorsperblock*$blockspercluster*$bitsperbyte*$startcluster); | ||
18 | |||
19 | print sprintf("%x",$audiosec)."\n"; | ||