MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / SetMemMode

Method SetMemMode

source/LanguageCard.cpp:635–675  ·  view source on GitHub ↗

Set the global memmode. Support for GH#1495: . slot 0 LC set to: RAM write enabled, ROM read . slot 4 Saturn set to: RAM write protect, ROM read [*] (effectively disables the card) . no further LC switches are accessed, and DOS is copied to LC Since all LC/Saturns could be written to simultaneously, then we need to support the writes to slot 0 LC. [*] NB. Saturn has no ROM, so when set to "RO

Source from the content-addressed store, hash-verified

633// Since all LC/Saturns could be written to simultaneously, then we need to support the writes to slot 0 LC.
634// [*] NB. Saturn has no ROM, so when set to "ROM read", then the bus isn't driven.
635void LanguageCardManager::SetMemMode(const uint8_t slot)
636{
637 bool isAnyLCWithWritableHighRam = false;
638 uint8_t slotWithWritableHighRam = SLOT0;
639
640 // Scan all slots, looking for a LC/Saturn with writeable RAM
641 for (UINT i = SLOT0; i < NUM_SLOTS; i++)
642 {
643 if (GetCardMgr().QuerySlot(i) == CT_LanguageCard || GetCardMgr().QuerySlot(i) == CT_LanguageCardIIe || GetCardMgr().QuerySlot(i) == CT_Saturn128K)
644 {
645 uint32_t lcMemMode = dynamic_cast<LanguageCardUnit&>(GetCardMgr().GetRef(i)).GetLCMemMode();
646 if (lcMemMode & MF_WRITERAM) // RAM writable (don't care if it's ROM or RAM that's readable)
647 {
648 isAnyLCWithWritableHighRam = true;
649 slotWithWritableHighRam = i;
650
651 // Favour the last accessed RAM card (as don't support writing to multiple RAM cards!)
652 if (slotWithWritableHighRam == slot)
653 break;
654 }
655 }
656 }
657
658 if (!isAnyLCWithWritableHighRam)
659 {
660 // Rd: ROM or RAM / Wr: discarded
661 LanguageCardUnit& card = dynamic_cast<LanguageCardUnit&>(GetCardMgr().GetRef(slot));
662 ::SetMemMode((GetMemMode() & ~MF_LANGCARD_MASK) | (card.GetLCMemMode() & MF_LANGCARD_MASK));
663 // SetMemMainLanguageCard() already done by calling-function's IO()
664 }
665 else
666 {
667 // Rd: ROM or RAM / Wr: RAM
668 LanguageCardUnit& card = dynamic_cast<LanguageCardUnit&>(GetCardMgr().GetRef(slotWithWritableHighRam));
669 ::SetMemMode((GetMemMode() & ~MF_LANGCARD_MASK) | (card.GetLCMemMode() & MF_LANGCARD_MASK));
670 if (slotWithWritableHighRam != slot)
671 card.SetMainMemLanguageCardMemory();
672 }
673
674 MemUpdatePaging(0); // Initialize=0
675}
676
677void LanguageCardManager::SetMemModeFromSnapshot(void)
678{

Callers 1

IOMethod · 0.80

Calls 6

SetMemModeFunction · 0.85
GetMemModeFunction · 0.85
MemUpdatePagingFunction · 0.85
QuerySlotMethod · 0.80
GetLCMemModeMethod · 0.80

Tested by

no test coverage detected