diff --git a/toolbox/mm.cpp b/toolbox/mm.cpp index 4998880..5fe8e57 100644 --- a/toolbox/mm.cpp +++ b/toolbox/mm.cpp @@ -140,7 +140,7 @@ namespace MM uint32_t cbNeeded = cpuGetDReg(0); fprintf(stderr, "%04x CompactMem(%08x)\n", trap, cbNeeded); - + return 0x0f0000; } @@ -257,6 +257,38 @@ namespace MM 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) { /* diff --git a/toolbox/mm.h b/toolbox/mm.h index 88870ff..e0cd7a5 100644 --- a/toolbox/mm.h +++ b/toolbox/mm.h @@ -20,6 +20,9 @@ namespace MM uint16_t NewPtr(uint16_t trap); uint16_t NewHandle(uint16_t trap); + + uint16_t SetPtrSize(uint16_t); + uint16_t SetHandleSize(uint16_t); } diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index f31b900..6e01741 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -49,6 +49,11 @@ namespace ToolBox { d0 = OS::GetVol(trap); break; + // SetPtrSize (p: Ptr; newSize: Size); + case 0xa020: + d0 = MM::SetPtrSize(trap); + break; + case 0xA023: d0 = MM::DisposeHandle(trap); break;