aboutsummaryrefslogtreecommitdiff
path: root/dumpgr.pl
blob: c382c510d0d61eceb4e618476c6a23ca1f77b199 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl -w

use bytes;

# dump rom as 4-color bitmap, each byte is 4 pixels wide
$startaddr = 0x8000;
#@chars = (" ", "X", "o", ".");
@chars = ("\x1b[30;40m ", "\x1b[30;42m ", "\x1b[30;41m ", "\x1b[30;47m ");

$start = hex(shift) || 0xa8b3;
$end = hex(shift) || 0xaa72;
@ARGV="defender.rom" unless @ARGV;

undef $/;
$data = <>;
@bytes = split "", $data;

for($addr = $start; $addr < $end; $addr += 2) {
	my $str = "";
	my $pos = $addr - $startaddr;
	my $word = ord($bytes[$pos + 1]) + 256 * ord($bytes[$pos]);
	my $tmp = $word;
	for(my $i = 0; $i < 8; $i++) {
		my $pixel = $tmp & 3;
		$str = $chars[$pixel] . $str;
		$str = $chars[$pixel] . $str;
		$tmp >>= 2;
	}
	$str .= "\x1b[0m";
	if($addr >= $start && $addr <= $end) {
		printf "%04x: %04x   |%s|\n", $addr, $word, $str;
		$count++;
		print ("\n"), $count = 0 if $count == 8;
	}
}