2020-10-03 21:38:26 +00:00
|
|
|
package izapple2
|
2019-02-23 23:41:32 +00:00
|
|
|
|
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-11-03 23:23:03 +00:00
|
|
|
ioFlagAltChar uint8 = 0x1E
|
|
|
|
ioFlag80Col uint8 = 0x1F
|
2019-11-11 21:58:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
screenDrawCycles = uint64(12480 + 4550)
|
|
|
|
screenVertBlankingCycles = uint64(4550)
|
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-11-03 23:23:03 +00:00
|
|
|
mmu := io.apple2.mmu
|
|
|
|
addSoftSwitchesMmu(io, 0x02, 0x03, 0x13, &mmu.altMainRAMActiveRead, "RAMRD")
|
|
|
|
addSoftSwitchesMmu(io, 0x04, 0x05, 0x14, &mmu.altMainRAMActiveWrite, "RAMWRT")
|
2019-11-05 23:02:03 +00:00
|
|
|
addSoftSwitchesMmu(io, 0x06, 0x07, 0x15, &mmu.intCxROMActive, "INTCXROM")
|
2019-11-03 23:23:03 +00:00
|
|
|
addSoftSwitchesMmu(io, 0x08, 0x09, 0x16, &mmu.altZeroPage, "ALTZP")
|
2019-11-05 23:02:03 +00:00
|
|
|
addSoftSwitchesMmu(io, 0x0a, 0x0b, 0x17, &mmu.slotC3ROMActive, "SLOTC3ROM")
|
2020-08-30 16:59:00 +00:00
|
|
|
mmu.slotC3ROMActive = false // Default behavior in II+ was true
|
2019-11-08 22:56:54 +00:00
|
|
|
addSoftSwitchesMmu(io, 0x00, 0x01, 0x18, &mmu.store80Active, "80STORE")
|
2019-10-20 22:00:42 +00:00
|
|
|
|
2019-11-03 23:23:03 +00:00
|
|
|
// New IOU read softswithes
|
|
|
|
addSoftSwitchesIou(io, 0x0c, 0x0d, 0x1f, ioFlag80Col, "80COL")
|
|
|
|
addSoftSwitchesIou(io, 0x0e, 0x0f, 0x1e, ioFlagAltChar, "ALTCHARSET")
|
2019-10-12 19:37:37 +00:00
|
|
|
|
|
|
|
// Previous read softswithes
|
2022-08-05 17:43:17 +00:00
|
|
|
io.addSoftSwitchR(0x1A, getStatusSoftSwitch(io, ioFlagText), "TEXT")
|
|
|
|
io.addSoftSwitchR(0x1B, getStatusSoftSwitch(io, ioFlagMixed), "MIXED")
|
|
|
|
io.addSoftSwitchR(0x1C, getStatusSoftSwitch(io, ioFlagSecondPage), "PAGE2")
|
|
|
|
io.addSoftSwitchR(0x1D, getStatusSoftSwitch(io, ioFlagHiRes), "HIRES")
|
2019-10-12 19:37:37 +00:00
|
|
|
|
2022-08-05 17:43:17 +00:00
|
|
|
io.addSoftSwitchR(0x11, func() uint8 {
|
2019-11-05 23:02:03 +00:00
|
|
|
return ssFromBool(mmu.lcAltBank)
|
|
|
|
}, "BSRBANK2")
|
2022-08-05 17:43:17 +00:00
|
|
|
io.addSoftSwitchR(0x12, func() uint8 {
|
2019-11-05 23:02:03 +00:00
|
|
|
return ssFromBool(mmu.lcActiveRead)
|
|
|
|
}, "BSRREADRAM")
|
|
|
|
|
2022-08-05 17:43:17 +00:00
|
|
|
io.addSoftSwitchR(0x19, func() uint8 {
|
2019-11-11 21:58:42 +00:00
|
|
|
// See "Inside Apple IIe", page 268
|
|
|
|
// See http://rich12345.tripod.com/aiivideo/vbl.html
|
|
|
|
// For each screen draw:
|
|
|
|
// 12480 cycles drawing lines, VERTBLANK = $00
|
|
|
|
// 4550 cycles doing the return to position (0,0), VERTBLANK = $80
|
|
|
|
// Vert blank takes 12480 cycles every page redraw
|
|
|
|
cycles := io.apple2.cpu.GetCycles() % screenDrawCycles
|
|
|
|
if cycles <= screenVertBlankingCycles {
|
|
|
|
return ssOn
|
|
|
|
}
|
|
|
|
return ssOff
|
|
|
|
}, "VERTBLANK")
|
2019-10-12 19:37:37 +00:00
|
|
|
|
|
|
|
//io.softSwitchesData[ioFlagAltChar] = ssOn // Not sure about this.
|
2019-02-23 23:41:32 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-11-03 23:23:03 +00:00
|
|
|
func addSoftSwitchesMmu(io *ioC0Page, addressClear uint8, addressSet uint8, AddressGet uint8, flag *bool, name string) {
|
2022-08-05 17:43:17 +00:00
|
|
|
io.addSoftSwitchW(addressClear, func(uint8) {
|
2019-11-03 23:23:03 +00:00
|
|
|
*flag = false
|
|
|
|
}, name+"OFF")
|
2019-02-23 23:41:32 +00:00
|
|
|
|
2022-08-05 17:43:17 +00:00
|
|
|
io.addSoftSwitchW(addressSet, func(uint8) {
|
2019-11-03 23:23:03 +00:00
|
|
|
*flag = true
|
|
|
|
}, name+"ON")
|
|
|
|
|
2022-08-05 17:43:17 +00:00
|
|
|
io.addSoftSwitchR(AddressGet, func() uint8 {
|
2019-11-05 23:02:03 +00:00
|
|
|
return ssFromBool(*flag)
|
2019-11-03 23:23:03 +00:00
|
|
|
}, name)
|
2019-02-23 23:41:32 +00:00
|
|
|
}
|
|
|
|
|
2019-11-03 23:23:03 +00:00
|
|
|
func addSoftSwitchesIou(io *ioC0Page, addressClear uint8, addressSet uint8, AddressGet uint8, ioFlag uint8, name string) {
|
2022-08-05 17:43:17 +00:00
|
|
|
io.addSoftSwitchW(addressClear, func(uint8) {
|
2019-11-03 23:23:03 +00:00
|
|
|
io.softSwitchesData[ioFlag] = ssOff
|
|
|
|
}, name+"OFF")
|
2019-02-23 23:41:32 +00:00
|
|
|
|
2022-08-05 17:43:17 +00:00
|
|
|
io.addSoftSwitchW(addressSet, func(uint8) {
|
2019-11-03 23:23:03 +00:00
|
|
|
io.softSwitchesData[ioFlag] = ssOn
|
|
|
|
}, name+"ON")
|
2019-02-23 23:41:32 +00:00
|
|
|
|
2022-08-05 17:43:17 +00:00
|
|
|
io.addSoftSwitchR(AddressGet, func() uint8 {
|
2019-11-03 23:23:03 +00:00
|
|
|
return io.softSwitchesData[ioFlag]
|
|
|
|
}, name)
|
2019-02-23 23:41:32 +00:00
|
|
|
}
|