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

Function ParseSlots

source/SaveState.cpp:303–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301//---
302
303static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
304{
305 if (unitVersion != UNIT_SLOTS_VER)
306 throw std::runtime_error(SS_YAML_KEY_UNIT ": Slots: Version mismatch");
307
308 while (1)
309 {
310 std::string scalar = yamlLoadHelper.GetMapNextSlotNumber();
311 if (scalar.empty())
312 break; // done all slots
313
314 const int slot = strtoul(scalar.c_str(), NULL, 10); // NB. aux slot supported as a different "unit"
315 // NB. slot-0 only supported for Apple II or II+ (or similar clones)
316 if (slot < SLOT0 || slot > SLOT7)
317 throw std::runtime_error("Slots: Invalid slot #: " + scalar);
318
319 yamlLoadHelper.GetSubMap(scalar);
320
321 std::string card = yamlLoadHelper.LoadString(SS_YAML_KEY_CARD);
322 UINT cardVersion = yamlLoadHelper.LoadUint(SS_YAML_KEY_VERSION);
323
324 if (!yamlLoadHelper.GetSubMap(std::string(SS_YAML_KEY_STATE), true)) // NB. For some cards, State can be null
325 throw std::runtime_error(SS_YAML_KEY_UNIT ": Expected sub-map name: " SS_YAML_KEY_STATE);
326
327 SS_CARDTYPE type = Card::GetCardType(card);
328 bool bRes = false;
329
330 if (slot == SLOT0)
331 {
332 SetExpansionMemType(type); // calls GetCardMgr().Insert() & InsertAux()
333 }
334 else
335 {
336 GetCardMgr().Insert(slot, type);
337 }
338
339 bRes = GetCardMgr().GetRef(slot).LoadSnapshot(yamlLoadHelper, cardVersion);
340
341 yamlLoadHelper.PopMap();
342 yamlLoadHelper.PopMap();
343 }
344
345}
346
347//---
348

Callers 1

ParseUnitFunction · 0.85

Calls 8

SetExpansionMemTypeFunction · 0.85
GetMapNextSlotNumberMethod · 0.80
LoadStringMethod · 0.80
LoadUintMethod · 0.80
PopMapMethod · 0.80
GetSubMapMethod · 0.45
InsertMethod · 0.45
LoadSnapshotMethod · 0.45

Tested by

no test coverage detected