mirror of
https://github.com/ksherlock/mpw.git
synced 2025-01-09 13:30:34 +00:00
RM::GetResource stub
This commit is contained in:
parent
5708edd11d
commit
0f7568a2ca
@ -1,4 +1,5 @@
|
||||
#include "rm.h"
|
||||
#include "toolbox.h"
|
||||
|
||||
#include <cpu/defs.h>
|
||||
#include <cpu/CpuModule.h>
|
||||
@ -36,29 +37,21 @@ namespace
|
||||
return sp;
|
||||
}
|
||||
|
||||
uint32_t StackFrame(uint32_t &b, uint16_t &a)
|
||||
{
|
||||
uint32_t sp = cpuGetAReg(7);
|
||||
a = memoryReadWord(sp); sp += 2;
|
||||
b = memoryReadLong(sp); sp += 4;
|
||||
cpuSetAReg(7, sp);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
void ToolReturn(uint32_t sp, uint32_t value)
|
||||
{
|
||||
memoryWriteLong(value, sp);
|
||||
}
|
||||
|
||||
std::string PString(uint32_t address)
|
||||
{
|
||||
std::string s;
|
||||
|
||||
unsigned length = address == 0 ? 0 : memoryReadByte(address++);
|
||||
if (length == 0)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
s.reserve(length);
|
||||
for (unsigned i = 0; i < length; ++i)
|
||||
{
|
||||
s.push_back((char)memoryReadByte(address++));
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -87,11 +80,41 @@ namespace RM
|
||||
|
||||
sp = StackFrame(theType, name);
|
||||
|
||||
std::string sname = PString(name);
|
||||
std::string sname = ToolBox::ReadPString(name);
|
||||
|
||||
fprintf(stderr, "%04x Get1NamedResource(%08x, %s)\n", trap, theType, sname.c_str());
|
||||
|
||||
ToolReturn(sp, (uint32_t)0);
|
||||
return -192;
|
||||
}
|
||||
|
||||
uint16_t GetResource(uint16_t trap)
|
||||
{
|
||||
// GetResource (theType: ResType; theID: Integer): Handle;
|
||||
|
||||
/*
|
||||
* -----------
|
||||
* +6 outHandle
|
||||
* ------------
|
||||
* +2 theType
|
||||
* ------------
|
||||
* +0 theID
|
||||
* ------------
|
||||
*
|
||||
*/
|
||||
|
||||
// nb - return address is not on the stack.
|
||||
|
||||
uint32_t sp;
|
||||
uint32_t theType;
|
||||
uint16_t theID;
|
||||
|
||||
sp = StackFrame(theType, theID);
|
||||
|
||||
fprintf(stderr, "%04x GetResource(%08x, %04x)\n", trap, theType, theID);
|
||||
|
||||
ToolReturn(sp, (uint32_t)0);
|
||||
return -192;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
namespace RM
|
||||
{
|
||||
uint16_t Get1NamedResource(uint16_t trap);
|
||||
|
||||
uint16_t GetResource(uint16_t trap);
|
||||
}
|
||||
|
||||
#endif
|
@ -36,7 +36,7 @@ namespace ToolBox {
|
||||
case 0xa009:
|
||||
d0 = OS::Delete(trap);
|
||||
break;
|
||||
|
||||
|
||||
case 0xA00C:
|
||||
d0 = OS::GetFileInfo(trap);
|
||||
break;
|
||||
@ -78,11 +78,27 @@ namespace ToolBox {
|
||||
d0 = MM::DisposePtr(trap);
|
||||
break;
|
||||
|
||||
// resource manager stuff.
|
||||
|
||||
// Get1NamedResource (theType: ResType; name: Str255) : Handle;
|
||||
case 0xa820:
|
||||
d0 = RM::Get1NamedResource(trap);
|
||||
break;
|
||||
|
||||
// GetResource (theType: ResType; thelD: INTEGER) : Handle;
|
||||
case 0xa9a0:
|
||||
d0 = RM::GetResource(trap);
|
||||
break;
|
||||
|
||||
// quickdraw
|
||||
|
||||
// _ShowCursor();
|
||||
case 0xA853:
|
||||
d0 = 0;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unsupported tool trap: %04x\n", trap);
|
||||
fprintf(stderr, "pc: %08x\n", cpuGetPC());
|
||||
|
Loading…
x
Reference in New Issue
Block a user