aboutsummaryrefslogtreecommitdiff
path: root/scripts/sec2off.pl
blob: 6028cb050a626f774b1c475d4b58b5d37e9d718a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl --
# Given an audio sector number (based on alloc info of a song),
# this script converts that sector number to the byte offset on
# the drive where that sector number should be allocated.
# This is useful in combination with hd24hexview.
# Blocks per cluster must be looked up in the superblock of the drive;
# it varies depending on drive capacity.
my $blockspercluster=5;
my $sectorsperblock=0x480;
my $firstaudiosec=0x1397f6;
my $usagetablestart=0xa00;
my $audiosec=hex($ARGV[0]);
my $bitsperbyte=8;

my $offs=($audiosec-$firstaudiosec)/0x480/$blockspercluster/$bitsperbyte+$usagetablestart;

print sprintf("%x",$offs)."\n";