Fastchip alternate mode

This commit is contained in:
Ivan Izaguirre 2020-04-02 21:50:01 +02:00
parent 01099a8ce3
commit b1d7fe6571
1 changed files with 34 additions and 16 deletions

View File

@ -18,6 +18,7 @@ type cardFastChip struct {
unlockCounter uint8 unlockCounter uint8
enabled bool enabled bool
accelerated bool accelerated bool
configRegister uint8
} }
func buildFastChipRom() []uint8 { func buildFastChipRom() []uint8 {
@ -43,6 +44,7 @@ func (c *cardFastChip) assign(a *Apple2, slot int) {
} else { } else {
c.unlockCounter = 0 c.unlockCounter = 0
c.unlocked = false c.unlocked = false
c.enabled = false
} }
}, "FASTCHIP-LOCK") }, "FASTCHIP-LOCK")
@ -53,7 +55,27 @@ func (c *cardFastChip) assign(a *Apple2, slot int) {
}, "FASTCHIP-ENABLE") }, "FASTCHIP-ENABLE")
a.io.addSoftSwitchW(0x6d, func(_ *ioC0Page, value uint8) { 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) newAccelerated := (value > fastChipNormalSpeed)
if newAccelerated == c.accelerated { if newAccelerated == c.accelerated {
// No change requested // No change requested
@ -66,7 +88,3 @@ func (c *cardFastChip) assign(a *Apple2, slot int) {
} }
c.accelerated = newAccelerated c.accelerated = newAccelerated
} }
}, "FASTCHIP-SPEED")
c.cardBase.assign(a, slot)
}