MM::SetPtrSize

This commit is contained in:
Kelvin Sherlock 2013-02-15 20:33:00 -05:00
parent 461989baee
commit a14cd5eb5d
3 changed files with 41 additions and 1 deletions

View File

@ -257,6 +257,38 @@ namespace MM
return SetMemError(0); return SetMemError(0);
} }
uint16_t SetPtrSize(uint16_t trap)
{
/*
* on entry:
* A0 pointer
* D0 new size
*
* on exit:
* D0 Result code
*
*/
uint32_t mcptr = cpuGetAReg(0);
uint32_t newSize = cpuGetDReg(0);
fprintf(stderr, "%08x SetPtrSize(%08x, %08x)\n", trap, mcptr, newSize);
auto iter = PtrMap.find(mcptr);
if (iter == PtrMap.end()) return SetMemError(memWZErr);
PtrMap.erase(iter);
uint8_t *ptr = mcptr + Memory;
if (mplite_resize(&pool, ptr, newSize) < 0)
{
return SetMemError(memFullErr);
}
return SetMemError(0);
}
uint16_t NewHandle(uint16_t trap) uint16_t NewHandle(uint16_t trap)
{ {
/* /*

View File

@ -20,6 +20,9 @@ namespace MM
uint16_t NewPtr(uint16_t trap); uint16_t NewPtr(uint16_t trap);
uint16_t NewHandle(uint16_t trap); uint16_t NewHandle(uint16_t trap);
uint16_t SetPtrSize(uint16_t);
uint16_t SetHandleSize(uint16_t);
} }

View File

@ -49,6 +49,11 @@ namespace ToolBox {
d0 = OS::GetVol(trap); d0 = OS::GetVol(trap);
break; break;
// SetPtrSize (p: Ptr; newSize: Size);
case 0xa020:
d0 = MM::SetPtrSize(trap);
break;
case 0xA023: case 0xA023:
d0 = MM::DisposeHandle(trap); d0 = MM::DisposeHandle(trap);
break; break;