aboutsummaryrefslogtreecommitdiff
path: root/mkdlatbl.pl
blob: a1377f64597a0da73ebe5533ef61e2b3f7582de5 (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
#!/usr/bin/perl -w

use POSIX 'round';
$PI = 3.14159265358979;

# bdeg means "binary degrees", 1/256 of a circle.
sub bdsin {
	return sin($_[0] / 128 * $PI);
}

sub bdcos {
	return cos($_[0] / 128 * $PI);
}

$centerx = 85;
$centery = 85;

for $r (15, 30, 45, 75) {
	push @xmin, $centerx - ($r + 10);
	push @xmax, $centerx + ($r + 10);
	push @ymin, $centery - ($r + 10);
	push @ymax, $centery + ($r + 10);
	for $angle (0..255) {
		my $x = round($centerx + $r * bdcos($angle));
		my $y = round($centery + $r * bdsin($angle));
		push @xpoints, $x;
		push @ypoints, $y;
	}
}

print <<EOF;
; data tables for dla.s
; generated file, do not edit.
; make changes in mkdlatbl.pl instead.

center_x = $centerx
center_y = $centery

EOF

print "xmin:\n";
for(@xmin) {
	print " .byte $_\n";
}

print "xmax:\n";
for(@xmax) {
	$_ = 169 if $_ >= 170;
	print " .byte $_\n";
}

print "ymin:\n";
for(@ymin) {
	print " .byte $_\n";
}

print "ymax:\n";
for(@ymax) {
	$_ = 169 if $_ >= 170;
	print " .byte $_\n";
}

print "points_x:\n";
for(@xpoints) {
	print " .byte $_\n";
}
print "points_y:\n";
for(@ypoints) {
	print " .byte $_\n";
}