diff --git a/toolbox/CMakeLists.txt b/toolbox/CMakeLists.txt index 78ab8f4..dafbd9c 100644 --- a/toolbox/CMakeLists.txt +++ b/toolbox/CMakeLists.txt @@ -7,6 +7,7 @@ add_definitions(-I ${CMAKE_SOURCE_DIR}/) set(TOOLBOX_SRC toolbox.cpp rm.cpp + mm.cpp ) diff --git a/toolbox/mm.cpp b/toolbox/mm.cpp new file mode 100644 index 0000000..3de24c1 --- /dev/null +++ b/toolbox/mm.cpp @@ -0,0 +1,40 @@ +#include "mm.h" + +#include +#include +#include + +#include + +#include + +namespace +{ + mplite_t pool; +} + +namespace MM +{ + + uint16_t NewPtr(uint16_t trap) + { + /* on entry: + * A0 Number of logical bytes requested + * on exit: + * A0 Address of the new block or NIL + * D0 Result code + */ + + bool clear = trap & (1 << 9); + bool sys = trap & (1 << 10); + + uint32_t size = cpuGetAReg(0); + + fprintf(stderr, "%04x NewPtr(%08x)\n", trap, size); + + cpuSetAReg(0, 0); + return memFullErr; + } + + +} \ No newline at end of file diff --git a/toolbox/mm.h b/toolbox/mm.h new file mode 100644 index 0000000..c50f8f6 --- /dev/null +++ b/toolbox/mm.h @@ -0,0 +1,16 @@ +#ifndef __mpw_rm_h__ +#define __mpw_rm_h__ + +#include + +namespace MM +{ + enum + { + memFullErr = -108 + } + + uint16_t NewPtr(uint16_t trap); +} + +#endif \ No newline at end of file diff --git a/toolbox/rm.cpp b/toolbox/rm.cpp index b291c7c..534b7cf 100644 --- a/toolbox/rm.cpp +++ b/toolbox/rm.cpp @@ -64,7 +64,7 @@ namespace namespace RM { - uint16_t Get1NamedResource() + uint16_t Get1NamedResource(uint16_t trap) { // Get1NamedResource (theType: ResType; name: Str255) : Handle; @@ -89,7 +89,7 @@ namespace RM std::string sname = PString(name); - fprintf(stderr, "Get1NamedResource(%08x, %s)\n", theType, sname.c_str()); + fprintf(stderr, "%04x Get1NamedResource(%08x, %s)\n", trap, theType, sname.c_str()); ToolReturn(sp, (uint32_t)0); return -192; diff --git a/toolbox/rm.h b/toolbox/rm.h index 7c996d7..92c342f 100644 --- a/toolbox/rm.h +++ b/toolbox/rm.h @@ -5,7 +5,7 @@ namespace RM { - uint16_t Get1NamedResource(); + uint16_t Get1NamedResource(uint16_t trap); } #endif \ No newline at end of file diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index 9cbe5d5..a572de0 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -22,9 +22,20 @@ namespace ToolBox { switch (trap) { + // NewPtr [Sys, Clear] (logicalSize: Size): Ptr; + case 0xa11e: + case 0xa31e: + case 0xa51e: + case 0xa71e: + // clear = bit 9, sys = bit 10 + d0 = MM:NewPtr(trap); + break; + + + // Get1NamedResource (theType: ResType; name: Str255) : Handle; case 0xa820: - d0 = RM::Get1NamedResource(); + d0 = RM::Get1NamedResource(trap); break; default: