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

Method LoadMemory

source/YamlHelper.cpp:275–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275UINT YamlHelper::LoadMemory(MapYaml& mapYaml, const LPBYTE pMemBase, const size_t kAddrSpaceSize, const UINT offset)
276{
277 UINT bytes = 0;
278
279 for (MapYaml::iterator it = mapYaml.begin(); it != mapYaml.end(); ++it)
280 {
281 const char* pKey = it->first.c_str();
282 UINT addr = strtoul(pKey, NULL, 16);
283 if (addr >= (kAddrSpaceSize + offset))
284 throw std::runtime_error("Memory: line address too big: " + it->first);
285
286 LPBYTE pDst = (LPBYTE) (pMemBase + addr);
287 const LPBYTE pDstEnd = (LPBYTE) (pMemBase + kAddrSpaceSize + offset);
288
289 if (it->second.subMap)
290 throw std::runtime_error("Memory: unexpected sub-map");
291
292 const char* pValue = it->second.value.c_str();
293 size_t len = strlen(pValue);
294 if (len & 1)
295 throw std::runtime_error("Memory: hex data must be an even number of nibbles on line address: " + it->first);
296
297 for (UINT i = 0; i<len; i+=2)
298 {
299 if (pDst >= pDstEnd)
300 throw std::runtime_error("Memory: hex data overflowed address space on line address: " + it->first);
301
302 BYTE ah = m_AsciiToHex[ (BYTE)(*pValue++) ];
303 BYTE al = m_AsciiToHex[ (BYTE)(*pValue++) ];
304 if ((ah | al) & 0x80)
305 throw std::runtime_error("Memory: hex data contains illegal character on line address: " + it->first);
306
307 *pDst++ = (ah<<4) | al;
308 bytes++;
309 }
310 }
311
312 mapYaml.clear();
313
314 return bytes;
315}
316
317//-------------------------------------
318

Callers 10

LoadSnapshotMethod · 0.80
MemLoadSnapshotFunction · 0.80
MemLoadSnapshotAuxCommonFunction · 0.80
LoadSnapshotMethod · 0.80
LoadSnapshotFloppyMethod · 0.80
LoadSnapshotMethod · 0.80
LoadSnapshotMethod · 0.80
LoadSnapshotHDDUnitMethod · 0.80
LoadSnapshotMethod · 0.80
LoadSnapshotMethod · 0.80

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected