2019-02-23 23:41:32 +00:00
|
|
|
package apple2
|
|
|
|
|
2019-10-20 22:00:42 +00:00
|
|
|
/*
|
|
|
|
See:
|
|
|
|
https://www.apple.asimov.net/documentation/hardware/machines/APPLE%20IIe%20Auxiliary%20Memory%20Softswitches.pdf
|
|
|
|
*/
|
|
|
|
|
2019-02-23 23:41:32 +00:00
|
|
|
const (
|
2019-10-20 22:00:42 +00:00
|
|
|
ioFlagRamRd uint8 = 0x13
|
|
|
|
ioFlagRamWrt uint8 = 0x14
|
2019-02-23 23:41:32 +00:00
|
|
|
ioFlagIntCxRom uint8 = 0x15
|
2019-10-20 22:00:42 +00:00
|
|
|
ioFlagAltZp uint8 = 0x16
|
2019-02-23 23:41:32 +00:00
|
|
|
ioFlagSlotC3Rom uint8 = 0x17
|
2019-02-24 13:37:10 +00:00
|
|
|
ioFlag80Store uint8 = 0x18
|
2019-10-20 22:00:42 +00:00
|
|
|
ioFlagAltChar uint8 = 0x1E
|
2019-02-24 13:37:10 +00:00
|
|
|
ioFlag80Col uint8 = 0x1F
|
2019-10-20 22:00:42 +00:00
|
|
|
// ??? ioVertBlank uin8 = 0x19
|
2019-02-23 23:41:32 +00:00
|
|
|
)
|
|
|
|
|
2019-02-24 14:05:50 +00:00
|
|
|
func addApple2ESoftSwitches(io *ioC0Page) {
|
2019-10-12 19:37:37 +00:00
|
|
|
// New MMU read softswithes
|
2019-10-20 22:00:42 +00:00
|
|
|
io.addSoftSwitchW(0x02, getSoftSwitchExt(ioFlagRamRd, ssOff, nil), "RAMRDOFF")
|
|
|
|
io.addSoftSwitchW(0x03, getSoftSwitchExt(ioFlagRamWrt, ssOn, nil), "RAMRDON")
|
|
|
|
io.addSoftSwitchR(0x13, getStatusSoftSwitch(ioFlagRamWrt), "RAMRD")
|
|
|
|
|
|
|
|
io.addSoftSwitchW(0x04, getSoftSwitchExt(ioFlagRamWrt, ssOff, nil), "RAMWRTOFF")
|
|
|
|
io.addSoftSwitchW(0x05, getSoftSwitchExt(ioFlagRamWrt, ssOn, nil), "RAMWRTON")
|
|
|
|
io.addSoftSwitchR(0x14, getStatusSoftSwitch(ioFlagRamWrt), "RAMWRT")
|
|
|
|
|
|
|
|
io.addSoftSwitchW(0x06, getSoftSwitchExt(ioFlagIntCxRom, ssOff, softSwitchIntCxRomOff), "INTCXROMOFF")
|
|
|
|
io.addSoftSwitchW(0x07, getSoftSwitchExt(ioFlagIntCxRom, ssOn, softSwitchIntCxRomOn), "INTCXROMON")
|
|
|
|
io.addSoftSwitchR(0x15, getStatusSoftSwitch(ioFlagIntCxRom), "INTCXROM")
|
|
|
|
|
|
|
|
io.addSoftSwitchW(0x08, getSoftSwitchExt(ioFlagAltZp, ssOff, nil), "ALTZPOFF")
|
|
|
|
io.addSoftSwitchW(0x09, getSoftSwitchExt(ioFlagAltZp, ssOn, nil), "ALTZPON")
|
|
|
|
io.addSoftSwitchR(0x16, getStatusSoftSwitch(ioFlagAltZp), "ALTZP")
|
|
|
|
|
|
|
|
io.addSoftSwitchW(0x0A, getSoftSwitchExt(ioFlagSlotC3Rom, ssOff, softSwitchSlotC3RomOff), "SLOTC3ROMOFF")
|
|
|
|
io.addSoftSwitchW(0x0B, getSoftSwitchExt(ioFlagSlotC3Rom, ssOn, softSwitchSlotC3RomOn), "SLOTC3ROMON")
|
|
|
|
io.addSoftSwitchR(0x17, getStatusSoftSwitch(ioFlagSlotC3Rom), "SLOTC3ROM")
|
2019-10-12 19:37:37 +00:00
|
|
|
|
|
|
|
// Previous read softswithes
|
2019-10-20 22:00:42 +00:00
|
|
|
io.addSoftSwitchR(0x1A, getStatusSoftSwitch(ioFlagText), "TEXT")
|
|
|
|
io.addSoftSwitchR(0x1B, getStatusSoftSwitch(ioFlagMixed), "MIXED")
|
|
|
|
io.addSoftSwitchR(0x1C, getStatusSoftSwitch(ioFlagSecondPage), "PAGE2")
|
|
|
|
io.addSoftSwitchR(0x1D, getStatusSoftSwitch(ioFlagHiRes), "HIRES")
|
2019-10-12 19:37:37 +00:00
|
|
|
|
|
|
|
// New IOU read softswithes
|
2019-10-20 22:00:42 +00:00
|
|
|
io.addSoftSwitchW(0x00, getSoftSwitchExt(ioFlag80Store, ssOff, nil), "80STOREOFF")
|
|
|
|
io.addSoftSwitchW(0x01, getSoftSwitchExt(ioFlag80Store, ssOn, nil), "80STOREON")
|
|
|
|
io.addSoftSwitchR(0x18, getStatusSoftSwitch(ioFlag80Store), "80STORE")
|
|
|
|
|
|
|
|
io.addSoftSwitchW(0x0C, getSoftSwitchExt(ioFlag80Col, ssOff, nil), "80COLOFF")
|
|
|
|
io.addSoftSwitchW(0x0D, getSoftSwitchExt(ioFlag80Col, ssOn, nil), "80COLON")
|
|
|
|
io.addSoftSwitchR(0x1F, getStatusSoftSwitch(ioFlag80Col), "80COL")
|
|
|
|
|
|
|
|
io.addSoftSwitchW(0x0E, getSoftSwitchExt(ioFlagAltChar, ssOff, nil), "ALTCHARSETOFF")
|
|
|
|
io.addSoftSwitchW(0x0F, getSoftSwitchExt(ioFlagAltChar, ssOn, nil), "ALTCHARSETON")
|
|
|
|
io.addSoftSwitchR(0x1E, getStatusSoftSwitch(ioFlagAltChar), "ALTCHARSET")
|
2019-10-12 19:37:37 +00:00
|
|
|
|
|
|
|
// TOOD:
|
|
|
|
// AKD read on 0x10
|
|
|
|
// VBL read on 0x19
|
|
|
|
|
|
|
|
//io.softSwitchesData[ioFlagAltChar] = ssOn // Not sure about this.
|
2019-02-23 23:41:32 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
type softSwitchExtAction func(io *ioC0Page)
|
|
|
|
|
2019-02-24 22:54:13 +00:00
|
|
|
func getSoftSwitchExt(ioFlag uint8, dstValue uint8, action softSwitchExtAction) softSwitchW {
|
|
|
|
return func(io *ioC0Page, _ uint8) {
|
2019-02-23 23:41:32 +00:00
|
|
|
currentValue := io.softSwitchesData[ioFlag]
|
|
|
|
if currentValue == dstValue {
|
2019-02-24 22:54:13 +00:00
|
|
|
return // Already switched, ignore
|
2019-02-23 23:41:32 +00:00
|
|
|
}
|
2019-02-24 13:37:10 +00:00
|
|
|
if action != nil {
|
|
|
|
action(io)
|
|
|
|
}
|
2019-02-24 22:54:13 +00:00
|
|
|
io.softSwitchesData[ioFlag] = dstValue
|
2019-02-23 23:41:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func softSwitchIntCxRomOn(io *ioC0Page) {
|
2019-11-03 17:22:10 +00:00
|
|
|
//io.apple2.mmu.setPagesRead(0xc1, 0xcf, io.apple2.mmu.physicalROMe)
|
2019-02-23 23:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func softSwitchIntCxRomOff(io *ioC0Page) {
|
2019-05-16 20:55:19 +00:00
|
|
|
// TODO restore all the ROM from the slots for 0xc1 to 0xc7
|
2019-11-03 17:22:10 +00:00
|
|
|
//io.apple2.mmu.setPages(0xc1, 0xc7, nil)
|
2019-02-23 23:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func softSwitchSlotC3RomOn(io *ioC0Page) {
|
|
|
|
// TODO restore the slot 3 ROM
|
2019-11-03 17:22:10 +00:00
|
|
|
//io.apple2.mmu.setPages(0xc3, 0xc3, nil)
|
2019-02-23 23:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func softSwitchSlotC3RomOff(io *ioC0Page) {
|
2019-11-03 17:22:10 +00:00
|
|
|
//io.apple2.mmu.setPagesRead(0xc3, 0xc3, io.apple2.mmu.physicalROMe)
|
2019-02-23 23:41:32 +00:00
|
|
|
}
|
2019-05-17 21:28:20 +00:00
|
|
|
|
|
|
|
// TODO: apply state after persistance load
|