mirror of
https://github.com/ksherlock/mpw.git
synced 2025-02-13 09:31:25 +00:00
MWDump68K support
- DATA and TEXT resource types - HGetFileInfo - use directory id - PtrAndHand tool call
This commit is contained in:
parent
806a4b7eaf
commit
ac66233f40
@ -1265,7 +1265,7 @@ namespace MM
|
|||||||
* A0 destination Handle
|
* A0 destination Handle
|
||||||
* D0 Result code
|
* D0 Result code
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint32_t srcHandle = cpuGetAReg(0);
|
uint32_t srcHandle = cpuGetAReg(0);
|
||||||
|
|
||||||
@ -1303,7 +1303,7 @@ namespace MM
|
|||||||
* A0 destination pointer
|
* A0 destination pointer
|
||||||
* D0 Result code
|
* D0 Result code
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint32_t mcptr = cpuGetAReg(0);
|
uint32_t mcptr = cpuGetAReg(0);
|
||||||
uint32_t size = cpuGetDReg(0);
|
uint32_t size = cpuGetDReg(0);
|
||||||
@ -1322,6 +1322,53 @@ namespace MM
|
|||||||
return d0; // SetMemError called by Native::NewHandle.
|
return d0; // SetMemError called by Native::NewHandle.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t PtrAndHand(uint16_t trap)
|
||||||
|
{
|
||||||
|
// FUNCTION PtrAndHand (pntr: Ptr; hndl: Handle; size: LongInt): OSErr;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* on entry:
|
||||||
|
* A0 source Pointer
|
||||||
|
* A1 dest Handle
|
||||||
|
* D0 number of bytes to concatenate
|
||||||
|
*
|
||||||
|
* on exit:
|
||||||
|
* A0 destination Handle
|
||||||
|
* D0 Result code
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint32_t ptr = cpuGetAReg(0);
|
||||||
|
uint32_t handle = cpuGetAReg(1);
|
||||||
|
uint32_t size = cpuGetDReg(0);
|
||||||
|
|
||||||
|
Log("%04x PtrAndHand(%08x, %08x, %08x)\n", trap, ptr, handle, size);
|
||||||
|
|
||||||
|
cpuSetAReg(0, handle);
|
||||||
|
|
||||||
|
uint32_t oldSize = 0;
|
||||||
|
uint32_t d0;
|
||||||
|
|
||||||
|
d0 = Native::GetHandleSize(handle, oldSize);
|
||||||
|
if (d0) return d0;
|
||||||
|
|
||||||
|
if ((uint64_t)oldSize + (uint64_t)size > UINT32_MAX)
|
||||||
|
return SetMemError(MacOS::memFullErr);
|
||||||
|
|
||||||
|
|
||||||
|
d0 = Native::SetHandleSize(handle, oldSize + size);
|
||||||
|
if (d0) return d0;
|
||||||
|
|
||||||
|
auto iter = HandleMap.find(handle);
|
||||||
|
if (iter == HandleMap.end())
|
||||||
|
return SetMemError(MacOS::memWZErr);
|
||||||
|
|
||||||
|
auto const info = iter->second;
|
||||||
|
|
||||||
|
std::memmove(memoryPointer(info.address + oldSize), memoryPointer(ptr), size);
|
||||||
|
|
||||||
|
return SetMemError(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
#include "os_internal.h"
|
#include "os_internal.h"
|
||||||
#include "toolbox.h"
|
#include "toolbox.h"
|
||||||
#include "stackframe.h"
|
#include "stackframe.h"
|
||||||
|
#include "fs_spec.h"
|
||||||
|
|
||||||
|
|
||||||
using ToolBox::Log;
|
using ToolBox::Log;
|
||||||
@ -115,6 +116,8 @@ namespace OS {
|
|||||||
_ioFlRPyLen = 68,
|
_ioFlRPyLen = 68,
|
||||||
_ioFlCrDat = 72,
|
_ioFlCrDat = 72,
|
||||||
_ioFlMdDat = 76,
|
_ioFlMdDat = 76,
|
||||||
|
|
||||||
|
_ioDirID = 48,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -145,11 +148,15 @@ namespace OS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sname = ToolBox::ReadPString(ioNamePtr, true);
|
sname = ToolBox::ReadPString(ioNamePtr, true);
|
||||||
|
// a20c HGetFileInfo uses a the dir id
|
||||||
|
if (trap == 0xa20c)
|
||||||
|
{
|
||||||
|
uint32_t ioDirID = memoryReadLong(parm + _ioDirID);
|
||||||
|
sname = FSSpecManager::ExpandPath(sname, ioDirID);
|
||||||
|
}
|
||||||
|
|
||||||
Log(" GetFileInfo(%s)\n", sname.c_str());
|
Log(" GetFileInfo(%s)\n", sname.c_str());
|
||||||
|
|
||||||
// todo -- how are absolute, relative, etc paths handled...
|
|
||||||
|
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
@ -237,6 +244,8 @@ namespace OS {
|
|||||||
_ioFlRPyLen = 68,
|
_ioFlRPyLen = 68,
|
||||||
_ioFlCrDat = 72,
|
_ioFlCrDat = 72,
|
||||||
_ioFlMdDat = 76,
|
_ioFlMdDat = 76,
|
||||||
|
|
||||||
|
_ioDirID = 48,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -254,13 +263,6 @@ namespace OS {
|
|||||||
//uint8_t ioFVersNum = memoryReadByte(parm + _ioFVersNum);
|
//uint8_t ioFVersNum = memoryReadByte(parm + _ioFVersNum);
|
||||||
//int16_t ioFDirIndex = memoryReadWord(parm + _ioFDirIndex);
|
//int16_t ioFDirIndex = memoryReadWord(parm + _ioFDirIndex);
|
||||||
|
|
||||||
// + 32 = finder data - 16 bytes.
|
|
||||||
|
|
||||||
//uint32_t ioFlCrDat = memoryReadLong(parm + 72);
|
|
||||||
//uint32_t ioFlMdDat = memoryReadLong(parm + 76);
|
|
||||||
|
|
||||||
// currently, only sets finder info.
|
|
||||||
|
|
||||||
if (!ioNamePtr)
|
if (!ioNamePtr)
|
||||||
{
|
{
|
||||||
d0 = MacOS::bdNamErr;
|
d0 = MacOS::bdNamErr;
|
||||||
@ -269,8 +271,19 @@ namespace OS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sname = ToolBox::ReadPString(ioNamePtr, true);
|
sname = ToolBox::ReadPString(ioNamePtr, true);
|
||||||
|
|
||||||
|
// a20d HSetFileInfo uses a the dir id
|
||||||
|
if (trap == 0xa20d)
|
||||||
|
{
|
||||||
|
uint32_t ioDirID = memoryReadLong(parm + _ioDirID);
|
||||||
|
sname = FSSpecManager::ExpandPath(sname, ioDirID);
|
||||||
|
}
|
||||||
|
|
||||||
Log(" SetFileInfo(%s)\n", sname.c_str());
|
Log(" SetFileInfo(%s)\n", sname.c_str());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// check if the file actually exists
|
// check if the file actually exists
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
@ -108,6 +108,8 @@ namespace
|
|||||||
case 0x4b4f4445: // 'KODE' (Link 32-bit Startup)
|
case 0x4b4f4445: // 'KODE' (Link 32-bit Startup)
|
||||||
case 0x45525253: // 'ERRS' (PPCLink)
|
case 0x45525253: // 'ERRS' (PPCLink)
|
||||||
case 0x63667267: // 'cfrg' (PPCLink)
|
case 0x63667267: // 'cfrg' (PPCLink)
|
||||||
|
case 0x44415441: // 'DATA' (MetroWorks tools)
|
||||||
|
case 0x54455854: // 'TEXT' (MetroWorks tools)
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -289,7 +289,10 @@ namespace ToolBox {
|
|||||||
case 0xa9e3:
|
case 0xa9e3:
|
||||||
d0 = MM::PtrToHand(trap);
|
d0 = MM::PtrToHand(trap);
|
||||||
break;
|
break;
|
||||||
|
case 0xa9ef:
|
||||||
|
d0 = MM::PtrAndHand(trap);
|
||||||
|
break;
|
||||||
|
|
||||||
case 0xa11a:
|
case 0xa11a:
|
||||||
d0 = MM::GetZone(trap);
|
d0 = MM::GetZone(trap);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user