Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use Getopt::Long;
- our ($input);
- my ($p, $b, $w, $l, $s, $total, $tmp_name);
- $input='bank.bnk';
- GetOptions('input=s' => \$input);
- # リスト処理
- unless(-e $input)
- {
- print STDERR "\"$input\" not found.\n";
- exit(-1);
- }
- open(BNK, "<$input") || die "file open error: $!";
- binmode(BNK);
- $total = 0;
- for my $i (0x00..0x3f)
- {
- $p = $i<<2;
- $s = 0;
- seek(BNK, 12+$p, 0); # dirテーブルへ移動
- read(BNK, $b, 2);
- $w = unpack("S", $b);
- read(BNK, $b, 2);
- $l = unpack("S", $b);
- unless($w==0)
- {
- while(1)
- {
- seek(BNK, $w-0x7ff4+$s, 0);
- read(BNK, $b, 1);
- $s += 9;
- if( (unpack("C", $b) & 1) == 1){last;}
- }
- $total += $s;
- printf "%02x:: start:0x%04x - loop:0x%04x - size:0x%04x\n", $i, $w, $l, $s;
- $tmp_name = sprintf("%2x.brr",$i);
- open(BRR, ">$tmp_name"); binmode(BRR);
- seek(BNK,$w-0x7ff4,0); read(BNK, $b, $s);
- print BRR pack("S", $l-$w);
- print BRR $b;
- close(BRR);
- }
- else
- {
- printf "%02x:: NULL\n", $i;
- }
- }
- printf "\n\nBank: 0x%04x / 0x7fee(%3f\%) space:0x%04x\n", $total, $total/0x7fee*100, 0x7fee-$total;
- close(BNK);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement