DisposePtr

This commit is contained in:
Kelvin Sherlock 2013-02-10 20:19:11 -05:00
parent ce832bca76
commit c5626a0fc4
2 changed files with 32 additions and 1 deletions

View File

@ -114,6 +114,35 @@ namespace MM
return 0;
}
uint16_t DisposePtr(uint16_t trap)
{
/*
* on entry:
* A0 Pointer to the nonrelocatable block to be disposed of
*
* on exit:
* D0 Result code
*
*/
uint32_t mcptr = cpuGetAReg(0);
fprintf(stderr, "%04x DisposePtr(%08x)\n", trap, mcptr);
auto iter = PtrMap.find(mcptr);
if (iter == PtrMap.end()) return memWZErr;
PtrMap.erase(iter);
uint8_t *ptr = mcptr + Memory;
mplite_free(&pool, ptr);
return 0;
}
uint16_t NewPtr(uint16_t trap)
{

View File

@ -7,12 +7,14 @@ namespace MM
{
enum
{
memFullErr = -108
memFullErr = -108,
memWZErr = -111,
};
bool Init(uint8_t *memory, uint32_t memorySize, uint32_t reserved);
uint16_t BlockMove(uint16_t trap);
uint16_t DisposePtr(uint16_t trap);
uint16_t NewPtr(uint16_t trap);
}