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

Function MemLoadSnapshotAuxCommon

source/Memory.cpp:3021–3107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3019}
3020
3021static SS_CARDTYPE MemLoadSnapshotAuxCommon(YamlLoadHelper& yamlLoadHelper, const std::string& card)
3022{
3023 g_uMaxExBanks = 1; // Must be at least 1 (for aux mem) - regardless of Apple2 type!
3024 g_uActiveBank = 0;
3025 _ASSERT(MemGetBankPtr(1, false)); // Ensure there is always aux mem (eg. for CT_80Col or CT_VidHD)
3026
3027 SS_CARDTYPE cardType;
3028 if (card == Card::GetCardNameEmpty())
3029 cardType = CT_Empty;
3030 else if (card == MemGetSnapshotCardName80Col())
3031 cardType = CT_80Col;
3032 else if (card == MemGetSnapshotCardNameExtended80Col())
3033 cardType = CT_Extended80Col;
3034 else if (card == MemGetSnapshotCardNameRamWorksIII() || card == MemGetSnapshotCardNameRamWorksIIIOld())
3035 cardType = CT_RamWorksIII;
3036 else
3037 throw std::runtime_error(SS_YAML_KEY_UNIT ": AuxSlot: Unknown card: " + card);
3038
3039 // "State"
3040 UINT numAuxBanks = 0, activeAuxBank = 0;
3041 if (cardType == CT_Extended80Col || cardType == CT_RamWorksIII)
3042 {
3043 numAuxBanks = yamlLoadHelper.LoadUint(SS_YAML_KEY_NUMAUXBANKS);
3044 activeAuxBank = yamlLoadHelper.LoadUint(SS_YAML_KEY_ACTIVEAUXBANK);
3045 }
3046
3047 if (cardType == CT_Empty)
3048 {
3049 // nothing to do here
3050 }
3051 else if (cardType == CT_80Col)
3052 {
3053 const UINT bank1 = 1;
3054 LPBYTE pBank = MemGetBankPtr(bank1, false);
3055 _ASSERT(pBank);
3056
3057 std::string auxMemName = MemGetSnapshotAuxMemStructName();
3058 if (!yamlLoadHelper.GetSubMap(auxMemName))
3059 throw std::runtime_error("Memory: Missing map name: " + auxMemName);
3060
3061 yamlLoadHelper.LoadMemory(pBank + TEXT_PAGE1_BEGIN, TEXT_PAGE1_SIZE);
3062
3063 yamlLoadHelper.PopMap();
3064 }
3065 else
3066 {
3067 if (cardType == CT_Extended80Col)
3068 {
3069 if (numAuxBanks != 1 || activeAuxBank != 0)
3070 throw std::runtime_error(SS_YAML_KEY_UNIT ": AuxSlot: Bad aux slot card state");
3071 }
3072 else // cardType == CT_RamWorksIII
3073 {
3074 if (numAuxBanks < 2 || numAuxBanks > kMaxExMemoryBanks || (activeAuxBank + 1) > numAuxBanks)
3075 throw std::runtime_error(SS_YAML_KEY_UNIT ": AuxSlot: Bad aux slot card state");
3076 }
3077
3078 g_uMaxExBanks = numAuxBanks;

Callers 2

MemLoadSnapshotAuxVer1Function · 0.85
MemLoadSnapshotAuxVer2Function · 0.85

Calls 7

MemGetBankPtrFunction · 0.85
ByteToHexStrFunction · 0.85
LoadUintMethod · 0.80
LoadMemoryMethod · 0.80
PopMapMethod · 0.80
InsertAuxMethod · 0.80
GetSubMapMethod · 0.45

Tested by

no test coverage detected