HandToHand (Pascal)

This commit is contained in:
Kelvin Sherlock 2013-07-13 19:19:49 -04:00
parent 68a70cfcbc
commit 7f59b64aad
2 changed files with 45 additions and 0 deletions

View File

@ -999,6 +999,44 @@ namespace MM
#pragma mark - OS Utility Routines
uint16_t HandToHand(uint16_t trap)
{
/*
* on entry:
* A0 source Handle
*
* on exit:
* A0 destination Handle
* D0 Result code
*
*/
uint32_t srcHandle = cpuGetAReg(0);
Log("%04x HandToHand(%08x)\n", trap, srcHandle);
auto iter = HandleMap.find(srcHandle);
if (iter == HandleMap.end())
return SetMemError(MacOS::memWZErr);
auto const info = iter->second;
uint32_t destHandle;
uint32_t destPtr;
uint32_t d0 = Native::NewHandle(info.size, false, destHandle, destPtr);
if (d0 == 0)
{
std::memmove(memoryPointer(destPtr), memoryPointer(info.address), info.size);
}
cpuSetAReg(0, destHandle);
return d0; // SetMemError called by Native::NewHandle.
}
uint16_t PtrToHand(uint16_t trap)
{
/*
@ -1030,6 +1068,9 @@ namespace MM
}
#pragma mark -
uint32_t StripAddress(uint16_t trap)
{

View File

@ -200,6 +200,10 @@ namespace ToolBox {
d0 = MM::MoveHHi(trap);
break;
case 0xa9e1:
d0 = MM::HandToHand(trap);
break;
case 0xa9e3:
d0 = MM::PtrToHand(trap);
break;