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