-
Notifications
You must be signed in to change notification settings - Fork 10
/
memoryRangeBasis108.go
73 lines (61 loc) · 1.63 KB
/
memoryRangeBasis108.go
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
package izapple2
/*
The Basis 108 clone has 128kb of RAM plus 2KB of static RAM at $0400 for 80 columns text.
*/
type memoryRangeBasis108 struct {
dataMain []uint8
dataAux []uint8
dataStatic []uint8
name string
staticRam bool
auxRam bool
}
func newMemoryRangeBasis108() *memoryRangeBasis108 {
var m memoryRangeBasis108
m.dataMain = make([]uint8, 48*1024)
m.dataAux = make([]uint8, 48*1024)
m.dataStatic = make([]uint8, 0xc000-0x0400)
// How is the static RAM initialized?
for i := 0; i < len(m.dataStatic); i++ {
m.dataStatic[i] = ' ' + 0x80
}
m.name = "Basis 108 RAM"
return &m
}
func (m *memoryRangeBasis108) peek(address uint16) uint8 {
if m.staticRam && address >= 0x0400 && address < 0x0c00 {
return m.dataStatic[address-0x0400]
}
if m.auxRam {
return m.dataAux[address]
}
return m.dataMain[address]
}
func (m *memoryRangeBasis108) poke(address uint16, value uint8) {
if m.staticRam && address >= 0x0400 && address < 0x0c00 {
m.dataStatic[address-0x0400] = value
} else if m.auxRam {
m.dataAux[address] = value
} else {
m.dataMain[address] = value
}
}
func (m *memoryRangeBasis108) subRange(a, b uint16) []uint8 {
if m.staticRam && a >= 0x0400 && b < 0x0c00 {
return m.dataStatic[a-0x0400 : b-0x0400]
}
if m.auxRam {
return m.dataAux[a:b]
}
return m.dataMain[a:b]
}
func (m *memoryRangeBasis108) getTextMemory(secondPage bool, ext bool) []uint8 {
addressStart := textPage1Address
if secondPage {
addressStart = textPage2Address
}
if ext {
return m.dataStatic[addressStart-0x0400 : addressStart-0x0400+textPageSize]
}
return m.dataMain[addressStart : addressStart+textPageSize]
}