Fastchip alternate mode

This commit is contained in:
Ivan Izaguirre 2020-04-02 21:50:01 +02:00
parent 01099a8ce3
commit b1d7fe6571

View File

@ -18,6 +18,7 @@ type cardFastChip struct {
unlockCounter uint8
enabled bool
accelerated bool
configRegister uint8
}
func buildFastChipRom() []uint8 {
@ -43,6 +44,7 @@ func (c *cardFastChip) assign(a *Apple2, slot int) {
} else {
c.unlockCounter = 0
c.unlocked = false
c.enabled = false
}
}, "FASTCHIP-LOCK")
@ -53,7 +55,27 @@ func (c *cardFastChip) assign(a *Apple2, slot int) {
}, "FASTCHIP-ENABLE")
a.io.addSoftSwitchW(0x6d, func(_ *ioC0Page, value uint8) {
if c.unlocked && c.enabled {
if c.enabled {
c.setSpeed(a, value)
}
}, "FASTCHIP-SPEED")
a.io.addSoftSwitchW(0x6e, func(_ *ioC0Page, value uint8) {
if c.enabled {
c.configRegister = value
}
}, "FASTCHIP-CONFIG")
a.io.addSoftSwitchW(0x6f, func(_ *ioC0Page, value uint8) {
if c.enabled && c.configRegister == 0 {
c.setSpeed(a, value)
}
}, "FASTCHIP-CONFIG")
c.cardBase.assign(a, slot)
}
func (c *cardFastChip) setSpeed(a *Apple2, value uint8) {
newAccelerated := (value > fastChipNormalSpeed)
if newAccelerated == c.accelerated {
// No change requested
@ -65,8 +87,4 @@ func (c *cardFastChip) assign(a *Apple2, slot int) {
a.releaseFastMode()
}
c.accelerated = newAccelerated
}
}, "FASTCHIP-SPEED")
c.cardBase.assign(a, slot)
}