diff options
Diffstat (limited to 'scripts/sec2off.pl')
-rwxr-xr-x | scripts/sec2off.pl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/sec2off.pl b/scripts/sec2off.pl new file mode 100755 index 0000000..6028cb0 --- /dev/null +++ b/scripts/sec2off.pl | |||
@@ -0,0 +1,17 @@ | |||
1 | #!/usr/bin/perl -- | ||
2 | # Given an audio sector number (based on alloc info of a song), | ||
3 | # this script converts that sector number to the byte offset on | ||
4 | # the drive where that sector number should be allocated. | ||
5 | # This is useful in combination with hd24hexview. | ||
6 | # Blocks per cluster must be looked up in the superblock of the drive; | ||
7 | # it varies depending on drive capacity. | ||
8 | my $blockspercluster=5; | ||
9 | my $sectorsperblock=0x480; | ||
10 | my $firstaudiosec=0x1397f6; | ||
11 | my $usagetablestart=0xa00; | ||
12 | my $audiosec=hex($ARGV[0]); | ||
13 | my $bitsperbyte=8; | ||
14 | |||
15 | my $offs=($audiosec-$firstaudiosec)/0x480/$blockspercluster/$bitsperbyte+$usagetablestart; | ||
16 | |||
17 | print sprintf("%x",$offs)."\n"; | ||