diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index 471dc82..ea8acb1 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -286,6 +286,9 @@ namespace ToolBox { case 0xa906: d0 = Utility::NewString(trap); break; + case 0xa9ba: + d0 = Utility::GetString(trap); + break; default: fprintf(stderr, "Unsupported tool trap: %04x\n", trap); diff --git a/toolbox/utility.cpp b/toolbox/utility.cpp index e2efab4..0277808 100644 --- a/toolbox/utility.cpp +++ b/toolbox/utility.cpp @@ -1,6 +1,7 @@ #include "utility.h" #include "toolbox.h" #include "mm.h" +#include "rm.h" #include #include @@ -13,6 +14,7 @@ using ToolBox::Log; namespace Utility { + // FUNCTION NewString (theString: Str255): StringHandle; uint16_t NewString(uint16_t trap) { /* @@ -51,5 +53,30 @@ namespace Utility { return d0; } + // FUNCTION GetString (stringID: Integer): StringHandle; + uint16_t GetString(uint16_t trap) + { + /* + * The GetString function loads a string from a string ('STR ') + * resource into memory. It returns a handle to the string with the + * specified resource ID, reading it from the resource file if + * necessary. + */ + + uint16_t stringID; + uint32_t sp; + uint32_t d0; + uint32_t theHandle; + + sp = StackFrame<2>(stringID); + + Log("%04x GetString($%04x)\n", trap, stringID); + + d0 = RM::Native::GetResource(0x53545220, stringID, theHandle); + + ToolReturn<4>(sp, theHandle); + return d0; + } + }