aboutsummaryrefslogtreecommitdiff
path: root/newtitle.pl
blob: a5cf2d2f247f630ac4f4887c72d72ddda83da55c (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl -w

use bytes;
use Image::Magick;
use Data::Dumper;
my $img = new Image::Magick;
$img->read("newtitle.png");
@pixels = $img->GetPixels(
		width     => 256,
		height    => 184,
		x         => 0,
		y         => 0,
		map       => 'G',
);
#print Dumper \@pixels;
#print "got " . @pixels . " pixels\n";

for $y (0..183) {
	for $b (0..31) {
		my $byte = 0;
		for($x = 0; $x < 8; $x++) {
			$byte <<= 1;
			$byte |= ($pixels[$y * 256 + $b * 8 + $x] > 0);
		}
		push @bytes, $byte;
	}
}

# we got over 4K of data, so the display list will have to
# have an LMS for the 2nd half. Since we're using narrow
# playfield mode, we don't have to leave a hole in the data,
# just make sure it gets loaded to an address aligned to a
# 32-byte boundary. It's getting loaded at $9000 so it can
# stay in memory while the rest of the game loads.
$load = 0x9000;
$len = scalar @bytes;
$end = $load + $len - 1;
print chr(0xff), chr(0xff);
print chr($load % 256);
print chr(int($load / 256));
print chr($end % 256);
print chr(int($end / 256));
print chr($_) for @bytes;


#print scalar @bytes;

#for $y (0..183) {
#	for $b (0..31) {
#		my $data = sprintf "%08b", $bytes[$y * 32 + $b];
#		$data =~ s,0, ,g;
#		$data =~ s,1,X,g;
#		print $data;
#	}
#	print "\n";
#}

# we might try a crude form of RLE, but not right now
#$run = 0;
#for(@bytes) {
#	if($_ == 0) {
#		$run++;
#	} else {
#		if($run > 1) {
#			print "run of $run 0 bytes\n";
#			$total += $run;
#		}
#		$run = 0;
#	}
#}
#
#print "total $total\n";