aboutsummaryrefslogtreecommitdiff
path: root/scripts/sec2off.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/sec2off.pl')
-rwxr-xr-xscripts/sec2off.pl17
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.
8my $blockspercluster=5;
9my $sectorsperblock=0x480;
10my $firstaudiosec=0x1397f6;
11my $usagetablestart=0xa00;
12my $audiosec=hex($ARGV[0]);
13my $bitsperbyte=8;
14
15my $offs=($audiosec-$firstaudiosec)/0x480/$blockspercluster/$bitsperbyte+$usagetablestart;
16
17print sprintf("%x",$offs)."\n";