| 301 | //--- |
| 302 | |
| 303 | static 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 |
no test coverage detected