Skip to content

Commit 4965acb

Browse files
committed
added mRAM cartridge type
1 parent 19d1d40 commit 4965acb

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

hardware/memory/external/fingerprint.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,25 @@ func FingerprintBlob(filename string, d []uint8, mapper string) (CartridgeInsert
166166
}, nil
167167
}
168168

169+
// mRAM chip in flat ROM cartridge (no bankswitching)
170+
//
171+
// it's not clear if the mRAM chip (with a masked address line) can be used in
172+
// conjunction with a bankswitching method. as it stands, I think only 'Rescue On
173+
// Fractalus' uses this type of RAM chip and that has a flat ROM map
174+
if cartType == 0x0080 {
175+
return CartridgeInsertor{
176+
data: d,
177+
creator: func(ctx Context, d []uint8) (Bus, error) {
178+
return NewMRAM(ctx, d[dataStart:])
179+
},
180+
Controller: controller,
181+
spec: spec,
182+
chips: chips,
183+
UseHSC: useHSC,
184+
UseSavekey: useSavekey,
185+
}, nil
186+
}
187+
169188
// activision
170189
if cartType == 0x0100 {
171190
// if cartridge name contians the '(OM)' string then the cartridge has been dumped

hardware/memory/external/mram.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package external
2+
3+
// MRAM is created when bit 0x0080 of the a78 cartridge type field is on. Example ROM is the
4+
// prototype of Rescue on Fractalus. The name mRAM comes from the A7800 rom.cpp file which describes
5+
// this type of cartridge as "no bankswitch + mRAM chip"
6+
type MRAM struct {
7+
data []byte
8+
origin uint16
9+
ram []byte
10+
}
11+
12+
func NewMRAM(_ Context, d []byte) (*MRAM, error) {
13+
return &MRAM{
14+
data: d,
15+
origin: uint16(0x10000 - len(d)),
16+
ram: make([]byte, 0x4000),
17+
}, nil
18+
}
19+
20+
func (ext *MRAM) Label() string {
21+
return "mRAM"
22+
}
23+
24+
func (ext *MRAM) Access(write bool, address uint16, data uint8) (uint8, error) {
25+
if address < 0x4000 {
26+
return 0, nil
27+
}
28+
29+
if address < 0x8000 {
30+
address &= 0xfeff
31+
if write {
32+
ext.ram[address-0x4000] = data
33+
return 0, nil
34+
}
35+
return ext.ram[address-0x4000], nil
36+
}
37+
38+
if address < ext.origin {
39+
return 0, nil
40+
}
41+
return ext.data[address-ext.origin], nil
42+
}

0 commit comments

Comments
 (0)