diff options
Diffstat (limited to 'scripts/genbackupscript.pl')
-rwxr-xr-x | scripts/genbackupscript.pl | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/scripts/genbackupscript.pl b/scripts/genbackupscript.pl new file mode 100755 index 0000000..9546c56 --- /dev/null +++ b/scripts/genbackupscript.pl | |||
@@ -0,0 +1,98 @@ | |||
1 | #!/usr/bin/perl -- | ||
2 | |||
3 | sub dec2hex { | ||
4 | # parameter passed to | ||
5 | # the subfunction | ||
6 | my $decnum = $_[0]; | ||
7 | if ($decnum==0) { | ||
8 | return "0"; | ||
9 | } | ||
10 | # the final hex number | ||
11 | my $hexnum; | ||
12 | my $tempval; | ||
13 | while ($decnum != 0) { | ||
14 | # get the remainder (modulus function) | ||
15 | # by dividing by 16 | ||
16 | $tempval = $decnum % 16; | ||
17 | # convert to the appropriate letter | ||
18 | # if the value is greater than 9 | ||
19 | if ($tempval > 9) { | ||
20 | $tempval = chr($tempval + 55); | ||
21 | } | ||
22 | # 'concatenate' the number to | ||
23 | # what we have so far in what will | ||
24 | # be the final variable | ||
25 | $hexnum = $tempval . $hexnum ; | ||
26 | # new actually divide by 16, and | ||
27 | # keep the integer value of the | ||
28 | # answer | ||
29 | $decnum = int($decnum / 16); | ||
30 | # if we cant divide by 16, this is the | ||
31 | # last step | ||
32 | if ($decnum < 16) { | ||
33 | # convert to letters again.. | ||
34 | if ($decnum > 9) { | ||
35 | $decnum = chr($decnum + 55); | ||
36 | } | ||
37 | |||
38 | # add this onto the final answer.. | ||
39 | # reset decnum variable to zero so loop | ||
40 | # will exit | ||
41 | $hexnum = $decnum . $hexnum; | ||
42 | $decnum = 0 | ||
43 | } | ||
44 | } | ||
45 | return $hexnum; | ||
46 | } # end sub | ||
47 | |||
48 | sub writebackupblock ($$$$) { | ||
49 | my $i; | ||
50 | my $sector=shift; | ||
51 | my $blocksize=shift; | ||
52 | my $currentcount=shift; | ||
53 | my $remark=shift; | ||
54 | print "-0 ".$remark." ".$currentcount."\n"; | ||
55 | for ($i=1;$i<=$blocksize;$i++) { | ||
56 | print "d".dec2hex($sector+$i-1)."\n"; | ||
57 | print "bb\nbe\n"; | ||
58 | print "d-".dec2hex($sector+1+$blocksize-$i)."\n"; | ||
59 | print "p\nws\n"; | ||
60 | } | ||
61 | } | ||
62 | $sector=0; | ||
63 | $blocksize=1; | ||
64 | $count=1; | ||
65 | writebackupblock($sector,$blocksize,$count,"Backup superblock"); | ||
66 | |||
67 | $sector+=$blocksize*$count; | ||
68 | $blocksize=1; | ||
69 | $count=1; | ||
70 | writebackupblock ($sector,$blocksize,$count,"Backup Drive info"); | ||
71 | |||
72 | $sector+=$blocksize*$count; | ||
73 | $blocksize=3; | ||
74 | $count=1; | ||
75 | writebackupblock ($sector,$blocksize,$count,"Backup undo (?) usage"); | ||
76 | |||
77 | $sector+=$blocksize*$count; | ||
78 | $blocksize=15; | ||
79 | $count=1; | ||
80 | writebackupblock ($sector,$blocksize,$count,"Backup drive usage table"); | ||
81 | |||
82 | $sector+=$blocksize*$count; | ||
83 | $blocksize=1; | ||
84 | $count=99; | ||
85 | for ($i=1;$i<=$count;$i++) { | ||
86 | writebackupblock ($sector+$i-1,$blocksize,$i,"Backup project "); | ||
87 | } | ||
88 | |||
89 | $sector+=$blocksize*$count; | ||
90 | $count=99; | ||
91 | for ($i=1;$i<=$count;$i++) { | ||
92 | $blocksize=2; | ||
93 | writebackupblock ($sector+(7*($i-1)),$blocksize,$i,"Backup song "); | ||
94 | $blocksize=5; | ||
95 | writebackupblock ($sector+(7*($i-1))+2,$blocksize,$i,"Backup song alloc info "); | ||
96 | } | ||
97 | print "q\n"; | ||
98 | |||