toolbox updates

This commit is contained in:
Kelvin Sherlock 2013-02-07 22:12:30 -05:00
parent 0d594d9e31
commit b6aa07a012
6 changed files with 72 additions and 4 deletions

View File

@ -7,6 +7,7 @@ add_definitions(-I ${CMAKE_SOURCE_DIR}/)
set(TOOLBOX_SRC
toolbox.cpp
rm.cpp
mm.cpp
)

40
toolbox/mm.cpp Normal file
View File

@ -0,0 +1,40 @@
#include "mm.h"
#include <cpu/defs.h>
#include <cpu/CpuModule.h>
#include <cpu/fmem.h>
#include <string>
#include <mplite/mplite.h>
namespace
{
mplite_t pool;
}
namespace MM
{
uint16_t NewPtr(uint16_t trap)
{
/* on entry:
* A0 Number of logical bytes requested
* on exit:
* A0 Address of the new block or NIL
* D0 Result code
*/
bool clear = trap & (1 << 9);
bool sys = trap & (1 << 10);
uint32_t size = cpuGetAReg(0);
fprintf(stderr, "%04x NewPtr(%08x)\n", trap, size);
cpuSetAReg(0, 0);
return memFullErr;
}
}

16
toolbox/mm.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef __mpw_rm_h__
#define __mpw_rm_h__
#include <cstdint>
namespace MM
{
enum
{
memFullErr = -108
}
uint16_t NewPtr(uint16_t trap);
}
#endif

View File

@ -64,7 +64,7 @@ namespace
namespace RM
{
uint16_t Get1NamedResource()
uint16_t Get1NamedResource(uint16_t trap)
{
// Get1NamedResource (theType: ResType; name: Str255) : Handle;
@ -89,7 +89,7 @@ namespace RM
std::string sname = PString(name);
fprintf(stderr, "Get1NamedResource(%08x, %s)\n", theType, sname.c_str());
fprintf(stderr, "%04x Get1NamedResource(%08x, %s)\n", trap, theType, sname.c_str());
ToolReturn(sp, (uint32_t)0);
return -192;

View File

@ -5,7 +5,7 @@
namespace RM
{
uint16_t Get1NamedResource();
uint16_t Get1NamedResource(uint16_t trap);
}
#endif

View File

@ -22,9 +22,20 @@ namespace ToolBox {
switch (trap)
{
// NewPtr [Sys, Clear] (logicalSize: Size): Ptr;
case 0xa11e:
case 0xa31e:
case 0xa51e:
case 0xa71e:
// clear = bit 9, sys = bit 10
d0 = MM:NewPtr(trap);
break;
// Get1NamedResource (theType: ResType; name: Str255) : Handle;
case 0xa820:
d0 = RM::Get1NamedResource();
d0 = RM::Get1NamedResource(trap);
break;
default: