PtrToHand

This commit is contained in:
Kelvin Sherlock 2013-02-26 18:32:39 -05:00
parent 6bc34f2085
commit df66ea44b3
3 changed files with 44 additions and 2 deletions

View File

@ -369,7 +369,7 @@ namespace MM
uint32_t mcptr = cpuGetAReg(0);
Log("%08x GetPtrSize(%08x,)\n", trap, mcptr);
Log("%08x GetPtrSize(%08x)\n", trap, mcptr);
auto iter = PtrMap.find(mcptr);
@ -474,7 +474,7 @@ namespace MM
uint32_t hh = cpuGetAReg(0);
Log("%08x GetHandleSize(%08x,)\n", trap, hh);
Log("%08x GetHandleSize(%08x)\n", trap, hh);
auto iter = HandleMap.find(hh);
@ -648,6 +648,38 @@ namespace MM
return 0;
}
#pragma mark - OS Utility Routines
uint16_t PtrToHand(uint16_t trap)
{
/*
* on entry:
* A0 source Pointer
* D0 size
*
* on exit:
* A0 destination pointer
* D0 Result code
*
*/
uint32_t mcptr = cpuGetAReg(0);
uint32_t size = cpuGetDReg(0);
Log("%04x PtrToHand(%08x, %08x)\n", trap, mcptr, size);
uint32_t destHandle;
uint32_t destPtr;
uint32_t d0 = Native::NewHandle(size, false, destHandle, destPtr);
if (d0 == 0)
{
std::memmove(memoryPointer(destPtr), memoryPointer(mcptr), size);
}
cpuSetAReg(0, destHandle);
return d0;
}
#pragma mark -
uint32_t StripAddress(uint16_t trap)

View File

@ -48,6 +48,13 @@ namespace MM
uint32_t StripAddress(uint16_t trap);
// operating system utility routines
uint16_t HandAndHand(uint16_t trap);
uint16_t HandToHand(uint16_t trap);
uint16_t PtrAndHand(uint16_t trap);
uint16_t PtrToHand(uint16_t trap);
uint16_t PtrToXHand(uint16_t trap);
}

View File

@ -118,6 +118,9 @@ namespace ToolBox {
d0 = MM::MoveHHi(trap);
break;
case 0xa9e3:
d0 = MM::PtrToHand(trap);
// ReadDateTime (VAR sees: LONGINT) : OSErr;
case 0xa039:
d0 = OS::ReadDateTime(trap);