set memory error (0x0220 global page)

This commit is contained in:
Kelvin Sherlock 2013-02-07 23:45:29 -05:00
parent 9687f1c387
commit 5f0e1c7ff3

View File

@ -27,6 +27,12 @@ namespace
// map of handle -> size [? just use Ptr map?] // map of handle -> size [? just use Ptr map?]
std::map<uint32_t, uint32_t> HandleMap; std::map<uint32_t, uint32_t> HandleMap;
inline uint16_t SetMemError(uint16_t error)
{
memoryWriteWord(error, 0x0220);
return error;
}
bool alloc_handle_block() bool alloc_handle_block()
{ {
const unsigned HandleCount = 128; const unsigned HandleCount = 128;
@ -135,7 +141,7 @@ namespace MM
if (size == 0) if (size == 0)
{ {
cpuSetAReg(0, 0); cpuSetAReg(0, 0);
return 0; return SetMemError(0);
} }
uint8_t *ptr = NULL; uint8_t *ptr = NULL;
@ -143,7 +149,7 @@ namespace MM
if (!ptr) if (!ptr)
{ {
cpuSetAReg(0, 0); cpuSetAReg(0, 0);
return memFullErr; return SetMemError(memFullErr);
} }
if (clear) if (clear)
@ -154,7 +160,7 @@ namespace MM
uint32_t mcptr = ptr - Memory; uint32_t mcptr = ptr - Memory;
PtrMap.emplace(std::make_pair(mcptr, size)); PtrMap.emplace(std::make_pair(mcptr, size));
cpuSetAReg(0, mcptr); cpuSetAReg(0, mcptr);
return 0; return SetMemError(0);
} }