GetString (mpw C)

This commit is contained in:
Kelvin Sherlock 2013-03-26 23:54:28 -04:00
parent a95efd9e3f
commit 18fa1a760a
2 changed files with 30 additions and 0 deletions

View File

@ -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);

View File

@ -1,6 +1,7 @@
#include "utility.h"
#include "toolbox.h"
#include "mm.h"
#include "rm.h"
#include <cpu/defs.h>
#include <cpu/CpuModule.h>
@ -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;
}
}