aboutsummaryrefslogtreecommitdiffstats
path: root/data/ufdpatch.pl
blob: 7f69160ad04f7e7b9311e1a3255b7381f532cca3 (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
#!/usr/bin/perl
#
# Patch the UFD-DOS binary
#
# Patches cribbed from ufdpatch.ny by:
# Bert Holgersson <560>    1988-02-03 20.26.03 (DUMP)
#

use bytes;

@patches = (
	    # Ctrl-C fix
	    [0x6851, 0xcd, 0x9b, 0x6f],
	    [0x6f9b, 0xcd, 0x3e, 0x03, 0xe9]
	    );

$org = 0x6000;
$len = 4096;

($in, $out) = @ARGV;

open(IN, '<', $in) or die "$0: cannot open $in: $!\n";

if (read(IN, $rom, $len) != $len) {
    die "$0: input file $in has the wrong length\n";
}
close(IN);

foreach $patch (@patches) {
    @p = @$patch;
    $a = shift @p;
    foreach $b (@p) {
	substr($rom, $a-$org, 1) = chr($b);
	$a++;
    }
}

open(OUT, '>', $out) or die "$0: cannot open $out: $!\n";
print OUT $rom;
close(OUT);