Implement the INTC8ROM softswitch

This commit is contained in:
Ivan Izaguirre 2020-09-23 18:23:57 +02:00
parent 9ce9d1f96d
commit 3f7c0bdf57
1 changed files with 18 additions and 8 deletions

View File

@ -39,6 +39,7 @@ type memoryManager struct {
store80Active bool // Special pagination for text and graphics areas store80Active bool // Special pagination for text and graphics areas
slotC3ROMActive bool // Apple2e slot 3 ROM shadow slotC3ROMActive bool // Apple2e slot 3 ROM shadow
intCxROMActive bool // Apple2e slots internal ROM shadow intCxROMActive bool // Apple2e slots internal ROM shadow
intC8ROMActive bool // C8Rom associated to the internal slot 3. Softswitch not directly accessible. See UtA2e 5-28
activeSlot uint8 // Active slot owner of 0xc800 to 0xcfff activeSlot uint8 // Active slot owner of 0xc800 to 0xcfff
extendedRAMBlock uint8 // Block used for entended memory for RAMWorks cards extendedRAMBlock uint8 // Block used for entended memory for RAMWorks cards
@ -82,26 +83,35 @@ func newMemoryManager(a *Apple2) *memoryManager {
} }
func (mmu *memoryManager) accessCArea(address uint16) memoryHandler { func (mmu *memoryManager) accessCArea(address uint16) memoryHandler {
slot := uint8((address >> 8) & 0x0f)
// Internal IIe slot 3
if (address <= addressLimitSlots) && !mmu.slotC3ROMActive && (slot == 3) {
mmu.intC8ROMActive = true
return mmu.physicalROM[mmu.romPage]
}
// Internal IIe CxROM
if mmu.intCxROMActive { if mmu.intCxROMActive {
return mmu.physicalROM[mmu.romPage] return mmu.physicalROM[mmu.romPage]
} }
// First slot area // First slot area
if address <= addressLimitSlots { if slot <= 7 {
slot := uint8((address >> 8) & 0x07)
mmu.activeSlot = slot mmu.activeSlot = slot
if !mmu.slotC3ROMActive && (slot == 3) { mmu.intC8ROMActive = false
return mmu.physicalROM[mmu.romPage]
}
return mmu.cardsROM[slot] return mmu.cardsROM[slot]
} }
// Extra slot area
// Extra slot area reset
if address == ioC8Off { if address == ioC8Off {
// Reset extra slot area owner // Reset extra slot area owner
mmu.activeSlot = 0 mmu.activeSlot = 0
mmu.lastAddressPage = invalidAddressPage mmu.intC8ROMActive = false
} }
if !mmu.slotC3ROMActive && (mmu.activeSlot == 3) { // Extra slot area
if mmu.intC8ROMActive {
return mmu.physicalROM[mmu.romPage] return mmu.physicalROM[mmu.romPage]
} }
return mmu.cardsROMExtra[mmu.activeSlot] return mmu.cardsROMExtra[mmu.activeSlot]