mpw/toolbox/toolbox.cpp

57 lines
1.0 KiB
C++
Raw Normal View History

2013-02-08 00:21:47 +00:00
#include <cstdio>
#include <cstdint>
#include <stdlib.h>
#include <cpu/defs.h>
#include <cpu/CpuModule.h>
#include <cpu/fmem.h>
#include "toolbox.h"
#include "rm.h"
2013-02-08 03:49:04 +00:00
#include "mm.h"
2013-02-08 00:21:47 +00:00
// yuck. TST.W d0
extern "C" void cpuSetFlagsNZ00NewW(UWO res);
namespace ToolBox {
void dispatch(uint16_t trap)
{
// todo -- check/remove extra bits for save a0, toolglue, etc.
uint32_t d0 = 0;
switch (trap)
{
2013-02-08 04:44:58 +00:00
// BlockMove (sourcePtr,destPtr: Ptr; byteCount: Size);
case 0xa02e:
d0 = MM::BlockMove(trap);
break;
2013-02-08 03:12:30 +00:00
// NewPtr [Sys, Clear] (logicalSize: Size): Ptr;
case 0xa11e:
case 0xa31e:
case 0xa51e:
case 0xa71e:
// clear = bit 9, sys = bit 10
2013-02-08 03:49:04 +00:00
d0 = MM::NewPtr(trap);
2013-02-08 03:12:30 +00:00
break;
2013-02-08 00:21:47 +00:00
// Get1NamedResource (theType: ResType; name: Str255) : Handle;
case 0xa820:
2013-02-08 03:12:30 +00:00
d0 = RM::Get1NamedResource(trap);
2013-02-08 00:21:47 +00:00
break;
default:
fprintf(stderr, "Unsupported tool trap: %04x\n", trap);
fprintf(stderr, "pc: %08x\n", cpuGetPC());
exit(255);
}
cpuSetDReg(0, d0);
cpuSetFlagsNZ00NewW(d0);
}
}