a2d/res/make_info.pl

71 lines
1.6 KiB
Perl
Raw Normal View History

#!/usr/bin/env perl
use strict;
use warnings;
2018-12-02 00:11:25 +00:00
my $org = $ARGV[0] || '2000';
2017-09-17 18:18:47 +00:00
print <<"END_HEADER";
GLOBAL {
2017-09-17 18:18:47 +00:00
STARTADDR \$$org;
PAGELENGTH 0; # No paging
CPU "6502";
};
2017-09-17 18:18:47 +00:00
END_HEADER
print <<'END_LABELS';
LABEL { NAME "RAMRDOFF"; ADDR $C002; };
LABEL { NAME "RAMRDON"; ADDR $C003; };
LABEL { NAME "RAMWRTOFF"; ADDR $C004; };
LABEL { NAME "RAMWRTON"; ADDR $C005; };
LABEL { NAME "ALTZPOFF"; ADDR $C008; };
LABEL { NAME "ALTZPON"; ADDR $C009; };
LABEL { NAME "LCBANK1"; ADDR $C08B; };
LABEL { NAME "AUXMOVE"; ADDR $C311; };
LABEL { NAME "XFER"; ADDR $C314; };
LABEL { NAME "A2D"; ADDR $4000; };
LABEL { NAME "UNKNOWN_CALL"; ADDR $8E00; };
LABEL { NAME "MLI"; ADDR $BF00; };
2017-09-17 18:18:47 +00:00
END_LABELS
2017-09-17 18:18:47 +00:00
print <<'END_SEGS';
2018-12-02 00:11:25 +00:00
#RANGE { START $8800; END $939E; TYPE ByteTable; };
#RANGE { START $DA20; END $DAFF; TYPE ByteTable; };
#RANGE { START $E690; END $E6BF; TYPE ByteTable; };
#RANGE { START $FB00; END $FFFF; TYPE ByteTable; };
2017-09-17 18:18:47 +00:00
END_SEGS
2017-09-17 18:18:47 +00:00
my $ptr = hex($org);
my @last = (-1, -1, -1);
my $b;
while (read(STDIN, $b, 1)) {
$b = ord($b);
#print sprintf("%04x: \$%02x\n", $ptr, $b);
++$ptr;
shift @last;
push @last, $b;
my $lastaddr = $last[1] | ($last[2] << 8);
if ($last[0] == 0x20 &&
($lastaddr == 0x4000 || $lastaddr == 0x8E00 || $lastaddr == 0xBF00)) {
die "expected 3 more\n" unless read(STDIN, $b, 3) == 3;
print sprintf(
"RANGE { START \$%04x; END \$%04x; TYPE ByteTable; };\n" .
"RANGE { START \$%04x; END \$%04x; TYPE AddrTable; };\n",
$ptr, $ptr, $ptr+1, $ptr+2
);
$ptr += 3;
next;
}
}