From 91e142446be56f11c79f6ccb5e3eb3de7274eda2 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 14 Dec 2014 19:51:49 -0500 Subject: [PATCH] MM::PurgeSpace call --- toolbox/mm.cpp | 16 ++++++++++++++++ toolbox/mm.h | 1 + toolbox/toolbox.cpp | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/toolbox/mm.cpp b/toolbox/mm.cpp index 51ee9ed..d7ff43d 100644 --- a/toolbox/mm.cpp +++ b/toolbox/mm.cpp @@ -1469,4 +1469,20 @@ namespace MM return 0; } + uint32_t PurgeSpace(uint16_t trap) + { + // PROCEDURE PurgeSpace (VAR total: LongInt; VAR contig: LongInt); + + /* + * Registers on exit: + * A0 Maximum number of contiguous bytes after purge + * D0 Total free memory after purge + */ + + Log("%04x PurgeSpace()\n", trap); + + SetMemError(0); + cpuSetAReg(0, mplite_maxmem(&pool)); + return mplite_freemem(&pool); + } } diff --git a/toolbox/mm.h b/toolbox/mm.h index 2961e66..725b3fd 100644 --- a/toolbox/mm.h +++ b/toolbox/mm.h @@ -41,6 +41,7 @@ namespace MM uint32_t MaxBlock(uint16_t trap); uint32_t FreeMem(uint16_t trap); uint16_t ReserveMem(uint16_t trap); + uint32_t PurgeSpace(uint16_t trap); uint16_t DisposeHandle(uint16_t trap); diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index e5b4ee1..fe7657f 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -263,6 +263,10 @@ namespace ToolBox { d0 = MM::MaxApplZone(trap); break; + case 0xa162: + d0 = MM::PurgeSpace(trap); + break; + // ReadDateTime (VAR sees: LONGINT) : OSErr; case 0xa039: d0 = OS::ReadDateTime(trap);