From 9feded23f87473f90e198eb1f6d880c3811c6483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Izaguirre?= Date: Fri, 5 Aug 2022 19:43:17 +0200 Subject: [PATCH] Simplify softswitches --- base64a.go | 18 ++--- cardBase.go | 14 ++-- cardDisk2.go | 16 ++-- cardDisk2Sequencer.go | 2 +- cardFastChip.go | 10 +-- cardHardDisk.go | 12 +-- cardInOut.go | 4 +- cardLanguage.go | 4 +- cardLogger.go | 2 +- cardMemoryExpansion.go | 18 ++--- cardMouse.go | 22 +++--- cardParallelPrinter.go | 2 +- cardRGB.go | 20 ++--- cardRamWorks.go | 4 +- cardSaturn.go | 4 +- cardSwyft.go | 6 +- cardThunderClockPlus.go | 4 +- cardVidHD.go | 16 ++-- cardVidex.go | 4 +- ioC0Page.go | 12 +-- softSwitches2.go | 166 +++++++++++++++++++++------------------- softSwitches2e.go | 26 +++---- 22 files changed, 196 insertions(+), 190 deletions(-) diff --git a/base64a.go b/base64a.go index 65b8185..c700d22 100644 --- a/base64a.go +++ b/base64a.go @@ -58,33 +58,27 @@ func loadBase64aRom(a *Apple2) error { func addBase64aSoftSwitches(io *ioC0Page) { // Other softswitches, not implemented but called from the ROM - io.addSoftSwitchW(0x0C, notImplementedSoftSwitchW, "80COLOFF") - io.addSoftSwitchW(0x0E, notImplementedSoftSwitchW, "ALTCHARSETOFF") - - // Write on the speaker. That is a double access and should do nothing - // but works somehow on the BASE64A - io.addSoftSwitchW(0x30, func(io *ioC0Page, value uint8) { - speakerSoftSwitch(io) - }, "SPEAKER") + io.addSoftSwitchW(0x0C, buildNotImplementedSoftSwitchW(io), "80COLOFF") + io.addSoftSwitchW(0x0E, buildNotImplementedSoftSwitchW(io), "ALTCHARSETOFF") // ROM pagination softswitches. They use the annunciator 0 and 1 mmu := io.apple2.mmu - io.addSoftSwitchRW(0x58, func(*ioC0Page) uint8 { + io.addSoftSwitchRW(0x58, func() uint8 { p := mmu.getActiveROMPage() mmu.setActiveROMPage(p & 2) return 0 }, "ANN0OFF-ROM") - io.addSoftSwitchRW(0x59, func(*ioC0Page) uint8 { + io.addSoftSwitchRW(0x59, func() uint8 { p := mmu.getActiveROMPage() mmu.setActiveROMPage(p | 1) return 0 }, "ANN0ON-ROM") - io.addSoftSwitchRW(0x5A, func(*ioC0Page) uint8 { + io.addSoftSwitchRW(0x5A, func() uint8 { p := mmu.getActiveROMPage() mmu.setActiveROMPage(p & 1) return 0 }, "ANN1OFF-ROM") - io.addSoftSwitchRW(0x5B, func(*ioC0Page) uint8 { + io.addSoftSwitchRW(0x5B, func() uint8 { p := mmu.getActiveROMPage() mmu.setActiveROMPage(p | 2) return 0 diff --git a/cardBase.go b/cardBase.go index 39b06ca..b24a8bf 100644 --- a/cardBase.go +++ b/cardBase.go @@ -118,23 +118,23 @@ func (c *cardBase) addCardSoftSwitchRW(address uint8, ss softSwitchR, name strin c._ssr[address] = ss c._ssrName[address] = name - c._ssw[address] = func(p *ioC0Page, _ uint8) { - ss(p) + c._ssw[address] = func(uint8) { + ss() } c._sswName[address] = name } -type softSwitches func(io *ioC0Page, address uint8, data uint8, write bool) uint8 +type softSwitches func(address uint8, data uint8, write bool) uint8 func (c *cardBase) addCardSoftSwitches(sss softSwitches, name string) { for i := uint8(0x0); i <= 0xf; i++ { address := i - c.addCardSoftSwitchR(address, func(io *ioC0Page) uint8 { - return sss(io, address, 0, false) + c.addCardSoftSwitchR(address, func() uint8 { + return sss(address, 0, false) }, fmt.Sprintf("%v%XR", name, address)) - c.addCardSoftSwitchW(address, func(io *ioC0Page, value uint8) { - sss(io, address, value, true) + c.addCardSoftSwitchW(address, func(value uint8) { + sss(address, value, true) }, fmt.Sprintf("%v%XW", name, address)) } } diff --git a/cardDisk2.go b/cardDisk2.go index 669fca8..d3ee954 100644 --- a/cardDisk2.go +++ b/cardDisk2.go @@ -80,7 +80,7 @@ func (c *CardDisk2) assign(a *Apple2, slot int) { // Q1, Q2, Q3 and Q4 phase control soft switches, for i := uint8(0); i < 4; i++ { phase := i - c.addCardSoftSwitchR(phase<<1, func(_ *ioC0Page) uint8 { + c.addCardSoftSwitchR(phase<<1, func() uint8 { // Update magnets and position drive := &c.drive[c.selected] drive.phases &^= (1 << phase) @@ -93,7 +93,7 @@ func (c *CardDisk2) assign(a *Apple2, slot int) { return c.dataLatch // All even addresses return the last dataLatch }, fmt.Sprintf("PHASE%vOFF", phase)) - c.addCardSoftSwitchR((phase<<1)+1, func(_ *ioC0Page) uint8 { + c.addCardSoftSwitchR((phase<<1)+1, func() uint8 { // Update magnets and position drive := &c.drive[c.selected] drive.phases |= (1 << phase) @@ -108,21 +108,21 @@ func (c *CardDisk2) assign(a *Apple2, slot int) { } // Q4, power switch - c.addCardSoftSwitchR(0x8, func(_ *ioC0Page) uint8 { + c.addCardSoftSwitchR(0x8, func() uint8 { c.softSwitchQ4(false) return c.dataLatch }, "Q4DRIVEOFF") - c.addCardSoftSwitchR(0x9, func(_ *ioC0Page) uint8 { + c.addCardSoftSwitchR(0x9, func() uint8 { c.softSwitchQ4(true) return 0 }, "Q4DRIVEON") // Q5, drive selecion - c.addCardSoftSwitchR(0xA, func(_ *ioC0Page) uint8 { + c.addCardSoftSwitchR(0xA, func() uint8 { c.softSwitchQ5(0) return c.dataLatch }, "Q5SELECT1") - c.addCardSoftSwitchR(0xB, func(_ *ioC0Page) uint8 { + c.addCardSoftSwitchR(0xB, func() uint8 { c.softSwitchQ5(1) return 0 }, "Q5SELECT2") @@ -130,10 +130,10 @@ func (c *CardDisk2) assign(a *Apple2, slot int) { // Q6, Q7 for i := uint8(0xC); i <= 0xF; i++ { iCopy := i - c.addCardSoftSwitchR(iCopy, func(_ *ioC0Page) uint8 { + c.addCardSoftSwitchR(iCopy, func() uint8 { return c.softSwitchQ6Q7(iCopy, 0) }, "Q6Q7") - c.addCardSoftSwitchW(iCopy, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(iCopy, func(value uint8) { c.softSwitchQ6Q7(iCopy, value) }, "Q6Q7") } diff --git a/cardDisk2Sequencer.go b/cardDisk2Sequencer.go index b7c6959..8418562 100644 --- a/cardDisk2Sequencer.go +++ b/cardDisk2Sequencer.go @@ -80,7 +80,7 @@ func (c *CardDisk2Sequencer) reset() { } func (c *CardDisk2Sequencer) assign(a *Apple2, slot int) { - c.addCardSoftSwitches(func(_ *ioC0Page, address uint8, data uint8, write bool) uint8 { + c.addCardSoftSwitches(func(address uint8, data uint8, write bool) uint8 { /* Slot card pins to SN74LS259 latch mapping: slot_address[3,2,1] => latch_address[2,1,0] diff --git a/cardFastChip.go b/cardFastChip.go index 55ccd45..5ed769e 100644 --- a/cardFastChip.go +++ b/cardFastChip.go @@ -42,7 +42,7 @@ const ( func (c *CardFastChip) assign(a *Apple2, slot int) { // The softswitches are outside the card reserved ss // Only writes are implemented to avoid conflicts with the joysticks - a.io.addSoftSwitchW(0x6a, func(_ *ioC0Page, value uint8) { + a.io.addSoftSwitchW(0x6a, func(value uint8) { if value == fastChipUnlockToken { c.unlockCounter++ if c.unlockCounter >= fastChipUnlockRepeats { @@ -55,25 +55,25 @@ func (c *CardFastChip) assign(a *Apple2, slot int) { } }, "FASTCHIP-LOCK") - a.io.addSoftSwitchW(0x6b, func(_ *ioC0Page, _ uint8) { + a.io.addSoftSwitchW(0x6b, func(uint8) { if c.unlocked { c.enabled = true } }, "FASTCHIP-ENABLE") - a.io.addSoftSwitchW(0x6d, func(_ *ioC0Page, value uint8) { + a.io.addSoftSwitchW(0x6d, func(value uint8) { if c.enabled { c.setSpeed(a, value) } }, "FASTCHIP-SPEED") - a.io.addSoftSwitchW(0x6e, func(_ *ioC0Page, value uint8) { + a.io.addSoftSwitchW(0x6e, func(value uint8) { if c.enabled { c.configRegister = value } }, "FASTCHIP-CONFIG") - a.io.addSoftSwitchW(0x6f, func(_ *ioC0Page, value uint8) { + a.io.addSoftSwitchW(0x6f, func(value uint8) { if c.enabled && c.configRegister == 0 { c.setSpeed(a, value) } diff --git a/cardHardDisk.go b/cardHardDisk.go index b1ef254..b9b29ff 100644 --- a/cardHardDisk.go +++ b/cardHardDisk.go @@ -73,7 +73,7 @@ const ( func (c *CardHardDisk) assign(a *Apple2, slot int) { c.loadRom(buildHardDiskRom(slot)) - c.addCardSoftSwitchR(0, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(0, func() uint8 { // Prodos entry point command := a.mmu.Peek(0x42) unit := a.mmu.Peek(0x43) @@ -95,16 +95,16 @@ func (c *CardHardDisk) assign(a *Apple2, slot int) { return proDosDeviceErrorIO } }, "HDCOMMAND") - c.addCardSoftSwitchR(1, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(1, func() uint8 { // Blocks available, low byte return uint8(c.disk.GetSizeInBlocks()) }, "HDBLOCKSLO") - c.addCardSoftSwitchR(2, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(2, func() uint8 { // Blocks available, high byte return uint8(c.disk.GetSizeInBlocks() >> 8) }, "HDBLOCKHI") - c.addCardSoftSwitchR(3, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(3, func() uint8 { // Smart port entry point command := c.a.mmu.Peek(c.mliParams + 1) paramsAddress := uint16(c.a.mmu.Peek(c.mliParams+2)) + uint16(c.a.mmu.Peek(c.mliParams+3))<<8 @@ -127,13 +127,13 @@ func (c *CardHardDisk) assign(a *Apple2, slot int) { return proDosDeviceErrorIO } }, "HDSMARTPORT") - c.addCardSoftSwitchW(4, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(4, func(value uint8) { c.mliParams = (c.mliParams & 0xff00) + uint16(value) if c.trace { fmt.Printf("[CardHardDisk] Smart port LO: 0x%x.\n", c.mliParams) } }, "HDSMARTPORTLO") - c.addCardSoftSwitchW(5, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(5, func(value uint8) { c.mliParams = (c.mliParams & 0x00ff) + (uint16(value) << 8) if c.trace { fmt.Printf("[CardHardDisk] Smart port HI: 0x%x.\n", c.mliParams) diff --git a/cardInOut.go b/cardInOut.go index b858531..75d9e4f 100644 --- a/cardInOut.go +++ b/cardInOut.go @@ -32,7 +32,7 @@ func NewCardInOut() *CardInOut { } func (c *CardInOut) assign(a *Apple2, slot int) { - c.addCardSoftSwitchR(0, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(0, func() uint8 { if c.reader == nil { c.reader = bufio.NewReader(os.Stdin) } @@ -48,7 +48,7 @@ func (c *CardInOut) assign(a *Apple2, slot int) { //fmt.Printf("[cardInOut] Read access to softswith 0x%x for slot %v, value %x.\n", 0, slot, value) return value }, "INOUTR") - c.addCardSoftSwitchW(1, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(1, func(value uint8) { //fmt.Printf("[cardInOut] Write access to softswith 0x%x for slot %v, value 0x%x: %v, %v.\n", 1, slot, value, value&0x7f, string(value&0x7f)) if value&0x7f == 13 { fmt.Printf("\n") diff --git a/cardLanguage.go b/cardLanguage.go index ea03240..f6fc583 100644 --- a/cardLanguage.go +++ b/cardLanguage.go @@ -68,11 +68,11 @@ func (c *CardLanguage) assign(a *Apple2, slot int) { a.mmu.initLanguageRAM(1) for i := uint8(0x0); i <= 0xf; i++ { iCopy := i - c.addCardSoftSwitchR(iCopy, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(iCopy, func() uint8 { c.ssAction(iCopy, false) return 0 }, "LANGCARDR") - c.addCardSoftSwitchW(iCopy, func(*ioC0Page, uint8) { + c.addCardSoftSwitchW(iCopy, func(uint8) { c.ssAction(iCopy, true) }, "LANGCARDW") } diff --git a/cardLogger.go b/cardLogger.go index a9b0d7a..55a7323 100644 --- a/cardLogger.go +++ b/cardLogger.go @@ -21,7 +21,7 @@ func NewCardLogger() *CardLogger { } func (c *CardLogger) assign(a *Apple2, slot int) { - c.addCardSoftSwitches(func(_ *ioC0Page, address uint8, data uint8, write bool) uint8 { + c.addCardSoftSwitches(func(address uint8, data uint8, write bool) uint8 { if write { fmt.Printf("[cardLogger] Write access to softswith 0x%x for slot %v, value 0x%02x.\n", address, slot, data) } else { diff --git a/cardMemoryExpansion.go b/cardMemoryExpansion.go index e3bf035..14030a6 100644 --- a/cardMemoryExpansion.go +++ b/cardMemoryExpansion.go @@ -65,31 +65,31 @@ func (c *CardMemoryExpansion) GetInfo() map[string]string { func (c *CardMemoryExpansion) assign(a *Apple2, slot int) { // Read pointer position - c.addCardSoftSwitchR(0, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(0, func() uint8 { return uint8(c.index) }, "MEMORYEXLOR") - c.addCardSoftSwitchR(1, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(1, func() uint8 { return uint8(c.index >> 8) }, "MEMORYEXMIR") - c.addCardSoftSwitchR(2, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(2, func() uint8 { // Top nibble returned is 0xf return uint8(c.index>>16) | 0xf0 }, "MEMORYEXHIR") // Set pointer position - c.addCardSoftSwitchW(0, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(0, func(value uint8) { c.index = (c.index &^ 0xff) + int(value) }, "MEMORYEXLOW") - c.addCardSoftSwitchW(1, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(1, func(value uint8) { c.index = (c.index &^ 0xff00) + int(value)<<8 }, "MEMORYEXMIW") - c.addCardSoftSwitchW(2, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(2, func(value uint8) { // Only lo nibble is used c.index = (c.index &^ 0xff0000) + int(value&0x0f)<<16 }, "MEMORYEXHIW") // Read data - c.addCardSoftSwitchR(3, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(3, func() uint8 { var value uint8 if c.index < len(c.ram) { value = c.ram[c.index] @@ -101,7 +101,7 @@ func (c *CardMemoryExpansion) assign(a *Apple2, slot int) { }, "MEMORYEXR") // Write data - c.addCardSoftSwitchW(3, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(3, func(value uint8) { if c.index < len(c.ram) { c.ram[c.index] = value } @@ -110,7 +110,7 @@ func (c *CardMemoryExpansion) assign(a *Apple2, slot int) { // The rest of the softswitches return 255, at least on //e and //c for i := uint8(4); i < 16; i++ { - c.addCardSoftSwitchR(i, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(i, func() uint8 { return 255 }, "MEMORYEXUNUSEDR") } diff --git a/cardMouse.go b/cardMouse.go index 64fe0a4..b763318 100644 --- a/cardMouse.go +++ b/cardMouse.go @@ -92,7 +92,7 @@ func (c *CardMouse) readMouse() (uint16, uint16, bool) { } func (c *CardMouse) assign(a *Apple2, slot int) { - c.addCardSoftSwitchR(0, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(0, func() uint8 { if c.iOut == 0 { // Create a new response x, y, pressed := c.readMouse() @@ -126,7 +126,7 @@ func (c *CardMouse) assign(a *Apple2, slot int) { return value }, "MOUSEOUT") - c.addCardSoftSwitchW(1, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(1, func(value uint8) { if c.trace { fmt.Printf("[cardMouse] PR#%v <- %02x\n", slot, value) } @@ -140,21 +140,21 @@ func (c *CardMouse) assign(a *Apple2, slot int) { } }, "MOUSEIN") - c.addCardSoftSwitchW(2, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(2, func(value uint8) { if c.trace { fmt.Printf("[cardMouse] SetMouse(0x%02v)\n", value) } c.setMode(value & 0x0f) }, "SETMOUSE") - c.addCardSoftSwitchW(3, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(3, func(value uint8) { if c.trace { fmt.Printf("[cardMouse] ServeMouse() NOT IMPLEMENTED\n") } panic("Mouse interrupts not implemented") }, "SERVEMOUSE") - c.addCardSoftSwitchW(4, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(4, func(value uint8) { if c.mode&mouseModeEnabled == 1 { x, y, pressed := c.readMouse() @@ -186,7 +186,7 @@ func (c *CardMouse) assign(a *Apple2, slot int) { } }, "READMOUSE") - c.addCardSoftSwitchW(5, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(5, func(value uint8) { if c.trace { fmt.Printf("[cardMouse] ClearMouse() NOT IMPLEMENTED\n") } @@ -195,13 +195,13 @@ func (c *CardMouse) assign(a *Apple2, slot int) { c.set(mouseXLo, 0) c.set(mouseYLo, 0) }, "CLEARMOUSE") - c.addCardSoftSwitchW(6, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(6, func(value uint8) { if c.trace { fmt.Printf("[cardMouse] PosMouse() NOT IMPLEMENTED\n") } }, "POSMOUSE") - c.addCardSoftSwitchW(7, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(7, func(value uint8) { if c.trace { fmt.Printf("[cardMouse] ClampMouse(%v)\n", value) } @@ -219,13 +219,13 @@ func (c *CardMouse) assign(a *Apple2, slot int) { } }, "CLAMPMOUSE") - c.addCardSoftSwitchW(8, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(8, func(value uint8) { if c.trace { fmt.Printf("[cardMouse] HomeMouse() NOT IMPLEMENTED\n") } }, "HOMEMOUSE") - c.addCardSoftSwitchW(0xc, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(0xc, func(value uint8) { if c.trace { fmt.Printf("[cardMouse] InitMouse()\n") } @@ -236,7 +236,7 @@ func (c *CardMouse) assign(a *Apple2, slot int) { c.mode = 0 }, "INITMOUSE") - c.addCardSoftSwitchW(8, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(8, func(value uint8) { if c.trace { fmt.Printf("[cardMouse] TimeData(%v) NOT IMPLEMENTED\n", value) } diff --git a/cardParallelPrinter.go b/cardParallelPrinter.go index b54101b..ff22e42 100644 --- a/cardParallelPrinter.go +++ b/cardParallelPrinter.go @@ -33,7 +33,7 @@ func (c *CardParallelPrinter) assign(a *Apple2, slot int) { } c.file = f - c.addCardSoftSwitchW(0, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(0, func(value uint8) { c.printByte(value) }, "PARALLELDEVW") diff --git a/cardRGB.go b/cardRGB.go index 432b5db..8a939a0 100644 --- a/cardRGB.go +++ b/cardRGB.go @@ -38,17 +38,17 @@ func setupRGBCard(a *Apple2) *cardRGB { a.io.softSwitchesData[ioFlagRGBCardActive] = ssOn // Does not have ROM or private softswitches. It spies on the softswitches - a.io.addSoftSwitchRW(0x50, func(io *ioC0Page) uint8 { - io.softSwitchesData[ioFlagText] = ssOff + a.io.addSoftSwitchRW(0x50, func() uint8 { + a.io.softSwitchesData[ioFlagText] = ssOff // Reset RGB modes when entering graphics mode c.step = 0 - io.softSwitchesData[ioFlag1RGBCard] = ssOn - io.softSwitchesData[ioFlag2RGBCard] = ssOn + a.io.softSwitchesData[ioFlag1RGBCard] = ssOn + a.io.softSwitchesData[ioFlag2RGBCard] = ssOn return 0 }, "TEXTOFF") - a.io.addSoftSwitchRW(0x5e, func(io *ioC0Page) uint8 { - io.softSwitchesData[ioFlagAnnunciator3] = ssOff + a.io.addSoftSwitchRW(0x5e, func() uint8 { + a.io.softSwitchesData[ioFlagAnnunciator3] = ssOff switch c.step { case 0: c.step++ @@ -59,14 +59,14 @@ func setupRGBCard(a *Apple2) *cardRGB { return 0 }, "ANN3OFF-RGB") - a.io.addSoftSwitchRW(0x5f, func(io *ioC0Page) uint8 { - io.softSwitchesData[ioFlagAnnunciator3] = ssOn + a.io.addSoftSwitchRW(0x5f, func() uint8 { + a.io.softSwitchesData[ioFlagAnnunciator3] = ssOn switch c.step { case 1: - io.softSwitchesData[ioFlag1RGBCard] = io.softSwitchesData[ioFlag80Col] + a.io.softSwitchesData[ioFlag1RGBCard] = a.io.softSwitchesData[ioFlag80Col] c.step++ case 3: - io.softSwitchesData[ioFlag2RGBCard] = io.softSwitchesData[ioFlag80Col] + a.io.softSwitchesData[ioFlag2RGBCard] = a.io.softSwitchesData[ioFlag80Col] c.step++ } diff --git a/cardRamWorks.go b/cardRamWorks.go index 268e561..90f2d55 100644 --- a/cardRamWorks.go +++ b/cardRamWorks.go @@ -14,11 +14,11 @@ It's is like the extra 64kb on an Apple IIe 80col 64kb card, but with up to 256 func setupRAMWorksCard(a *Apple2, banks int) { a.mmu.initExtendedRAM(banks) - ssr := func(_ *ioC0Page) uint8 { + ssr := func() uint8 { return a.mmu.extendedRAMBlock } - ssw := func(_ *ioC0Page, value uint8) { + ssw := func(value uint8) { a.mmu.setExtendedRAMActiveBlock(value) } diff --git a/cardSaturn.go b/cardSaturn.go index b86bc7f..7d3897c 100644 --- a/cardSaturn.go +++ b/cardSaturn.go @@ -37,11 +37,11 @@ func (c *CardSaturn) assign(a *Apple2, slot int) { // TODO: use addCardSoftSwitches() for i := uint8(0x0); i <= 0xf; i++ { iCopy := i - c.addCardSoftSwitchR(iCopy, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(iCopy, func() uint8 { c.ssAction(iCopy) return 0 }, "SATURNR") - c.addCardSoftSwitchW(iCopy, func(*ioC0Page, uint8) { + c.addCardSoftSwitchW(iCopy, func(uint8) { c.ssAction(iCopy) }, "SATURNW") } diff --git a/cardSwyft.go b/cardSwyft.go index 327f667..ddb5e1e 100644 --- a/cardSwyft.go +++ b/cardSwyft.go @@ -81,19 +81,19 @@ func (c *CardSwyft) assign(a *Apple2, slot int) { } c.rom = data - c.addCardSoftSwitchRW(0, func(*ioC0Page) uint8 { + c.addCardSoftSwitchRW(0, func() uint8 { a.mmu.inhibitROM(c) c.bank2 = false return 0x55 }, "SWYFTONBANK1") - c.addCardSoftSwitchRW(1, func(*ioC0Page) uint8 { + c.addCardSoftSwitchRW(1, func() uint8 { a.mmu.inhibitROM(nil) c.bank2 = false return 0x55 }, "SWYFTOFFBANK1") - c.addCardSoftSwitchRW(2, func(*ioC0Page) uint8 { + c.addCardSoftSwitchRW(2, func() uint8 { a.mmu.inhibitROM(c) c.bank2 = true return 0x55 diff --git a/cardThunderClockPlus.go b/cardThunderClockPlus.go index c422889..b98f2b3 100644 --- a/cardThunderClockPlus.go +++ b/cardThunderClockPlus.go @@ -37,7 +37,7 @@ func NewCardThunderClockPlus() *CardThunderClockPlus { } func (c *CardThunderClockPlus) assign(a *Apple2, slot int) { - c.addCardSoftSwitchR(0, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(0, func() uint8 { bit := c.upd1990.Out() // Get the next data bit from uPD1990AC on the MSB if bit { @@ -46,7 +46,7 @@ func (c *CardThunderClockPlus) assign(a *Apple2, slot int) { return 0 }, "THUNDERCLOCKR") - c.addCardSoftSwitchW(0, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(0, func(value uint8) { dataIn := (value & 0x01) == 1 clock := ((value >> 1) & 0x01) == 1 strobe := ((value >> 2) & 0x01) == 1 diff --git a/cardVidHD.go b/cardVidHD.go index a5c1d7a..47cec40 100644 --- a/cardVidHD.go +++ b/cardVidHD.go @@ -37,14 +37,14 @@ const ( func (c *CardVidHD) assign(a *Apple2, slot int) { // The softswitches are outside the card reserved ss - a.io.addSoftSwitchR(0x22, notImplementedSoftSwitchR, "VIDHD-TBCOLOR") - a.io.addSoftSwitchW(0x22, notImplementedSoftSwitchW, "VIDHD-TBCOLOR") - a.io.addSoftSwitchR(0x29, getStatusSoftSwitch(ioDataNewVideo), "VIDHD-NEWVIDEO") - a.io.addSoftSwitchW(0x29, setStatusSoftSwitch(ioDataNewVideo), "VIDHD-NEWVIDEO") - a.io.addSoftSwitchR(0x34, notImplementedSoftSwitchR, "VIDHD-CLOCKCTL") - a.io.addSoftSwitchW(0x34, notImplementedSoftSwitchW, "VIDHD-CLOCKCTL") - a.io.addSoftSwitchR(0x35, notImplementedSoftSwitchR, "VIDHD-SHADOW") - a.io.addSoftSwitchW(0x35, notImplementedSoftSwitchW, "VIDHD-SHADOW") + a.io.addSoftSwitchR(0x22, buildNotImplementedSoftSwitchR(a.io), "VIDHD-TBCOLOR") + a.io.addSoftSwitchW(0x22, buildNotImplementedSoftSwitchW(a.io), "VIDHD-TBCOLOR") + a.io.addSoftSwitchR(0x29, getStatusSoftSwitch(a.io, ioDataNewVideo), "VIDHD-NEWVIDEO") + a.io.addSoftSwitchW(0x29, setStatusSoftSwitch(a.io, ioDataNewVideo), "VIDHD-NEWVIDEO") + a.io.addSoftSwitchR(0x34, buildNotImplementedSoftSwitchR(a.io), "VIDHD-CLOCKCTL") + a.io.addSoftSwitchW(0x34, buildNotImplementedSoftSwitchW(a.io), "VIDHD-CLOCKCTL") + a.io.addSoftSwitchR(0x35, buildNotImplementedSoftSwitchR(a.io), "VIDHD-SHADOW") + a.io.addSoftSwitchW(0x35, buildNotImplementedSoftSwitchW(a.io), "VIDHD-SHADOW") c.cardBase.assign(a, slot) } diff --git a/cardVidex.go b/cardVidex.go index c9fcaca..f353dcf 100644 --- a/cardVidex.go +++ b/cardVidex.go @@ -77,11 +77,11 @@ func (c *CardVidex) assign(a *Apple2, slot int) { ssName += "ADDRESS" } - c.addCardSoftSwitchR(i, func(*ioC0Page) uint8 { + c.addCardSoftSwitchR(i, func() uint8 { c.sramPage = sramPage return c.mc6845.Read(rsPin) }, ssName+"R") - c.addCardSoftSwitchW(i, func(_ *ioC0Page, value uint8) { + c.addCardSoftSwitchW(i, func(value uint8) { c.sramPage = sramPage c.mc6845.Write(rsPin, value) }, ssName+"W") diff --git a/ioC0Page.go b/ioC0Page.go index 8b45ab3..514c6aa 100644 --- a/ioC0Page.go +++ b/ioC0Page.go @@ -21,8 +21,8 @@ type ioC0Page struct { panicNotImplemented bool } -type softSwitchR func(io *ioC0Page) uint8 -type softSwitchW func(io *ioC0Page, value uint8) +type softSwitchR func() uint8 +type softSwitchW func(value uint8) // SpeakerProvider provides a speaker implementation type SpeakerProvider interface { @@ -69,8 +69,8 @@ func (p *ioC0Page) setPanicNotImplemented(value bool) { func (p *ioC0Page) addSoftSwitchRW(address uint8, ss softSwitchR, name string) { p.addSoftSwitchR(address, ss, name) - p.addSoftSwitchW(address, func(p *ioC0Page, _ uint8) { - ss(p) + p.addSoftSwitchW(address, func(uint8) { + ss() }, name) } @@ -122,7 +122,7 @@ func (p *ioC0Page) peek(address uint16) uint8 { } return 0 } - value := ss(p) + value := ss() if p.trace && address != 0xc000 { name := p.softSwitchesRName[pageAddress] fmt.Printf("Softswitch peek on $%04x %v: $%02x\n", address, name, value) @@ -146,7 +146,7 @@ func (p *ioC0Page) poke(address uint16, value uint8) { name := p.softSwitchesWName[pageAddress] fmt.Printf("Softswitch poke on $%04x %v with $%02x\n", address, name, value) } - ss(p, value) + ss(value) } func (p *ioC0Page) setBase(_ uint16) { diff --git a/softSwitches2.go b/softSwitches2.go index 53000a3..08e1db3 100644 --- a/softSwitches2.go +++ b/softSwitches2.go @@ -29,81 +29,86 @@ const ( func addApple2SoftSwitches(io *ioC0Page) { - io.addSoftSwitchRW(0x00, keySoftSwitch, "KEYBOARD") // Keyboard - io.addSoftSwitchRW(0x10, strobeKeyboardSoftSwitch, "AKD") // Keyboard Strobe - io.addSoftSwitchR(0x20, notImplementedSoftSwitchR, "TAPEOUT") // Cassette Output - io.addSoftSwitchRW(0x30, speakerSoftSwitch, "SPEAKER") // Speaker - io.addSoftSwitchR(0x40, notImplementedSoftSwitchR, "STROBE") // Game connector Strobe + io.addSoftSwitchRW(0x00, buildKeySoftSwitch(io), "KEYBOARD") // Keyboard + io.addSoftSwitchRW(0x10, buildStrobeKeyboardSoftSwitch(io), "AKD") // Keyboard Strobe + io.addSoftSwitchR(0x20, buildNotImplementedSoftSwitchR(io), "TAPEOUT") // Cassette Output + io.addSoftSwitchRW(0x30, buildSpeakerSoftSwitch(io), "SPEAKER") // Speaker + io.addSoftSwitchR(0x40, buildNotImplementedSoftSwitchR(io), "STROBE") // Game connector Strobe // Note: Some sources indicate that all these cover 16 positions // for read and write. But the Apple2e takes over some of them, with // the prevention on acting only on writes. - io.addSoftSwitchRW(0x50, getSoftSwitch(ioFlagText, false), "TEXTOFF") - io.addSoftSwitchRW(0x51, getSoftSwitch(ioFlagText, true), "TEXTON") - io.addSoftSwitchRW(0x52, getSoftSwitch(ioFlagMixed, false), "MIXEDOFF") - io.addSoftSwitchRW(0x53, getSoftSwitch(ioFlagMixed, true), "MIXEDON") - io.addSoftSwitchRW(0x54, getSoftSwitch(ioFlagSecondPage, false), "PAGE2OFF") - io.addSoftSwitchRW(0x55, getSoftSwitch(ioFlagSecondPage, true), "PAGE2ON") - io.addSoftSwitchRW(0x56, getSoftSwitch(ioFlagHiRes, false), "HIRESOFF") - io.addSoftSwitchRW(0x57, getSoftSwitch(ioFlagHiRes, true), "HIRESON") + io.addSoftSwitchRW(0x50, getSoftSwitch(io, ioFlagText, false), "TEXTOFF") + io.addSoftSwitchRW(0x51, getSoftSwitch(io, ioFlagText, true), "TEXTON") + io.addSoftSwitchRW(0x52, getSoftSwitch(io, ioFlagMixed, false), "MIXEDOFF") + io.addSoftSwitchRW(0x53, getSoftSwitch(io, ioFlagMixed, true), "MIXEDON") + io.addSoftSwitchRW(0x54, getSoftSwitch(io, ioFlagSecondPage, false), "PAGE2OFF") + io.addSoftSwitchRW(0x55, getSoftSwitch(io, ioFlagSecondPage, true), "PAGE2ON") + io.addSoftSwitchRW(0x56, getSoftSwitch(io, ioFlagHiRes, false), "HIRESOFF") + io.addSoftSwitchRW(0x57, getSoftSwitch(io, ioFlagHiRes, true), "HIRESON") - io.addSoftSwitchRW(0x58, getSoftSwitch(ioFlagAnnunciator0, false), "ANN0OFF") - io.addSoftSwitchRW(0x59, getSoftSwitch(ioFlagAnnunciator0, true), "ANN0ON") - io.addSoftSwitchRW(0x5a, getSoftSwitch(ioFlagAnnunciator1, false), "ANN1OFF") - io.addSoftSwitchRW(0x5b, getSoftSwitch(ioFlagAnnunciator1, true), "ANN1ON") - io.addSoftSwitchRW(0x5c, getSoftSwitch(ioFlagAnnunciator2, false), "ANN2OFF") - io.addSoftSwitchRW(0x5d, getSoftSwitch(ioFlagAnnunciator2, true), "ANN2ON") - io.addSoftSwitchRW(0x5e, getSoftSwitch(ioFlagAnnunciator3, false), "ANN3OFF") - io.addSoftSwitchRW(0x5f, getSoftSwitch(ioFlagAnnunciator3, true), "ANN3ON") + io.addSoftSwitchRW(0x58, getSoftSwitch(io, ioFlagAnnunciator0, false), "ANN0OFF") + io.addSoftSwitchRW(0x59, getSoftSwitch(io, ioFlagAnnunciator0, true), "ANN0ON") + io.addSoftSwitchRW(0x5a, getSoftSwitch(io, ioFlagAnnunciator1, false), "ANN1OFF") + io.addSoftSwitchRW(0x5b, getSoftSwitch(io, ioFlagAnnunciator1, true), "ANN1ON") + io.addSoftSwitchRW(0x5c, getSoftSwitch(io, ioFlagAnnunciator2, false), "ANN2OFF") + io.addSoftSwitchRW(0x5d, getSoftSwitch(io, ioFlagAnnunciator2, true), "ANN2ON") + io.addSoftSwitchRW(0x5e, getSoftSwitch(io, ioFlagAnnunciator3, false), "ANN3OFF") + io.addSoftSwitchRW(0x5f, getSoftSwitch(io, ioFlagAnnunciator3, true), "ANN3ON") - io.addSoftSwitchR(0x60, notImplementedSoftSwitchR, "CASSETTE") // Cassette Input - io.addSoftSwitchR(0x61, getButtonSoftSwitch(0), "PB0") - io.addSoftSwitchR(0x62, getButtonSoftSwitch(1), "PB1") - io.addSoftSwitchR(0x63, getButtonSoftSwitch(2), "PB2") - io.addSoftSwitchR(0x64, getPaddleSoftSwitch(0), "PDL0") - io.addSoftSwitchR(0x65, getPaddleSoftSwitch(1), "PDL1") - io.addSoftSwitchR(0x66, getPaddleSoftSwitch(2), "PDL2") - io.addSoftSwitchR(0x67, getPaddleSoftSwitch(3), "PDL3") + io.addSoftSwitchR(0x60, buildNotImplementedSoftSwitchR(io), "CASSETTE") // Cassette Input + io.addSoftSwitchR(0x61, buildButtonSoftSwitch(io, 0), "PB0") + io.addSoftSwitchR(0x62, buildButtonSoftSwitch(io, 1), "PB1") + io.addSoftSwitchR(0x63, buildButtonSoftSwitch(io, 2), "PB2") + io.addSoftSwitchR(0x64, buildPaddleSoftSwitch(io, 0), "PDL0") + io.addSoftSwitchR(0x65, buildPaddleSoftSwitch(io, 1), "PDL1") + io.addSoftSwitchR(0x66, buildPaddleSoftSwitch(io, 2), "PDL2") + io.addSoftSwitchR(0x67, buildPaddleSoftSwitch(io, 3), "PDL3") // The previous 8 softswitches are repeated - io.addSoftSwitchR(0x68, notImplementedSoftSwitchR, "CASSETTE") // Cassette Input - io.addSoftSwitchR(0x69, getButtonSoftSwitch(0), "PB0") - io.addSoftSwitchR(0x6A, getButtonSoftSwitch(1), "PB1") - io.addSoftSwitchR(0x6B, getButtonSoftSwitch(2), "PB2") - io.addSoftSwitchR(0x6C, getPaddleSoftSwitch(0), "PDL0") - io.addSoftSwitchR(0x6D, getPaddleSoftSwitch(1), "PDL1") - io.addSoftSwitchR(0x6E, getPaddleSoftSwitch(2), "PDL2") - io.addSoftSwitchR(0x6F, getPaddleSoftSwitch(3), "PDL3") + io.addSoftSwitchR(0x68, buildNotImplementedSoftSwitchR(io), "CASSETTE") // Cassette Input + io.addSoftSwitchR(0x69, buildButtonSoftSwitch(io, 0), "PB0") + io.addSoftSwitchR(0x6A, buildButtonSoftSwitch(io, 1), "PB1") + io.addSoftSwitchR(0x6B, buildButtonSoftSwitch(io, 2), "PB2") + io.addSoftSwitchR(0x6C, buildPaddleSoftSwitch(io, 0), "PDL0") + io.addSoftSwitchR(0x6D, buildPaddleSoftSwitch(io, 1), "PDL1") + io.addSoftSwitchR(0x6E, buildPaddleSoftSwitch(io, 2), "PDL2") + io.addSoftSwitchR(0x6F, buildPaddleSoftSwitch(io, 3), "PDL3") - io.addSoftSwitchR(0x70, strobePaddlesSoftSwitch, "RESETPDL") // Game controllers reset + io.addSoftSwitchR(0x70, buildStrobePaddlesSoftSwitch(io), "RESETPDL") // Game controllers reset // For RGB screen modes. Default to NTSC artifacts io.softSwitchesData[ioFlag1RGBCard] = ssOn io.softSwitchesData[ioFlag2RGBCard] = ssOn } -func notImplementedSoftSwitchR(io *ioC0Page) uint8 { - // Return random info. Some games (Serpentine) used CASSETTE and get stuck if not changing. - return uint8(io.apple2.cpu.GetCycles()) +func buildNotImplementedSoftSwitchR(io *ioC0Page) softSwitchR { + return func() uint8 { + // Return random info. Some games (Serpentine) used CASSETTE and get stuck if not changing. + return uint8(io.apple2.cpu.GetCycles()) + } } -func notImplementedSoftSwitchW(*ioC0Page, uint8) { +func buildNotImplementedSoftSwitchW(io *ioC0Page) softSwitchW { + return func(uint8) { + // Do nothing + } } -func setStatusSoftSwitch(ioFlag uint8) softSwitchW { - return func(io *ioC0Page, value uint8) { +func setStatusSoftSwitch(io *ioC0Page, ioFlag uint8) softSwitchW { + return func(value uint8) { io.softSwitchesData[ioFlag] = value } } -func getStatusSoftSwitch(ioFlag uint8) softSwitchR { - return func(io *ioC0Page) uint8 { +func getStatusSoftSwitch(io *ioC0Page, ioFlag uint8) softSwitchR { + return func() uint8 { return io.softSwitchesData[ioFlag] } } -func getSoftSwitch(ioFlag uint8, isSet bool) softSwitchR { - return func(io *ioC0Page) uint8 { +func getSoftSwitch(io *ioC0Page, ioFlag uint8, isSet bool) softSwitchR { + return func() uint8 { if isSet { io.softSwitchesData[ioFlag] = ssOn } else { @@ -113,35 +118,40 @@ func getSoftSwitch(ioFlag uint8, isSet bool) softSwitchR { } } -func speakerSoftSwitch(io *ioC0Page) uint8 { - if io.speaker != nil { - io.speaker.Click(io.apple2.cpu.GetCycles()) - } - return 0 -} - -func keySoftSwitch(io *ioC0Page) uint8 { - strobed := (io.softSwitchesData[ioDataKeyboard] & (1 << 7)) == 0 - if io.keyboard != nil { - if key, ok := io.keyboard.GetKey(strobed); ok { - io.softSwitchesData[ioDataKeyboard] = key + (1 << 7) +func buildSpeakerSoftSwitch(io *ioC0Page) softSwitchR { + return func() uint8 { + if io.speaker != nil { + io.speaker.Click(io.apple2.cpu.GetCycles()) } + return 0 } - value := io.softSwitchesData[ioDataKeyboard] - //fmt.Printf("Key $%02x, %v\n", value, strobed) - return value - } -func strobeKeyboardSoftSwitch(io *ioC0Page) uint8 { - result := io.softSwitchesData[ioDataKeyboard] - //fmt.Printf("Strobe $%02x\n", result) - io.softSwitchesData[ioDataKeyboard] &^= 1 << 7 - return result +func buildKeySoftSwitch(io *ioC0Page) softSwitchR { + return func() uint8 { + strobed := (io.softSwitchesData[ioDataKeyboard] & (1 << 7)) == 0 + if io.keyboard != nil { + if key, ok := io.keyboard.GetKey(strobed); ok { + io.softSwitchesData[ioDataKeyboard] = key + (1 << 7) + } + } + value := io.softSwitchesData[ioDataKeyboard] + //fmt.Printf("Key $%02x, %v\n", value, strobed) + return value + } } -func getButtonSoftSwitch(i int) softSwitchR { - return func(io *ioC0Page) uint8 { +func buildStrobeKeyboardSoftSwitch(io *ioC0Page) softSwitchR { + return func() uint8 { + result := io.softSwitchesData[ioDataKeyboard] + //fmt.Printf("Strobe $%02x\n", result) + io.softSwitchesData[ioDataKeyboard] &^= 1 << 7 + return result + } +} + +func buildButtonSoftSwitch(io *ioC0Page, i int) softSwitchR { + return func() uint8 { if io.joysticks != nil && io.joysticks.ReadButton(i) { return 128 } @@ -161,8 +171,8 @@ func getButtonSoftSwitch(i int) softSwitchR { const paddleToCyclesFactor = 11 -func getPaddleSoftSwitch(i int) softSwitchR { - return func(io *ioC0Page) uint8 { +func buildPaddleSoftSwitch(io *ioC0Page, i int) softSwitchR { + return func() uint8 { if io.joysticks == nil { return 255 // Capacitors never discharge if there is not joystick } @@ -180,8 +190,10 @@ func getPaddleSoftSwitch(i int) softSwitchR { } } -func strobePaddlesSoftSwitch(io *ioC0Page) uint8 { - // On the real machine this discharges the capacitors. - io.paddlesStrobeCycle = io.apple2.cpu.GetCycles() - return 0 +func buildStrobePaddlesSoftSwitch(io *ioC0Page) softSwitchR { + return func() uint8 { + // On the real machine this discharges the capacitors. + io.paddlesStrobeCycle = io.apple2.cpu.GetCycles() + return 0 + } } diff --git a/softSwitches2e.go b/softSwitches2e.go index 6179cb3..fd18aaa 100644 --- a/softSwitches2e.go +++ b/softSwitches2e.go @@ -31,19 +31,19 @@ func addApple2ESoftSwitches(io *ioC0Page) { addSoftSwitchesIou(io, 0x0e, 0x0f, 0x1e, ioFlagAltChar, "ALTCHARSET") // Previous read softswithes - io.addSoftSwitchR(0x1A, getStatusSoftSwitch(ioFlagText), "TEXT") - io.addSoftSwitchR(0x1B, getStatusSoftSwitch(ioFlagMixed), "MIXED") - io.addSoftSwitchR(0x1C, getStatusSoftSwitch(ioFlagSecondPage), "PAGE2") - io.addSoftSwitchR(0x1D, getStatusSoftSwitch(ioFlagHiRes), "HIRES") + 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") - io.addSoftSwitchR(0x11, func(_ *ioC0Page) uint8 { + io.addSoftSwitchR(0x11, func() uint8 { return ssFromBool(mmu.lcAltBank) }, "BSRBANK2") - io.addSoftSwitchR(0x12, func(_ *ioC0Page) uint8 { + io.addSoftSwitchR(0x12, func() uint8 { return ssFromBool(mmu.lcActiveRead) }, "BSRREADRAM") - io.addSoftSwitchR(0x19, func(_ *ioC0Page) uint8 { + io.addSoftSwitchR(0x19, func() uint8 { // See "Inside Apple IIe", page 268 // See http://rich12345.tripod.com/aiivideo/vbl.html // For each screen draw: @@ -62,29 +62,29 @@ func addApple2ESoftSwitches(io *ioC0Page) { } func addSoftSwitchesMmu(io *ioC0Page, addressClear uint8, addressSet uint8, AddressGet uint8, flag *bool, name string) { - io.addSoftSwitchW(addressClear, func(_ *ioC0Page, _ uint8) { + io.addSoftSwitchW(addressClear, func(uint8) { *flag = false }, name+"OFF") - io.addSoftSwitchW(addressSet, func(_ *ioC0Page, _ uint8) { + io.addSoftSwitchW(addressSet, func(uint8) { *flag = true }, name+"ON") - io.addSoftSwitchR(AddressGet, func(_ *ioC0Page) uint8 { + io.addSoftSwitchR(AddressGet, func() uint8 { return ssFromBool(*flag) }, name) } func addSoftSwitchesIou(io *ioC0Page, addressClear uint8, addressSet uint8, AddressGet uint8, ioFlag uint8, name string) { - io.addSoftSwitchW(addressClear, func(_ *ioC0Page, _ uint8) { + io.addSoftSwitchW(addressClear, func(uint8) { io.softSwitchesData[ioFlag] = ssOff }, name+"OFF") - io.addSoftSwitchW(addressSet, func(_ *ioC0Page, _ uint8) { + io.addSoftSwitchW(addressSet, func(uint8) { io.softSwitchesData[ioFlag] = ssOn }, name+"ON") - io.addSoftSwitchR(AddressGet, func(_ *ioC0Page) uint8 { + io.addSoftSwitchR(AddressGet, func() uint8 { return io.softSwitchesData[ioFlag] }, name) }