From 231e34627d1f36fceecdddb56c92d34d8c339f46 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sat, 30 Mar 2013 18:45:20 -0400 Subject: [PATCH] MM::MaxMem / MM::FreeMem (68k Pascal) --- toolbox/mm.cpp | 39 +++++++++++++++++++++++++++++++++++++-- toolbox/mm.h | 4 +++- toolbox/toolbox.cpp | 8 ++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/toolbox/mm.cpp b/toolbox/mm.cpp index 38d90b4..aad4d28 100644 --- a/toolbox/mm.cpp +++ b/toolbox/mm.cpp @@ -270,10 +270,45 @@ namespace MM Log("%04x CompactMem(%08x)\n", trap, cbNeeded); - // todo -- add mplite call to return total free mem, largest block. - return 0x0f0000; + + return mplite_maxmem(&pool); } + uint32_t MaxMem(uint16_t trap) + { + // return largest contiguous free block size. + /* + * on entry: + * (nothing) + * + * on exit: + * D0: function result (long word) + * + */ + + Log("%04x MaxMem()\n", trap); + + return mplite_maxmem(&pool); + } + + uint32_t FreeMem(uint16_t trap) + { + // total free memory. + /* + * on entry: + * (nothing) + * + * on exit: + * D0: function result (long word) + * + */ + + Log("%04x FreeMem()\n", trap); + + return mplite_freemem(&pool); + } + + uint16_t MoveHHi(uint16_t trap) { /* diff --git a/toolbox/mm.h b/toolbox/mm.h index 538eaf2..d3e3839 100644 --- a/toolbox/mm.h +++ b/toolbox/mm.h @@ -26,7 +26,9 @@ namespace MM uint16_t BlockMove(uint16_t trap); uint32_t CompactMem(uint16_t trap); - + uint32_t MaxMem(uint16_t trap); + uint32_t FreeMem(uint16_t trap); + uint16_t DisposeHandle(uint16_t trap); uint16_t DisposePtr(uint16_t trap); diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index 671ba09..011431f 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -128,6 +128,14 @@ namespace ToolBox { d0 = MM::HPurge(trap); break; + case 0xA11D: + d0 = MM::MaxMem(trap); + break; + + case 0xA01C: + d0 = MM::FreeMem(trap); + break; + // CompactMem (cbNeeded: Size) : Size; case 0xa04c: d0 = MM::CompactMem(trap);