aboutsummaryrefslogtreecommitdiffstats
path: root/data/mmuinit.pl
blob: fb041182b0f1595daa448665264bc36e327bcaf1 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/perl
#
# Create MMU initialization file
#

# Each MMU entry is 16 bits; there are 4 address maps total.
# These are initialized with a 2K video RAM window at 30-32K.
# The defaults match the map uses from Mikrodatorn's 64K RAM
# expansion:
#
# Map 0: default (32K RAM)
# Map 1: 0-30K is RAM
# Map 2: 0-62K RAM; 62-64K video
# Map 3: 0-64K RAM, no video
#
# The format of each entry is as follows:
# Bit  [15] -> Apply BASIC "patch" for 80 characters?
# Bits [14:12] -> device index:
#                 0 - SRAM
#                 1 - Flash ROM
#                 2 - Video RAM
#                 3 - Character generator RAM
#                 4 - Block graphics RAM
#                 5 - Reserved
#		  6 - Reserved
#                 7 - Hyperspace (reads bits[7:0], writes nowhere)
#
# Bits [11:0] -> A[19:8]
#

$testram = 0;
$with_bgram = 1;

sub do_ram() {
    if ( $testram ) {
	# Tiny amount of RAM (4K)
	for ( ; $i < 0xF0 ; $i++ ) {
	    printf("%03X : %04X;\n", $a++, 0x70FF);
	}
	for ( $i = 0xF0 ; $i < 0x100 ; $i++ ) {
	    printf("%03X : %04X;\n", $a++, 0x0000|$i);
	}
    } else {
	for ( ; $i < 0x100 ; $i++ ) {
	    # Important: No offset for this index
	    printf("%03X : %04X;\n", $a++, 0x0000|$i);
	}
    }
}

print "DEPTH = 1024;\n";
print "WIDTH = 16;\n";
print "ADDRESS_RADIX = HEX;\n";
print "DATA_RADIX    = HEX;\n";
print "CONTENT\n";
print "BEGIN\n";

$a = 0;

# Map 0 (standard)
for ( $i = 0x00 ; $i < 0x40 ; $i++ ) { # BASIC
    printf("%03X : %04X;\n", $a++, 0x9000|$i);
}
for ( $i = 0x40 ; $i < 0x48 ; $i++ ) { # Free for expansion
    printf("%03X : %04X;\n", $a++, 0x70FF);
}
for ( $i = 0x48 ; $i < 0x60 ; $i++ ) { # Free for expansion or bgram
    printf("%03X : %04X;\n", $a++, $with_bgram ? 0x4000|($i-0x48) : 0x70FF);
}
for ( $i = 0x60 ; $i < 0x74 ; $i++ ) { # DOS, IEC options
    printf("%03X : %04X;\n", $a++, 0x1000|$i);
}
for ( $i = 0x74 ; $i < 0x78 ; $i++ ) { # Video RAM (for 80 col only)
    printf("%03X : %04X;\n", $a++, 0x2000|($i-0x74));
}
for ( $i = 0x78 ; $i < 0x7B ; $i++ ) { # PR option
    printf("%03X : %04X;\n", $a++, 0x1000|$i);
}
for ( $i = 0x7B ; $i < 0x7C ; $i++ ) { # RAM in the PR option area
    printf("%03X : %04X;\n", $a++, 0x0000|$i);
}
for ( $i = 0x7C ; $i < 0x80 ; $i++ ) { # Video RAM
    printf("%03X : %04X;\n", $a++, 0x2004|($i-0x7C));
}
do_ram();

# Map 1 (standard layout in RAM)
for ( $i = 0x00 ; $i < 0x40 ; $i++ ) { # BASIC (in RAM)
    printf("%03X : %04X;\n", $a++, 0x8000|$i);
}
for ( $i = 0x40 ; $i < 0x48 ; $i++ ) { # Expansion (fill with RAM)
    printf("%03X : %04X;\n", $a++, 0x0000|$i);
}
for ( $i = 0x48 ; $i < 0x60 ; $i++ ) { # RAM or bgram
    printf("%03X : %04X;\n", $a++, $with_bgram ? 0x4000|($i-0x48) : 0x0000|$i);
}
for ( $i = 0x60 ; $i < 0x74 ; $i++ ) { # DOS and IEC (in RAM)
    printf("%03X : %04X;\n", $a++, 0x0000|$i);
}
for ( $i = 0x74 ; $i < 0x78 ; $i++ ) { # Video RAM (for 80 col only)
    printf("%03X : %04X;\n", $a++, 0x2000|($i-0x74));
}
for ( $i = 0x78 ; $i < 0x7C ; $i++ ) { # PR option (in RAM)
    printf("%03X : %04X;\n", $a++, 0x0000|$i);
}
for ( $i = 0x7C ; $i < 0x80 ; $i++ ) { # Video RAM
    printf("%03X : %04X;\n", $a++, 0x2004|($i-0x7C));
}
do_ram();

# Map 2 (CP/M with video enabled)
for ( $i = 0x00 ; $i < 0xF8 ; $i++ ) { # RAM
    printf("%03X : %04X;\n", $a++, 0x0000|$i);
}
for ( $i = 0xF8 ; $i < 0x100 ; $i++ ) {	# Video RAM
    printf("%03X : %04X;\n", $a++, 0x2000|($i-0xF8));
}

# Map 3 (CP/M all memory)
for ( $i = 0x00 ; $i < 0x100 ; $i++ ) { # All RAM
    printf("%03X : %04X;\n", $a++, 0x0000|$i);
}

print "END;\n";