aboutsummaryrefslogtreecommitdiff
path: root/scripts/sl2o.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/sl2o.pl')
-rwxr-xr-xscripts/sl2o.pl23
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/sl2o.pl b/scripts/sl2o.pl
new file mode 100755
index 0000000..6047816
--- /dev/null
+++ b/scripts/sl2o.pl
@@ -0,0 +1,23 @@
1#!/usr/bin/perl --
2# sl2o -> converts Sectornumber and Length to Offset
3# Given a sector number and block count (as mentioned in an allocation
4# entry of a song), this little script tries to calculate which
5# range of byte offsets on the drive correspond with the usage
6# info of that allocation entry. This is useful in combination with
7# hd24hexview.
8# Blocks per cluster must be configured depending on the drive capacity.
9# Look up the correct number in the superblock of the drive.
10use POSIX floor;
11my $sectorsperblock=0x480;
12my $firstaudiosec=0x1397f6;
13my $usagetablestart=0xa00;
14my $blockspercluster=5;
15my $bitsperbyte=8;
16my $audiosec=hex($ARGV[0]);
17my $seclen=floor(hex($ARGV[1])/($blockspercluster*$bitsperbyte));
18
19
20my $offs=($audiosec-$firstaudiosec)/0x480/$blockspercluster/$bitsperbyte+$usagetablestart;
21
22print sprintf("%x",$offs)."-";
23print sprintf("%x",$offs+$seclen)."\n";