-
Notifications
You must be signed in to change notification settings - Fork 9
/
cardProDOSRomDrive.go
73 lines (59 loc) · 1.86 KB
/
cardProDOSRomDrive.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
import "fmt"
/*
Terence Boldt's ProDOS-ROM-Drive: A bootable 1 MB solid state disk for Apple ][ computers
Emulates version 4.0+
See:
https://github.com/tjboldt/ProDOS-ROM-Drive
https://github.com/Alex-Kw/ProDOS-ROM-Drive-Images
*/
// CardMemoryExpansion is a Memory Expansion card
type CardProDOSRomDrive struct {
cardBase
address uint16
data []uint8
}
const proDOSRomDriveMask = 0xf_ffff // 1 MB mask
func newCardProDOSRomDriveBuilder() *cardBuilder {
return &cardBuilder{
name: "ProDOS ROM Drive",
description: "A bootable 1 MB solid state disk by Terence Boldt",
defaultParams: &[]paramSpec{
// {"image", "ROM image with the ProDOS volume", "https://github.com/tjboldt/ProDOS-ROM-Drive/raw/v4.0/Firmware/GamesWithFirmware.po"},
{"image", "ROM image with the ProDOS volume", "https://github.com/Alex-Kw/ProDOS-ROM-Drive-Images/raw/main/ProDOS_2.4.3_TJ.po"},
},
buildFunc: func(params map[string]string) (Card, error) {
image := paramsGetPath(params, "image")
if image == "" {
return nil, fmt.Errorf("image required for the ProDOS ROM drive")
}
data, _, err := LoadResource(image)
if err != nil {
return nil, err
}
var c CardProDOSRomDrive
c.data = data
c.loadRom(data[0x300:0x400], cardRomSimple)
return &c, nil
},
}
}
func (c *CardProDOSRomDrive) assign(a *Apple2, slot int) {
// Set pointer position
c.addCardSoftSwitchW(0, func(value uint8) {
c.address = uint16(value) | c.address&0xff00
}, "LATCHLO")
c.addCardSoftSwitchW(1, func(value uint8) {
c.address = uint16(value)<<8 | c.address&0xff
}, "LATCHHI")
// Read data
for i := uint8(0x0); i <= 0xf; i++ {
iCopy := i
c.addCardSoftSwitchR(iCopy, func() uint8 {
offset := uint32(c.address)<<4 + uint32(iCopy)
offset &= proDOSRomDriveMask
return c.data[offset]
}, fmt.Sprintf("READ%X", iCopy))
}
c.cardBase.assign(a, slot)
}