clean up trailing whitespace / end of file linefeed.

This commit is contained in:
Kelvin Sherlock 2015-02-18 09:32:01 -05:00
parent ac4506b52e
commit 2766493398
57 changed files with 630 additions and 644 deletions

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -100,6 +100,3 @@ void ToolMap::remove(uint16_t tool)
map.erase(tool);
}

View File

@ -58,7 +58,7 @@ public:
{
return map.end();
}
size_t size()
{
return map.size();
@ -69,4 +69,4 @@ private:
};
#endif
#endif

View File

@ -29,16 +29,16 @@ namespace Debug {
char buffer2[16 + 1];
ssize_t offset = 0;
unsigned i, j;
while(size > 0)
{
{
std::memset(buffer1, ' ', sizeof(buffer1));
std::memset(buffer2, ' ', sizeof(buffer2));
unsigned linelen = (unsigned)std::min(size, (ssize_t)16);
for (i = 0, j = 0; i < linelen; i++)
{
unsigned x = data[i];
@ -46,16 +46,16 @@ namespace Debug {
buffer1[j++] = HexMap[x & 0x0f];
j++;
if (i == 7) j++;
// isascii not part of std:: and may be a macro.
buffer2[i] = isascii(x) && std::isprint(x) ? x : '.';
}
buffer1[sizeof(buffer1)-1] = 0;
buffer2[sizeof(buffer2)-1] = 0;
std::printf("%06x: %s %s\n", address + (unsigned)offset, buffer1, buffer2);
offset += 16;
data += 16;
@ -76,7 +76,7 @@ namespace Debug {
if ((int32_t)value > UINT16_MAX) return;
if ((int32_t)value < INT16_MIN) return;
uint16_t error = value;
printf("%d\n", (int16_t)error);
@ -106,7 +106,7 @@ namespace Debug {
{
printf("noErr\n");
return;
}
}
}
@ -184,7 +184,7 @@ namespace Debug {
uint32_t prevA6 = ReadLong(a6);
if (prevA6 <= a6) break;
uint32_t pc = ReadLong(a6+4); //
uint32_t pc = ReadLong(a6+4); //

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -104,7 +104,7 @@ namespace {
};
std::deque<BackTraceInfo> BackTrace;
@ -121,7 +121,7 @@ namespace {
break;
case 0x4E74: // rtd #
mboffset = 4;
break;
break;
default:
return;
break;
@ -137,7 +137,7 @@ namespace {
b -= 0x80;
pc++;
if (!b) b = Debug::ReadByte(pc++);
s.reserve(b);
for (unsigned i = 0; i < b; ++i)
{
@ -185,7 +185,7 @@ namespace {
}
else
{
printf("$%08X Tool #$%04X ; %04X\n",
printf("$%08X Tool #$%04X ; %04X\n",
pc, opcode, opcode);
}
@ -207,7 +207,7 @@ namespace {
{
case 0x4EBA: // jsr offset(pc)
{
int16_t offset = Debug::ReadWord(pc + 2);
int16_t offset = Debug::ReadWord(pc + 2);
address = pc + 2 + offset;
break;
}
@ -215,7 +215,7 @@ namespace {
{
address = Debug::ReadLong(pc + 2);
break;
}
}
case 0x4EF9: // jmp address
{
address = Debug::ReadLong(pc + 2);
@ -225,14 +225,14 @@ namespace {
{
// check if address is a jmp address (see above)
// and follow it. a5 should never change.
int16_t offset = Debug::ReadWord(pc + 2);
int16_t offset = Debug::ReadWord(pc + 2);
address = cpuGetAReg(5) + offset;
if (Debug::ReadWord(address) == 0x4EF9)
if (Debug::ReadWord(address) == 0x4EF9)
address = Debug::ReadLong(address + 2);
else address = 0;
break;
break;
}
// consider checking branches?
@ -297,7 +297,7 @@ namespace {
{
if (!trace) disasm(pc);
printf("CPU stopped\n");
return false;
return false;
}
if (sigInt)
@ -305,7 +305,7 @@ namespace {
if (!trace) disasm(pc);
printf("^C break\n");
sigInt = false;
return false;
return false;
}
if (memBreak)
@ -377,7 +377,7 @@ namespace {
break;
case 4:
fprintf(stdout, " [%08x]\n", value);
break;
break;
default:
fprintf(stdout, "\n");
break;
@ -607,7 +607,7 @@ void Print(uint32_t data)
if (data <= 0xffff)
printf(" '%s'", tmp + 2);
break;
case 0x08:
if (data <= 0xff)
printf(" '%s'", tmp + 3);
@ -690,15 +690,15 @@ void PrintRegisters(const BackTraceInfo &i)
{
const char *srbits = srBits(i.csr);
printf(" 0 1 2 3 4 5 6 7\n");
printf(" 0 1 2 3 4 5 6 7\n");
printf("D: %08x %08x %08x %08x %08x %08x %08x %08x\n",
i.d[0], i.d[1], i.d[2], i.d[3],
i.d[0], i.d[1], i.d[2], i.d[3],
i.d[4], i.d[5], i.d[6], i.d[7]
);
printf("A: %08x %08x %08x %08x %08x %08x %08x %08x\n",
i.a[0], i.a[1], i.a[2], i.a[3],
i.a[0], i.a[1], i.a[2], i.a[3],
i.a[4], i.a[5], i.a[6], i.a[7]
);
@ -711,15 +711,15 @@ void PrintRegisters()
uint16_t sr = cpuGetSR();
const char *srbits = srBits(sr);
printf(" 0 1 2 3 4 5 6 7\n");
printf(" 0 1 2 3 4 5 6 7\n");
printf("D: %08x %08x %08x %08x %08x %08x %08x %08x\n",
cpuGetDReg(0), cpuGetDReg(1), cpuGetDReg(2), cpuGetDReg(3),
cpuGetDReg(0), cpuGetDReg(1), cpuGetDReg(2), cpuGetDReg(3),
cpuGetDReg(4), cpuGetDReg(5), cpuGetDReg(6), cpuGetDReg(7)
);
printf("A: %08x %08x %08x %08x %08x %08x %08x %08x\n",
cpuGetAReg(0), cpuGetAReg(1), cpuGetAReg(2), cpuGetAReg(3),
cpuGetAReg(0), cpuGetAReg(1), cpuGetAReg(2), cpuGetAReg(3),
cpuGetAReg(4), cpuGetAReg(5), cpuGetAReg(6), cpuGetAReg(7)
);
@ -787,7 +787,7 @@ void PrintBackTrace()
disasm(prev->pc);
btdiff(*prev, current);
//
//
prev = &current;
}
@ -950,7 +950,7 @@ void Step(const Command &cmd)
int count = 0;
if (cmd.argc == 1) count = (int)cmd.argv[0];
if (count < 1) count = 1;
// TODO -- move to common function...
for (int i = 0; i < count; ++i)
{
@ -1001,7 +1001,7 @@ void SetXRegister(unsigned reg, uint32_t value)
if (value & 0x01)
{
fprintf(stderr, "Address is not aligned: $%08x\n", value);
return;
return;
}
if (value > Flags.memorySize)
{
@ -1084,7 +1084,7 @@ void Info(uint32_t address)
}
// 4 as an error
// almost all are negative 16-bit values,
// almost all are negative 16-bit values,
// but may also be a positive 16-bit value.
uint16_t error = 0;
if (address <= 0xffff) error = address;
@ -1155,7 +1155,7 @@ namespace {
auto end = iter;
if (!count) return NULL;
if (count > 100) return NULL;
if (count > 100) return NULL;
if (count == 1)
{
@ -1172,7 +1172,7 @@ namespace {
auto min_length = begin->first.length();
// item 0 is the longest match. (fill in later.)
buffer[i++] = NULL;
buffer[i++] = NULL;
for (iter = begin; iter != end; ++iter)
{
buffer[i++] = strdup(iter->first.c_str());
@ -1188,7 +1188,7 @@ namespace {
if (i >= min_length)
{
buffer[0][i] = 0;
buffer[0][i] = 0;
break;
}
@ -1319,5 +1319,3 @@ void Shell()
}
} // namespace Debugger

View File

@ -43,11 +43,11 @@ struct Token {
intValue(0), stringValue(0), subtype(0)
{}
Token(uint32_t i) :
Token(uint32_t i) :
intValue(i), subtype(0)
{}
Token(std::string *s, unsigned st = 0) :
Token(std::string *s, unsigned st = 0) :
intValue(0), stringValue(s), subtype(st)
{}
#endif

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -97,7 +97,7 @@ void code0(uint32_t data_size)
}
else
{
printf("$%08X ???\n", pc + 2);
printf("$%08X ???\n", pc + 2);
}
}
else
@ -208,7 +208,7 @@ void disasm(const char *name, int segment, uint32_t data_size)
ToolBox(pc, op);
pc += 2;
prevOP = op;
prevOP = op;
continue;
}
@ -305,4 +305,4 @@ int main(int argc, char **argv)
CloseResFile(refNum);
return 0;
}
}

View File

@ -13,9 +13,9 @@ namespace {
unsigned int hash = 5381;
for(size_t i = 0; i < length; ++i)
{
{
hash = ((hash << 5) + hash) + (begin[i]);
}
}
return hash;
}
@ -46,9 +46,9 @@ namespace Intern {
// insert it. I suppose this could throw, in which case a string would leak.
std::string *s = new std::string(std::move(str));
InternTable.emplace(std::make_pair(hash, s));
return s;
return s;
}
const std::string *String(const char *begin, size_t size)
{
if (!size) return &EmptyString;
@ -96,7 +96,3 @@ namespace Intern {
}

View File

@ -11,4 +11,4 @@ namespace Intern {
const std::string *String(const char *, const char *);
};
#endif
#endif

View File

@ -24,7 +24,7 @@
// hd / hexdump expression [:expression]
// stack ?
// brk expression
// tbrk expression
// tbrk expression
namespace {
int tox(char c)
{
@ -36,7 +36,7 @@ namespace {
uint32_t scan10(const char *begin, const char *end)
{
return std::accumulate(begin, end, 0,
return std::accumulate(begin, end, 0,
[](uint32_t value, char c){
return value * 10 + c - '0';
});
@ -44,7 +44,7 @@ namespace {
uint32_t scan16(const char *begin, const char *end)
{
return std::accumulate(begin, end, 0,
return std::accumulate(begin, end, 0,
[](uint32_t value, char c){
return (value << 4) + tox(c);
});
@ -237,7 +237,7 @@ bool ParseLine(const char *iter, Command *command)
'tbrk' | 'tbreak' | 'toolbreak' {
Parse(parser, tkTBREAK, 0, command);
continue;
continue;
}
'mbrk' | 'mbreak' | 'rwbrk' | 'rwbreak' {
@ -265,7 +265,7 @@ bool ParseLine(const char *iter, Command *command)
Parse(parser, tkPRINT, 0, command);
continue;
}
'r' | 'run' {
Parse(parser, tkCONTINUE, 0, command);
continue;
@ -324,4 +324,3 @@ bool ParseLine(const char *iter, Command *command)
} // namespace Debugger

View File

@ -4,13 +4,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -121,7 +121,7 @@ void reloc1(const uint8_t *r, uint32_t address, uint32_t offset)
// %0xxxxxxx -> 7-bit value
// %1xxxxxxx xxxxxxxx -> 15-bit value
// %00000000 1xxxxxxx x{8} x{8} x{8} -> 31 bit value
// ^ that's what the documentation says..
// ^ that's what the documentation says..
// that's how the 32-bit bootstrap works
// DumpCode ignores the high 2 bytes.
for(;;)
@ -302,7 +302,7 @@ uint32_t load(const char *file)
}
ReleaseResource(h);
}
}
// now link the segment 0 jump table...
assert(a5);
@ -392,7 +392,7 @@ void GlobalInit()
// 0x0a06 - MinusOne
memoryWriteLong(0xffffffff, MacOS::MinusOne);
// 0x0130 -- ApplLimit
memoryWriteLong(Flags.memorySize - Flags.stackSize - 1, MacOS::ApplLimit);
memoryWriteLong(kGlobalSize, MacOS::ApplZone);
@ -562,7 +562,7 @@ void MemoryLogger(uint32_t address, int size, int readWrite, uint32_t value)
break;
case 4:
fprintf(stderr, " [%08x]\n", value);
break;
break;
default:
fprintf(stderr, "\n");
break;
@ -624,7 +624,7 @@ bool parse_number(const char *input, uint32_t *dest)
value *= 1024 * 1024;
else if (strcasecmp(end, "K") == 0)
value *= 1024;
else
else
{
fprintf(stderr, "%s - invalid input\n", input);
return false;
@ -747,7 +747,7 @@ void MainLoop()
if (cpuGetStop()) break; // will this also be set by an interrupt?
#ifndef CPU_INSTRUCTION_LOGGING
if (Flags.traceCPU || Flags.traceMacsbug)
{
@ -781,7 +781,7 @@ int main(int argc, char **argv)
kDebugger,
kMemoryStats,
};
static struct option LongOpts[] =
static struct option LongOpts[] =
{
{ "ram",required_argument, NULL, 'r' },
{ "stack", required_argument, NULL, 's' },
@ -831,7 +831,7 @@ int main(int argc, char **argv)
case kTraceMPW:
Flags.traceMPW = true;
break;
case kMemoryStats:
Flags.memoryStats = true;
break;
@ -968,7 +968,7 @@ int main(int argc, char **argv)
MPW::Trace = Flags.traceMPW;
ToolBox::Trace = Flags.traceToolBox;
if (Flags.traceCPU || Flags.traceMacsbug)
{
#ifdef CPU_INSTRUCTION_LOGGING
@ -995,6 +995,6 @@ int main(int argc, char **argv)
if (rv > 0xff) rv = 0xff;
exit(rv);
}
}

View File

@ -296,4 +296,3 @@ int main(int argc, char **argv)
}
#endif

View File

@ -83,7 +83,7 @@ namespace Debug {
if (iter != Types.end())
{
if (iter->second == type) return; // ok, just a duplicate.
fprintf(stderr, "Template Error: line %d - redefining %s\n",
fprintf(stderr, "Template Error: line %d - redefining %s\n",
info->LineNumber, name->c_str());
return;
@ -91,13 +91,13 @@ namespace Debug {
if (Templates.find(*name) != Templates.end())
{
fprintf(stderr, "Template Error: line %d - redefining %s\n",
fprintf(stderr, "Template Error: line %d - redefining %s\n",
info->LineNumber, name->c_str());
return;
return;
}
Types.emplace(std::make_pair(*name, type));
Types.emplace(std::make_pair(*name, type));
}
@ -110,16 +110,16 @@ namespace Debug {
if (Templates.find(*name) != Templates.end())
{
fprintf(stderr, "Template Error: line %d - redefining %s\n",
fprintf(stderr, "Template Error: line %d - redefining %s\n",
info->LineNumber, name->c_str());
return;
return;
}
if (Types.find(*name) != Types.end())
{
fprintf(stderr, "Template Error: line %d - redefining %s\n",
fprintf(stderr, "Template Error: line %d - redefining %s\n",
info->LineNumber, name->c_str());
return;
return;
}
firstField = Reverse(firstField);
@ -135,10 +135,10 @@ namespace Debug {
return isprint(c) ? c : '.';
});
if (s.size() > 40) {
s.resize(37);
if (s.size() > 40) {
s.resize(37);
s.append("...");
}
}
}
void PrettyPrint(uint32_t value, unsigned type)
{
@ -224,7 +224,7 @@ namespace Debug {
uint8_t value = ReadByte(address + offset);
printf(" %02x", value);
PrettyPrint(value, type);
break;
break;
}
case 2:
@ -232,7 +232,7 @@ namespace Debug {
uint16_t value = ReadWord(address + offset);
printf(" %04x", value);
PrettyPrint(value, type);
break;
break;
}
case 4:
@ -240,12 +240,12 @@ namespace Debug {
uint32_t value = ReadLong(address + offset);
printf("%08x", value);
PrettyPrint(value, type);
break;
break;
}
case 0:
// either a pointer or a struct
if (type & 0x8000) {
if (type & 0x8000) {
// pointer.
uint32_t value = ReadLong(address + offset);
printf("%08x", value);

View File

@ -79,4 +79,3 @@ int main(int argc, char **argv)
#endif
#endif

View File

@ -554,7 +554,7 @@ but a special error is needed to patch secondary inits.*/
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus

View File

@ -263,7 +263,7 @@ enum {
enum {
SysParam = 0x1F8, /*[GLOBAL VAR] Low-memory copy of parameter RAM (20 bytes)
system parameter memory [20 bytes]*/
CrsrThresh = 0x8EC, /*[GLOBAL VAR] Mouse-scaling threshold (word)
CrsrThresh = 0x8EC, /*[GLOBAL VAR] Mouse-scaling threshold (word)
delta threshold for mouse scaling [word]*/
JCrsrTask = 0x8EE, /*[GLOBAL VAR] address of CrsrVBLTask [long]*/
MTemp = 0x828, /*[GLOBAL VAR] Low-level interrupt mouse location [long]*/
@ -318,7 +318,7 @@ enum {
MaskPtr = 0x31A, /*[GLOBAL VAR] Memory Manager Pointer Mask [long]*/
MinStack = 0x31E, /*[GLOBAL VAR] Minimum space allotment for stack (long)
min stack size used in InitApplZone [long]*/
DefltStack = 0x322, /*[GLOBAL VAR] Default space allotment for stack (long)
DefltStack = 0x322, /*[GLOBAL VAR] Default space allotment for stack (long)
default size of stack [long]*/
MMDefFlags = 0x326, /*[GLOBAL VAR] default zone flags [word]*/
DSAlertTab = 0x2BA, /*[GLOBAL VAR] Pointer to system error alert table in use
@ -362,7 +362,7 @@ enum {
TagData = 0x2FA, /*[GLOBAL VAR] sector tag info for disk drivers [14 bytes]*/
BufTgFNum = 0x2FC, /*[GLOBAL VAR] File tags buffer: file number (long)
file number [long]*/
BufTgFFlg = 0x300, /*[GLOBAL VAR] File tags buffer: flags (word: bit 1=1 if resource fork)
BufTgFFlg = 0x300, /*[GLOBAL VAR] File tags buffer: flags (word: bit 1=1 if resource fork)
flags [word]*/
BufTgFBkNum = 0x302, /*[GLOBAL VAR] File tags buffer: logical block number (word)
logical block number [word]*/
@ -400,7 +400,7 @@ enum {
Z-ordered linked list of windows [pointer]*/
PaintWhite = 0x9DC, /*[GLOBAL VAR] Flag for whether to paint window white before update event (word)
erase newly drawn windows? [word]*/
WMgrPort = 0x9DE, /*[GLOBAL VAR] Pointer to Window Manager port
WMgrPort = 0x9DE, /*[GLOBAL VAR] Pointer to Window Manager port
window manager's grafport [pointer]*/
GrayRgn = 0x9EE, /*[GLOBAL VAR] Handle to region drawn as desktop
rounded gray desk region [handle]*/
@ -439,7 +439,7 @@ enum {
system map [handle]*/
SysMap = 0xA58, /*[GLOBAL VAR] Reference number of system resource file (word)
reference number of system map [word]*/
CurMap = 0xA5A, /*[GLOBAL VAR] Reference number of current resource file (word)
CurMap = 0xA5A, /*[GLOBAL VAR] Reference number of current resource file (word)
reference number of current map [word]*/
ResReadOnly = 0xA5C, /*[GLOBAL VAR] Read only flag [word]*/
ResLoad = 0xA5E, /*[GLOBAL VAR] Current SetResLoad state (word)

View File

@ -73,13 +73,13 @@ namespace MacOS {
return *this;
}
constexpr const T* operator->() const
{
return &_value;
}
constexpr const T& operator *() const
{
return _value;
@ -117,7 +117,7 @@ namespace MacOS {
{
public:
tool_return()
tool_return()
{}
tool_return(macos_error error) : tool_return_base(error)
@ -133,5 +133,5 @@ namespace MacOS {
};
} // namespace IIgs
} // namespace
#endif

View File

@ -7,10 +7,10 @@ const char *TrapName(uint16_t trap)
switch(trap)
{
/*
/*
; QuickDraw
*/
case 0xA817: return "_CopyMask";
@ -196,10 +196,10 @@ const char *TrapName(uint16_t trap)
case 0xA8FB: return "_MapRgn";
case 0xA8FC: return "_MapPoly";
/*
/*
; Toolbox
*/
case 0xA80D: return "_Count1Resources";
@ -511,34 +511,34 @@ const char *TrapName(uint16_t trap)
case 0xABF2: return "_ThreadDispatch";
case 0xABFF: return "_DebugStr";
/*
/*
; Resource Manager
*/
case 0xA822: return "_ResourceDispatch";
/*
/*
; PPCToolbox
*/
case 0xA0DD: return "_PPC";
/*
/*
; Alias Manager
*/
case 0xA823: return "_AliasDispatch";
/*
/*
; Device Manager (some shared by the File Manager)
*/
case 0xA000: return "_Open";
@ -549,10 +549,10 @@ const char *TrapName(uint16_t trap)
case 0xA005: return "_Status";
case 0xA006: return "_KillIO";
/*
/*
; File Manager
*/
case 0xA007: return "_GetVolInfo";
@ -595,27 +595,27 @@ const char *TrapName(uint16_t trap)
case 0xA241: return "_HSetFLock";
case 0xA242: return "_HRstFLock";
/*
/*
; dispatch trap for remaining File Manager (and Desktop Manager) calls
*/
case 0xA060: return "_FSDispatch";
case 0xA260: return "_HFSDispatch";
/*
/*
; High level FSSpec calls
*/
case 0xAA52: return "_HighLevelHFSDispatch";
/*
/*
; Memory Manager
*/
case 0xA019: return "_InitZone";
@ -652,10 +652,10 @@ const char *TrapName(uint16_t trap)
case 0xA08F: return "_DeferUserFn";
case 0xA08D: return "_DebugUtil";
/*
/*
; Event Manager
*/
case 0xA02F: return "_PostEvent";
@ -697,8 +697,8 @@ const char *TrapName(uint16_t trap)
// case 0xA057: return "_SetApplBase";
case 0xA198: return "_HWPriv";
/*
/*
; New names for (mostly) new flavors of old LwrString trap (redone <13>)
*/
@ -707,10 +707,10 @@ const char *TrapName(uint16_t trap)
case 0xA456: return "_UpperText";
case 0xA656: return "_StripUpperText";
/*
/*
; Temporary Memory routines
*/
case 0xA88F: return "_OSDispatch";
@ -765,10 +765,10 @@ const char *TrapName(uint16_t trap)
case 0xA087: return "_IOPMsgRequest";
case 0xA088: return "_IOPMoveData";
/*
/*
; Power Manager
*/
case 0xA09F: return "_PowerDispatch";
@ -782,19 +782,19 @@ const char *TrapName(uint16_t trap)
case 0xA48A: return "_SleepQRemove";
// case 0xA48A: return "_SlpQRemove";
/*
/*
; Comm. Toolbox
*/
case 0xA08B: return "_CommToolboxDispatch";
case 0xA090: return "_SysEnvirons";
/*
/*
; Egret Manager
*/
case 0xA092: return "_EgretDispatch";
@ -809,10 +809,10 @@ const char *TrapName(uint16_t trap)
// case 0xA9C3: return "_KeyTrans";
case 0xA9C3: return "_KeyTranslate";
/*
/*
; TextEdit
*/
case 0xA9CB: return "_TEGetText";
@ -842,10 +842,10 @@ const char *TrapName(uint16_t trap)
case 0xA83D: return "_TEDispatch";
case 0xA83E: return "_TEStyleNew";
/*
/*
; Color Quickdraw
*/
case 0xAA00: return "_OpenCPort";
@ -899,10 +899,10 @@ const char *TrapName(uint16_t trap)
case 0xAA4F: return "_CalcCMask";
case 0xAA51: return "_CopyDeepMask";
/*
/*
; Routines for video devices
*/
case 0xAA27: return "_GetMaxDevice";
@ -920,10 +920,10 @@ const char *TrapName(uint16_t trap)
case 0xAA32: return "_GetGDevice";
case 0xABCA: return "_DeviceLoop";
/*
/*
; Color Manager
*/
case 0xAA33: return "_Color2Index";
@ -933,10 +933,10 @@ const char *TrapName(uint16_t trap)
case 0xAA37: return "_GetSubTable";
case 0xAA38: return "_UpdatePixMap";
/*
/*
; Dialog Manager
*/
// case 0xAA4B: return "_NewCDialog";
@ -956,10 +956,10 @@ const char *TrapName(uint16_t trap)
case 0xAA4E: return "_SetStdCProcs";
case 0xABF8: return "_StdOpcodeProc";
/*
/*
; added to Toolbox for color
*/
case 0xAA41: return "_SetWinColor";
@ -976,10 +976,10 @@ const char *TrapName(uint16_t trap)
case 0xA809: return "_GetControlVariant";
case 0xA80A: return "_GetWVariant";
/*
/*
; added to Menu Manager for color
*/
// case 0xAA60: return "_DelMCEntries";
@ -991,36 +991,36 @@ const char *TrapName(uint16_t trap)
case 0xAA64: return "_GetMCEntry";
case 0xAA65: return "_SetMCEntries";
/*
/*
; Menu Manager
*/
case 0xAA66: return "_MenuChoice";
/*
/*
; Dialog Manager?
*/
case 0xAA67: return "_ModalDialogMenuSetup";
case 0xAA68: return "_DialogDispatch";
/*
/*
; Font Manager
*/
case 0xA814: return "_SetFractEnable";
case 0xA854: return "_FontDispatch";
/*
/*
; Palette Manager
*/
case 0xAA90: return "_InitPalettes";
@ -1044,10 +1044,10 @@ const char *TrapName(uint16_t trap)
case 0xAAA1: return "_CopyPalette";
case 0xAAA2: return "_PaletteDispatch";
/*
/*
; Sound Manager
*/
case 0xA800: return "_SoundDispatch";
@ -1079,26 +1079,26 @@ const char *TrapName(uint16_t trap)
case 0xA05E: return "_NMInstall";
case 0xA05F: return "_NMRemove";
/*
/*
; All QDOffscreen Routines go through one trap with a selector
*/
case 0xAB1D: return "_QDExtensions";
/*
/*
; UserDelay
*/
case 0xA84C: return "_UserDelay";
/*
/*
; Component Manager
*/
case 0xA82A: return "_ComponentDispatch";
@ -1114,10 +1114,10 @@ const char *TrapName(uint16_t trap)
case 0xAA59: return "_MixedModeDispatch";
case 0xAA5A: return "_CodeFragmentDispatch";
/*
/*
; Translation Manager
*/
case 0xABFC: return "_TranslationDispatch";

View File

@ -1,18 +1,18 @@
/*
File: Traps.h
Contains: A-Trap constants.
Version: Technology: Mac OS 9
Release: Universal Interfaces 3.4
Copyright: © 1985-2001 by Apple Computer, Inc., all rights reserved
Bugs?: For bug reports, consult the following page on
the World Wide Web:
http://developer.apple.com/bugreporter/
*/
#ifndef __macos_traps__
#define __macos_traps__
@ -1079,4 +1079,3 @@ enum {
#endif
#endif /* __TRAPS__ */

View File

@ -29,7 +29,7 @@ std::string EvalString(std::string &s, std::unordered_map<std::string, std::stri
re2c:yyfill:enable = 0;
re2c:yych:conversion = 1;
re2c:indent:top = 1;
'$' [A-Za-z0-9_]+ {
std::string tmp(begin + 1, cp);
@ -44,7 +44,7 @@ std::string EvalString(std::string &s, std::unordered_map<std::string, std::stri
}
'${' [A-Za-z0-9_]+ '}' {
std::string tmp(begin + 2, cp - 1);
auto iter = env.find(tmp);
@ -86,7 +86,7 @@ void LoadEnvironment(std::string &envfile, std::unordered_map<std::string, std::
char *end;
char *iter;
size_t length;
size_t length;
begin = fgetln(fp, &length);
if (!begin) break; // eof or error.
@ -124,4 +124,4 @@ void LoadEnvironment(std::string &envfile, std::unordered_map<std::string, std::
fclose(fp);
}
}
}

View File

@ -155,4 +155,4 @@ int main(int argc, char **argv)
return 0;
}
#endif
#endif

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -57,7 +57,7 @@
extern char **environ;
namespace MPW {
namespace MPW {
// for dup counts, etc.
//std::vector<int> FDTable;
@ -152,7 +152,7 @@ namespace MPW
{
std::string s(pwd.pw_dir);
if (s.back() != '/') s.push_back('/');
s.append("mpw");
s.append("mpw");
if (isdir(s))
{
path = std::move(s);
@ -222,7 +222,7 @@ namespace MPW
FDTable[STDOUT_FILENO].text = true;
FDTable[STDERR_FILENO].refcount = 1;
FDTable[STDERR_FILENO].text = true;
FDTable[STDERR_FILENO].text = true;
*/
OS::Internal::FDEntry::allocate(STDIN_FILENO).text = true;
@ -238,7 +238,7 @@ namespace MPW
argv[0] = basename(argv[0]);
// 0x0910 CurApName
// 0x0910 CurApName
{
char str32[32];
@ -371,7 +371,7 @@ namespace MPW
memoryWriteWord(0x4E75, fptr + 6); // rts
memoryWriteWord(fClose, fptr + 8);
memoryWriteWord(0x4E75, fptr + 10); // rts
memoryWriteWord(0x4E75, fptr + 10); // rts
memoryWriteWord(fRead, fptr + 12);
memoryWriteWord(0x4E75, fptr + 14); // rts

View File

@ -31,7 +31,7 @@ namespace MPW {
enum
{
kF_GTABINFO = (('e' << 8) | 0x00), /* get tab offset for file */
kF_GTABINFO = (('e' << 8) | 0x00), /* get tab offset for file */
kF_STABINFO = (('e' << 8) | 0x01), /* set " " " " */
kF_GFONTINFO = (('e' << 8) | 0x02), /* get font number and size for file */
kF_SFONTINFO = (('e' << 8) | 0x03), /* set " " " " " " */
@ -122,4 +122,4 @@ namespace MPW {
}
#endif
#endif

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -93,7 +93,7 @@ namespace MPW
{
// get_tab_info(const char *name, uint32_t *tabSize)
// hard code for now.
// hard code for now.
// Could check xattr for actual value.
// That would be rather pointless unless some editor respected
// it.
@ -134,7 +134,7 @@ namespace MPW
rv = ::unlink(sname.c_str());
if (rv < 0) return 0x40000000 | mpw_errno_from_errno();
return 0;
}
@ -204,7 +204,7 @@ namespace MPW
// adjust the binary flags...
// some apps are good about this but
// some apps are good about this but
// dumpobj, makelib, linkiigs don't set O_BINARY (but should)
// MPW Assembler sets O_BINARY (but shouldn't)
@ -241,7 +241,7 @@ namespace MPW
uint32_t parm = memoryReadLong(sp + 12);
Log("%04x Access(%08x, %04x, %08x)\n", trap, name, op, parm);
switch (op)
{
case kF_OPEN:
@ -268,16 +268,16 @@ namespace MPW
d0 = ftrap_set_font_info(name, parm);
break;
default:
d0 = 0x40000000 | kEINVAL;
fprintf(stderr, "faccess - unsupported op %04x\n", op);
exit(1);
fprintf(stderr, "faccess - unsupported op %04x\n", op);
exit(1);
}
cpuSetDReg(0, d0);
cpuSetDReg(0, d0);
}
}
}

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -107,7 +107,7 @@ namespace MPW
f.error = OS::notOpenErr;
d0 = kEINVAL;
}
else
else
{
if (--e.refcount == 0)
{

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -159,7 +159,7 @@ namespace MPW {
const std::error_category& mpw_system_category()
{
static __system_category s;
return s;
return s;
}

View File

@ -12,7 +12,7 @@ namespace MPW
{
if (Trace) fprintf(stderr, format, args...);
}
}
#endif
#endif

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -138,8 +138,8 @@ namespace MPW
// write back...
memoryWriteWord(f.error, parm + 2);
memoryWriteLong(f.count, parm + 12);
cpuSetDReg(0, d0);
cpuSetDReg(0, d0);
}
}
}

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -57,7 +57,7 @@ using MacOS::macos_error_from_errno;
namespace MPW
{
uint32_t ftrap_dup(uint32_t parm, uint32_t arg)
{
uint32_t d0;
@ -96,7 +96,7 @@ namespace MPW
{
d0 = 0;
fd.refcount++;
}
}
else
{
d0 = kEINVAL;
@ -139,7 +139,7 @@ namespace MPW
uint32_t ftrap_interactive(uint32_t parm, uint32_t arg)
{
// return 0 if interactive, an error if
// return 0 if interactive, an error if
// non-interactive.
uint32_t d0;
@ -153,8 +153,8 @@ namespace MPW
f.count = memoryReadLong(parm + 12);
f.buffer = memoryReadLong(parm + 16);
// linkgs reads from stdin and
// doesn't work quite right when
// linkgs reads from stdin and
// doesn't work quite right when
// this returns 0. So, don't.
f.error = 0;
@ -183,7 +183,7 @@ namespace MPW
{
int tty = ::isatty(fd);
d0 = tty ? 0 : kEINVAL;
}
}
else
{
d0 = kEINVAL;
@ -252,7 +252,7 @@ namespace MPW
return kEINVAL;
}
);
#if 0
if (fd < 0 || fd >= FDTable.size() || !FDTable[fd])
{
@ -382,7 +382,7 @@ namespace MPW
return kEINVAL;
}
);
memoryWriteWord(f.error, parm + 2);
return d0;
@ -434,7 +434,7 @@ namespace MPW
break;
default:
fprintf(stderr, "ioctl - unsupported op %04x\n", cmd);
fprintf(stderr, "ioctl - unsupported op %04x\n", cmd);
exit(1);
break;
}
@ -443,4 +443,4 @@ namespace MPW
}
}
}

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -80,13 +80,13 @@ namespace {
// %1010 | 1 x . . | . . . . . . . . |
//
// if x = 1, an extra rts is pushed,
return (trap & 0x0c00) == 0x0c00;
return (trap & 0x0c00) == 0x0c00;
}
inline constexpr bool save_a0(uint16_t trap)
{
// %1010 | 0 . . x | . . . . . . . . |
//
//
// if x = 0, a0 is saved and restored.
// if x = 1, a0 is not saved and restored.
return (trap & 0x0900) == 0x0000;
@ -108,7 +108,7 @@ namespace OS {
uint16_t GetToolTrapAddress(uint16_t trap)
{
/*
/*
* on entry:
* D0 trap number
*
@ -138,7 +138,7 @@ namespace OS {
{
//pascal void SetToolTrapAddress(long trapAddr, short trapNum);
/*
/*
* on entry:
* A0 Address of patch
* D0 trap number
@ -167,7 +167,7 @@ namespace OS {
uint16_t GetOSTrapAddress(uint16_t trap)
{
/*
/*
* on entry:
* D0 trap number
*
@ -197,7 +197,7 @@ namespace OS {
{
//pascal void SetOSTrapAddress(long trapAddr, short trapNum);
/*
/*
* on entry:
* A0 Address of patch
* D0 trap number
@ -255,9 +255,9 @@ namespace OS {
default:
fprintf(stderr, "OSDispatch: selector %04x not implemented\n",
fprintf(stderr, "OSDispatch: selector %04x not implemented\n",
selector);
exit(1);
exit(1);
}
}
@ -267,7 +267,7 @@ namespace OS {
namespace ToolBox {
bool Init() {
//
//
std::fill(std::begin(trap_address), std::end(trap_address), 0);
std::fill(std::begin(os_address), std::end(os_address), 0);
@ -280,7 +280,7 @@ namespace ToolBox {
for (unsigned i = 0; i < 1024; ++i) {
*code++ = 0xafff;
*code++ = 0xa800 | i;
*code++ = 0xa800 | i;
}
for (unsigned i = 0; i < 256; ++i) {
@ -325,7 +325,7 @@ namespace ToolBox {
#if 0
/*
* os stubs:
* os stubs:
* os_return_a0
* pop registers a0, a1, d0, d1, d2
* pop long word
@ -339,11 +339,11 @@ namespace ToolBox {
* rts
*
* os_entry_a0:
*
*
*/
else
{
// os calls push the trap dispatcher pc as well.
// os calls push the trap dispatcher pc as well.
uint32_t tmp;
uint32_t a0, a1, d0, d1, d2;
if (save_a0(trap))
@ -386,7 +386,7 @@ namespace ToolBox {
*
* Most development environments, including MPW, do not use
* this feature.
*
*
* (Trap Manager, 8-20)
*/
@ -414,7 +414,7 @@ namespace ToolBox {
* parameters were pushed on the stack but
* the a-line instruction was intercepted
* before an exception occurred. Therefore,
* we need to push the return address on the
* we need to push the return address on the
* stack and set the new pc to the trap address.
*
* returnPC may have been previously set from the
@ -435,7 +435,7 @@ namespace ToolBox {
// Trap Manager 8-12.
// not actually an issue yet, will only matter
// if os address is overridden.
// if os address is overridden.
if (save_a0(trap)) {
saveA0 = true;
@ -513,7 +513,7 @@ namespace ToolBox {
case 0xa011:
d0 = OS::GetEOF(trap);
break;
case 0xa012:
d0 = OS::SetEOF(trap);
break;
@ -537,7 +537,7 @@ namespace ToolBox {
case 0xa215: // HSetVol
d0 = OS::HSetVol(trap);
break;
case 0xa018:
d0 = OS::GetFPos(trap);
@ -554,7 +554,7 @@ namespace ToolBox {
case 0xa060:
d0 = OS::FSDispatch(trap);
break;
case 0xa260:
d0 = OS::HFSDispatch(trap);
break;
@ -644,7 +644,7 @@ namespace ToolBox {
case 0xA01C:
d0 = MM::FreeMem(trap);
break;
// CompactMem (cbNeeded: Size) : Size;
case 0xa04c:
d0 = MM::CompactMem(trap);
@ -690,7 +690,7 @@ namespace ToolBox {
case 0xa11a:
d0 = MM::GetZone(trap);
break;
case 0xa01b:
d0 = MM::SetZone(trap);
break;
@ -721,7 +721,7 @@ namespace ToolBox {
case 0xa9c6:
d0 = OS::SecondsToDate(trap);
break;
// TickCount : LONGINT;
case 0xa975:
d0 = OS::TickCount(trap);
@ -771,7 +771,7 @@ namespace ToolBox {
case 0xA027:
d0 = MM::ReallocHandle(trap);
break;
case 0xA02B:
d0 = MM::EmptyHandle(trap);
break;
@ -890,7 +890,7 @@ namespace ToolBox {
case 0xa9a5:
d0 = RM::GetResourceSizeOnDisk(trap);
break;
case 0xa9a6:
d0 = RM::GetResAttrs(trap);
break;
@ -914,7 +914,7 @@ namespace ToolBox {
case 0xa9ad:
d0 = RM::RemoveResource(trap);
break;
// ResError : INTEGER;
case 0xa9af:
d0 = RM::ResError(trap);
@ -1032,4 +1032,4 @@ namespace ToolBox {
}
}
}

View File

@ -141,4 +141,4 @@ namespace OS {
}
}

View File

@ -42,4 +42,4 @@ namespace OS {
}
#endif
#endif

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -69,7 +69,7 @@ namespace Loader {
// todo -- also add std::string segmentName?
};
struct Segment0Info
struct Segment0Info
{
Segment0Info()
{}
@ -88,7 +88,7 @@ namespace Loader {
// %0xxxxxxx -> 7-bit value
// %1xxxxxxx xxxxxxxx -> 15-bit value
// %00000000 1xxxxxxx x{8} x{8} x{8} -> 31 bit value
// ^ that's what the documentation says..
// ^ that's what the documentation says..
// that's how the 32-bit bootstrap works
// DumpCode ignores the high 2 bytes.
for(;;)
@ -224,7 +224,7 @@ namespace Loader {
}
namespace Native
namespace Native
{
uint16_t LoadFile(const std::string &path)
@ -248,10 +248,10 @@ namespace Loader {
::FSGetResourceForkName(&fork);
err = ::FSOpenResourceFile(&ref,
fork.length,
fork.unicode,
fsRdPerm,
err = ::FSOpenResourceFile(&ref,
fork.length,
fork.unicode,
fsRdPerm,
&refNum);
if (err) return err;
@ -266,7 +266,7 @@ namespace Loader {
Segment0Info seg0;
err = LoadCode0(seg0);
// iterate through the jump table to get the other
// iterate through the jump table to get the other
// code segments to load
bool farModel = false;
for (uint32_t jtEntry = seg0.jtStart; jtEntry < seg0.jtEnd; jtEntry += 8)
@ -363,7 +363,7 @@ namespace Loader {
//
//
void LoadDebugNames(DebugNameTable &table)
{
@ -420,7 +420,7 @@ namespace Loader {
case 0x4E74: // rtd #
pc += 2; // skip the argument.
eof = true;
break;
break;
default:
break;
@ -474,7 +474,7 @@ namespace Loader {
}
// verify name is legal.
bool ok = std::all_of(s.begin(), s.end(),
bool ok = std::all_of(s.begin(), s.end(),
[](char c) {
if (c >= 'A' && c <= 'Z') return true;
if (c >= 'a' && c <= 'z') return true;
@ -524,7 +524,7 @@ namespace Loader {
/*
* struct { uint32_t a5; uint32_t pc; };
* future state: Native::LoadFile(const std::string &path, a5pc) ->
* future state: Native::LoadFile(const std::string &path, a5pc) ->
* load file, set global page variables, set A5, return PC.
*
*/
@ -532,7 +532,7 @@ namespace Loader {
uint16_t UnloadSeg(uint16_t trap)
{
// UnloadSeg (routineAddr: Ptr);
// UnloadSeg (routineAddr: Ptr);
/*
* ------------

View File

@ -11,12 +11,12 @@ namespace Loader {
typedef std::map<std::string, std::pair<uint32_t, uint32_t>> DebugNameTable;
namespace Native {
/*
/*
* loads the file
* sets registers PC and A5.
* sets certain globals.
*
* Dependencies: MM, RM
* Dependencies: MM, RM
*/
uint16_t LoadFile(const std::string &path);

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -46,7 +46,7 @@
using ToolBox::Log;
namespace
namespace
{
mplite_t pool;
@ -81,7 +81,7 @@ namespace
{
const unsigned HandleCount = 128; // 512 bytes of handle blocks.
uint8_t *block = (uint8_t *)mplite_malloc(&pool,
uint8_t *block = (uint8_t *)mplite_malloc(&pool,
sizeof(uint32_t) * HandleCount);
if (!block) return false;
@ -92,7 +92,7 @@ namespace
for ( ; hh < end; hh += sizeof(uint32_t))
{
HandleQueue.push_back(hh);
}
}
return true;
}
@ -118,10 +118,10 @@ namespace MM
MemorySize = memorySize;
HeapSize = memorySize - stack;
ok = mplite_init(&pool,
memory + globals,
memorySize - globals - stack,
32,
ok = mplite_init(&pool,
memory + globals,
memorySize - globals - stack,
32,
NULL);
if (ok != MPLITE_OK) return false;
@ -170,16 +170,16 @@ namespace MM
if (iter != HandleMap.end())
{
const HandleInfo &info = iter->second;
printf("Handle $%08x Pointer: $%08x Size: $%08x Flags: %c %c %c\n",
iter->first,
info.address,
info.size,
printf("Handle $%08x Pointer: $%08x Size: $%08x Flags: %c %c %c\n",
iter->first,
info.address,
info.size,
info.locked ? 'L' : ' ',
info.purgeable ? 'P' : ' ',
info.resource ? 'R' : ' '
);
return;
}
}
}
// 3. check if the address is within a handle.
@ -195,10 +195,10 @@ namespace MM
if (!info.size) end++;
if (address >= begin && address < end)
{
printf("Handle $%08x Pointer: $%08x Size: $%08x Flags: %c %c %c\n",
kv.first,
info.address,
info.size,
printf("Handle $%08x Pointer: $%08x Size: $%08x Flags: %c %c %c\n",
kv.first,
info.address,
info.size,
info.locked ? 'L' : ' ',
info.purgeable ? 'P' : ' ',
info.resource ? 'R' : ' '
@ -221,10 +221,10 @@ namespace MM
const auto h = kv.first;
const auto & info = kv.second;
fprintf(stdout, "%08x %08x %08x %c %c %c\n",
h,
info.address,
info.size,
info.locked? 'L' : ' ',
h,
info.address,
info.size,
info.locked? 'L' : ' ',
info.purgeable? 'P' : ' ',
info.resource ? 'R' : ' '
);
@ -255,7 +255,7 @@ namespace MM
return SetMemError(0);
}
uint16_t DisposePtr(uint32_t mcptr)
{
@ -305,7 +305,7 @@ namespace MM
HandleQueue.push_back(hh);
return SetMemError(MacOS::memFullErr);
}
mcptr = ptr - Memory;
mcptr = ptr - Memory;
if (clear)
std::memset(ptr, 0, size);
@ -424,7 +424,7 @@ namespace MM
// 1. - resizing to 0.
if (!newSize)
{
if (info.locked)
if (info.locked)
{
//return SetMemError(MacOS::memLockedErr);
@ -493,7 +493,7 @@ namespace MM
}
fprintf(stderr, "mplite_realloc failed.\n");
Native::PrintMemoryStats();
Native::PrintMemoryStats();
if (i > 0) return SetMemError(MacOS::memFullErr);
@ -600,7 +600,7 @@ namespace MM
if (iter == HandleMap.end()) return SetMemError(MacOS::memWZErr);
SetMemError(0);
return iter->second;
return iter->second;
}
@ -611,8 +611,8 @@ namespace MM
{
// also implements BlockMoveData.
// BlockMove will flush caches, BlockMoveData will not.
/*
/*
* on entry:
* A0 Pointer to source
* A1 Pointer to destination
@ -638,7 +638,7 @@ namespace MM
if (source == 0 || dest == 0 || count == 0)
return 0;
#endif
std::memmove(Memory + dest, Memory + source, count);
return 0;
@ -649,7 +649,7 @@ namespace MM
{
// todo -- add function to check pool for largest block?
/*
/*
* on entry:
* D0: cbNeeded (long word)
*
@ -669,7 +669,7 @@ namespace MM
uint32_t MaxMem(uint16_t trap)
{
// return largest contiguous free block size.
/*
/*
* on entry:
* (nothing)
*
@ -687,12 +687,12 @@ namespace MM
uint32_t MaxBlock(uint16_t trap)
{
/*
* The MaxBlock function returns the maximum contiguous space, in bytes, that you
* could obtain after compacting the current heap zone. MaxBlock does not actually
* The MaxBlock function returns the maximum contiguous space, in bytes, that you
* could obtain after compacting the current heap zone. MaxBlock does not actually
* do the compaction.
*/
/*
/*
* on entry:
* (nothing)
*
@ -710,7 +710,7 @@ namespace MM
uint32_t FreeMem(uint16_t trap)
{
// total free memory.
/*
/*
* on entry:
* (nothing)
*
@ -730,7 +730,7 @@ namespace MM
uint16_t ReserveMem(uint16_t trap)
{
/*
/*
* on entry:
* D0: cbNeeded (long word)
*
@ -754,7 +754,7 @@ namespace MM
uint16_t MoveHHi(uint16_t trap)
{
/*
/*
* on entry:
* A0: Handle to move
*
@ -779,7 +779,7 @@ namespace MM
uint32_t StackSpace(uint16_t trap)
{
/*
/*
* on entry:
*
* on exit:
@ -807,7 +807,7 @@ namespace MM
uint16_t NewPtr(uint16_t trap)
{
/*
/*
* on entry:
* D0 Number of logical bytes requested
*
@ -838,7 +838,7 @@ namespace MM
uint16_t DisposePtr(uint16_t trap)
{
/*
/*
* on entry:
* A0 Pointer to the nonrelocatable block to be disposed of
*
@ -860,7 +860,7 @@ namespace MM
uint32_t GetPtrSize(uint16_t trap)
{
/*
/*
* on entry:
* A0 pointer
*
@ -882,7 +882,7 @@ namespace MM
uint16_t SetPtrSize(uint16_t trap)
{
/*
/*
* on entry:
* A0 pointer
* D0 new size
@ -918,7 +918,7 @@ namespace MM
uint16_t NewHandle(uint16_t trap)
{
/*
/*
* on entry:
* D0 Number of logical bytes requested
*
@ -946,7 +946,7 @@ namespace MM
uint16_t DisposeHandle(uint16_t trap)
{
/*
/*
* on entry:
* A0 Handle to be disposed of
*
@ -964,7 +964,7 @@ namespace MM
uint16_t EmptyHandle(uint16_t trap)
{
/*
/*
* on entry:
* A0 Handle to be disposed of
*
@ -997,7 +997,7 @@ namespace MM
/*
* ReallocHandle (h: Handle; logicalSize: Size);
*
*
* ReallocHandle allocates a new relocatable block with a logical
* size of logicalSize bytes. It then updates handle h by setting
* its master pointer to point to the new block. The main use of
@ -1006,12 +1006,12 @@ namespace MM
* be: If it points to an existing block, that block is released
* before the new block is created.
*
* In case of an error, no new block is allocated and handle h is
* In case of an error, no new block is allocated and handle h is
* left unchanged.
*/
uint16_t ReallocHandle(uint16_t trap)
{
/*
/*
* on entry:
* A0 Handle to be disposed of
* D0 Logical Size
@ -1070,7 +1070,7 @@ namespace MM
uint32_t GetHandleSize(uint16_t trap)
{
/*
/*
* on entry:
* A0 handle
*
@ -1105,7 +1105,7 @@ namespace MM
uint16_t SetHandleSize(uint16_t trap)
{
/*
/*
* on entry:
* A0 pointer
* D0 new size
@ -1133,7 +1133,7 @@ namespace MM
* A0 Master pointer
*
* on exit:
* A0 Handle to master pointers relocatable block
* A0 Handle to master pointers relocatable block
* D0 Unchanged
*
*/
@ -1209,7 +1209,7 @@ namespace MM
// see HSetRBit, HClrRBit
if (info.resource) flags |= (1 << 5);
if (info.purgeable) flags |= (1 << 6);
if (info.locked) flags |= (1 << 7);
if (info.locked) flags |= (1 << 7);
SetMemError(0);
return flags;
@ -1248,7 +1248,7 @@ namespace MM
uint16_t HPurge(uint16_t trap)
{
/*
/*
* on entry:
* A0 Handle
*
@ -1273,7 +1273,7 @@ namespace MM
uint16_t HNoPurge(uint16_t trap)
{
/*
/*
* on entry:
* A0 Handle
*
@ -1297,7 +1297,7 @@ namespace MM
uint16_t HLock(uint16_t trap)
{
/*
/*
* on entry:
* A0 Handle
*
@ -1320,7 +1320,7 @@ namespace MM
uint16_t HUnlock(uint16_t trap)
{
/*
/*
* on entry:
* A0 Handle
*
@ -1346,7 +1346,7 @@ namespace MM
uint16_t HandToHand(uint16_t trap)
{
/*
/*
* on entry:
* A0 source Handle
*
@ -1365,7 +1365,7 @@ namespace MM
return SetMemError(MacOS::memWZErr);
auto const info = iter->second;
auto const info = iter->second;
uint32_t destHandle;
@ -1375,7 +1375,7 @@ namespace MM
{
std::memmove(memoryPointer(destPtr), memoryPointer(info.address), info.size);
}
cpuSetAReg(0, destHandle);
return d0; // SetMemError called by Native::NewHandle.
}
@ -1383,7 +1383,7 @@ namespace MM
uint16_t PtrToHand(uint16_t trap)
{
/*
/*
* on entry:
* A0 source Pointer
* D0 size
@ -1406,7 +1406,7 @@ namespace MM
{
std::memmove(memoryPointer(destPtr), memoryPointer(mcptr), size);
}
cpuSetAReg(0, destHandle);
return d0; // SetMemError called by Native::NewHandle.
}
@ -1415,7 +1415,7 @@ namespace MM
{
// FUNCTION PtrAndHand (pntr: Ptr; hndl: Handle; size: LongInt): OSErr;
/*
/*
* on entry:
* A0 source Pointer
* A1 dest Handle
@ -1452,7 +1452,7 @@ namespace MM
if (iter == HandleMap.end())
return SetMemError(MacOS::memWZErr);
auto const info = iter->second;
auto const info = iter->second;
std::memmove(memoryPointer(info.address + oldSize), memoryPointer(ptr), size);
@ -1465,7 +1465,7 @@ namespace MM
#pragma mark -
uint32_t StripAddress(uint16_t trap)
{
/*
/*
* on entry:
* d0 Address to strip
*
@ -1491,12 +1491,12 @@ namespace MM
uint16_t HandleZone(uint16_t trap)
{
// FUNCTION HandleZone (h: Handle): THz;
/*
/*
* on entry:
* A0 Handle whose zone is to be found
*
* on exit:
* A0 Pointer to handles heap zone
* A0 Pointer to handles heap zone
* D0 Result code
*
*/
@ -1525,7 +1525,7 @@ namespace MM
* on entry:
*
* on exit:
* A0 Pointer to current heap zone
* A0 Pointer to current heap zone
* D0 Result code
*/
@ -1573,7 +1573,7 @@ namespace MM
/*
* Registers on exit:
* A0 Maximum number of contiguous bytes after purge
* A0 Maximum number of contiguous bytes after purge
* D0 Total free memory after purge
*/
@ -1635,7 +1635,7 @@ namespace MM
uint16_t TempHLock(void)
{
// PROCEDURE TempHLock (theHandle: Handle; VAR resultCode: OSErr);
// PROCEDURE TempHLock (theHandle: Handle; VAR resultCode: OSErr);
uint32_t theHandle;
uint32_t resultCode;
@ -1651,7 +1651,7 @@ namespace MM
uint16_t TempHUnlock(void)
{
// PROCEDURE TempHUnlock (theHandle: Handle; VAR resultCode: OSErr);
// PROCEDURE TempHUnlock (theHandle: Handle; VAR resultCode: OSErr);
uint32_t theHandle;
uint32_t resultCode;
@ -1668,7 +1668,7 @@ namespace MM
uint16_t TempDisposeHandle(void)
{
// PROCEDURE TempDisposeHandle (theHandle: Handle; VAR resultCode: OSErr);
// PROCEDURE TempDisposeHandle (theHandle: Handle; VAR resultCode: OSErr);
uint32_t theHandle;
uint32_t resultCode;

View File

@ -45,7 +45,7 @@ namespace MM
bool purgeable = false;
bool resource = false;
HandleInfo(uint32_t a = 0, uint32_t s = 0) :
HandleInfo(uint32_t a = 0, uint32_t s = 0) :
address(a), size(s)
{}
};
@ -64,7 +64,7 @@ namespace MM
uint32_t FreeMem(uint16_t trap);
uint16_t ReserveMem(uint16_t trap);
uint32_t PurgeSpace(uint16_t trap);
uint16_t DisposeHandle(uint16_t trap);
uint16_t DisposePtr(uint16_t trap);
@ -128,4 +128,4 @@ namespace MM
#endif
#endif

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -77,13 +77,13 @@ namespace {
pos = s.find_last_of("./:");
if (pos == s.npos) return tmp;
if (pos == s.npos) return tmp;
if (s[pos++] != '.') return tmp;
if (pos >= s.length()) return tmp;
tmp = s.substr(pos);
std::transform(tmp.begin(), tmp.end(), tmp.begin(),
std::transform(tmp.begin(), tmp.end(), tmp.begin(),
[](char c) { return tolower(c); }
);
@ -133,7 +133,7 @@ namespace OS
if (rv >= 8 && memcmp(buffer, "TEXT", 4) == 0)
return true;
}
std::string ext = extension(s);
if (ext.empty()) return false;
@ -158,7 +158,7 @@ namespace OS
if (ext == "equ") // asm iigs include file.
return true;
break;
case 'i':
if (ext == "i") // asmiigs include file
return true;
@ -167,7 +167,7 @@ namespace OS
break;
case 'h':
if (ext == "h") // c header
if (ext == "h") // c header
return true;
break;
@ -242,7 +242,7 @@ namespace OS
if (buffer[0] == 'B' && buffer[2] == ' ' && buffer[3] == ' ')
return true;
// "p" $uv $wx $yz
// "p" $uv $wx $yz
if (buffer[0] == 'p')
{
uint8_t fileType = buffer[1];
@ -271,7 +271,7 @@ namespace OS
return true;
// Newton C++ Tools output
if (ext == "ntkc")
return true;
return true;
break;
case 'o':
@ -284,7 +284,7 @@ namespace OS
case 's':
// Newton C++ Intermediate file
if (ext == "sym")
return true;
return true;
break;
}
@ -382,7 +382,7 @@ namespace OS
else
{
::close(fd);
d0 = 0;
d0 = 0;
}
memoryWriteWord(d0, parm + _ioResult);
@ -421,7 +421,7 @@ namespace OS
int fd;
uint8_t ioPermission = memoryReadByte(parm + _ioPermssn);
uint8_t ioPermission = memoryReadByte(parm + _ioPermssn);
uint32_t namePtr = memoryReadLong(parm + _ioNamePtr);
std::string sname = ToolBox::ReadPString(namePtr, true);
@ -436,7 +436,7 @@ namespace OS
d0 = fd < 0 ? fd : 0;
if (fd >= 0)
{
memoryWriteWord(fd, parm + _ioRefNum);
memoryWriteWord(fd, parm + _ioRefNum);
}
memoryWriteWord(d0, parm + _ioResult);
@ -507,7 +507,7 @@ namespace OS
d0 = 0;
pos += count;
memoryWriteLong(count, parm + 40);
}
}
if (count == 0)
{
@ -567,7 +567,7 @@ namespace OS
d0 = 0;
pos += count;
memoryWriteLong(count, parm + 40);
}
}
if (count < 0)
{
@ -781,11 +781,11 @@ namespace OS
uint16_t CmpString(uint16_t trap)
{
/*
/*
* on entry:
* A0 Pointer to first character of first string
* A1 Pointer to first character of second string
* D0 (high) length of first string
* D0 (high) length of first string
* D0 (low) length of second string
*
* on exit:
@ -814,9 +814,9 @@ namespace OS
bool eq;
eq = std::equal(
a.begin(),
a.end(),
b.begin(),
a.begin(),
a.end(),
b.begin(),
[caseSens](char a, char b){
if (!caseSens)
{
@ -846,7 +846,7 @@ namespace OS
uint16_t ReadDateTime(uint16_t trap)
{
/*
/*
* on entry:
* A0 Pointer to long word secs
*
@ -875,7 +875,7 @@ namespace OS
uint16_t SecondsToDate(uint16_t trap)
{
/*
/*
* on entry:
* D0 Seconds since midnight, January 1, 1904
* A0 pointer to date-time record
@ -933,7 +933,7 @@ namespace OS
uint16_t Microseconds(uint16_t trap)
{
// UnsignedWide is a uint64_t
// UnsignedWide is a uint64_t
// Microseconds(UnsignedWide * microTickCount)
// FOURWORDINLINE(0xA193, 0x225F, 0x22C8, 0x2280);
@ -961,7 +961,7 @@ namespace OS
#ifdef OLD_TRAP_DISPATCH
uint16_t GetToolTrapAddress(uint16_t trap)
{
/*
/*
* on entry:
* D0 trap number
*
@ -983,7 +983,7 @@ namespace OS
{
//pascal void SetToolTrapAddress(long trapAddr, short trapNum);
/*
/*
* on entry:
* A0 Address of patch
* D0 trap number
@ -1009,7 +1009,7 @@ namespace OS
uint16_t GetOSTrapAddress(uint16_t trap)
{
/*
/*
* on entry:
* D0 trap number
*
@ -1031,7 +1031,7 @@ namespace OS
{
//pascal void SetOSTrapAddress(long trapAddr, short trapNum);
/*
/*
* on entry:
* A0 Address of patch
* D0 trap number

View File

@ -43,7 +43,7 @@ namespace OS
uint16_t Create(uint16_t trap);
uint16_t Delete(uint16_t trap);
uint16_t FlushVol(uint16_t trap);
uint16_t GetFileInfo(uint16_t trap);
uint16_t HGetFileInfo(uint16_t trap);
uint16_t SetFileInfo(uint16_t trap);
@ -56,7 +56,7 @@ namespace OS
uint16_t GetVol(uint16_t trap);
uint16_t HGetVol(uint16_t trap);
uint16_t HGetVInfo(uint16_t trap);
uint16_t SetVol(uint16_t trap);

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -74,13 +74,13 @@ namespace OS {
break;
default:
fprintf(stderr, "AliasDispatch: selector $%04x not implemented\n",
fprintf(stderr, "AliasDispatch: selector $%04x not implemented\n",
selector);
exit(1);
exit(1);
}
ToolReturn<2>(-1, d0);
return d0;
}
}
}

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -88,7 +88,7 @@ namespace {
}
namespace OS {
uint16_t GetFileInfo(uint16_t trap)
{
@ -171,7 +171,7 @@ namespace OS {
}
Internal::GetFinderInfo(sname, memoryPointer(parm + _ioFlFndrInfo), false);
Internal::GetFinderInfo(sname, memoryPointer(parm + _ioFlFndrInfo), false);
// file reference number
@ -296,7 +296,7 @@ namespace OS {
{
d0 = macos_error_from_errno();
memoryWriteWord(d0, parm + _ioResult);
return d0;
return d0;
}
@ -316,7 +316,7 @@ namespace OS {
uint16_t HGetFileInfo(uint16_t trap)
{
enum { // HFileParam
_qLink = 0,
_qType = 4,

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -154,4 +154,3 @@ namespace OS {
}
}

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -54,7 +54,7 @@
#include "toolbox.h"
#include "stackframe.h"
#include "fs_spec.h"
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
#define st_birthtime st_mtime
#endif
@ -87,7 +87,7 @@ namespace OS {
/*
* TODO - this is a Massive hack.
* MPW returns this: for a 0/0 entry.
* MPW returns this: for a 0/0 entry.
* PBGetWDInfo
* 0
* ioNamePtr: MacOS
@ -245,7 +245,7 @@ namespace OS {
{
memoryWriteByte(0, parm + _ioFlAttrib);
memoryWriteByte(0, parm + _ioACUser);
memoryWriteByte(0, parm + _ioACUser);
Internal::GetFinderInfo(sname, memoryPointer(parm + _ioFlFndrInfo), false); // finder info
memoryWriteLong(0, parm + _ioDirID);
memoryWriteWord(0, parm + _ioFlStBlk);
@ -377,7 +377,7 @@ namespace OS {
{
d0 = macos_error_from_errno();
memoryWriteWord(d0, parm + _ioResult);
return d0;
return d0;
}
// just nop if it's a directory.
@ -385,13 +385,13 @@ namespace OS {
{
d0 = 0;
d0 = Internal::SetFileDates(sname,
memoryReadLong(parm + _ioDrCrDat),
memoryReadLong(parm + _ioDrMdDat),
d0 = Internal::SetFileDates(sname,
memoryReadLong(parm + _ioDrCrDat),
memoryReadLong(parm + _ioDrMdDat),
memoryReadLong(parm + _ioDrBkDat));
memoryWriteWord(d0, parm + _ioResult);
return d0;
return d0;
}
}
@ -399,9 +399,9 @@ namespace OS {
// set the finder info. could also call utimes or setattrlist, I suppose.
d0 = Internal::SetFinderInfo(sname, memoryPointer(parm + _ioFlFndrInfo), false);
if (d0 == 0) d0 = Internal::SetFileDates(sname,
memoryReadLong(parm + _ioFlCrDat),
memoryReadLong(parm + _ioFlMdDat),
if (d0 == 0) d0 = Internal::SetFileDates(sname,
memoryReadLong(parm + _ioFlCrDat),
memoryReadLong(parm + _ioFlMdDat),
memoryReadLong(parm + _ioFlBkDat));
@ -433,7 +433,7 @@ namespace OS {
{
// AccessParam.ioDenyModes short word matches
// up with the permission byte considering it's big-endian.
Log(" PBHOpenDeny\n");
return OS::OpenCommon(paramBlock, true, false);
}
@ -465,7 +465,7 @@ namespace OS {
break;
default:
fprintf(stderr, "FSDispatch: selector %08x not implemented\n",
fprintf(stderr, "FSDispatch: selector %08x not implemented\n",
selector);
exit(1);
}
@ -504,7 +504,7 @@ namespace OS {
return PBHOpenRFDeny(paramBlock);
default:
fprintf(stderr, "HFSDispatch: selector %08x not implemented\n",
fprintf(stderr, "HFSDispatch: selector %08x not implemented\n",
selector);
exit(1);
}

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -74,7 +74,7 @@ namespace OS {
long parID;
StrFileName name; // a Str63 on MacOS
};
*/
*/
// MacOS: -> { -1, 1, "MacOS" }
// MacOS:dumper -> {-1, 2 "dumper"}
@ -90,7 +90,7 @@ namespace OS {
// expand the path. Also handles relative paths.
char *cp = ::fs_spec_realpath(path.c_str(), buffer);
if (!cp) return "";
return std::string(cp);
}
@ -107,7 +107,7 @@ namespace OS {
// FSMakeFSSpec(vRefNum: Integer; dirID: LongInt; fileName: Str255; VAR spec: FSSpec): OSErr;
// todo -- if the file does not exist (but the path is otherwise valid), create the spec but return fnfErr.
/*
* See Chapter 2, File Manager / Using the File Manager, 2-35
*
@ -123,7 +123,7 @@ namespace OS {
StackFrame<14>(vRefNum, dirID, fileName, spec);
std::string sname = ToolBox::ReadPString(fileName, true);
Log(" FSMakeFSSpec(%04x, %08x, %s, %08x)\n",
Log(" FSMakeFSSpec(%04x, %08x, %s, %08x)\n",
vRefNum, dirID, sname.c_str(), spec);
if (vRefNum == 0 && dirID > 0 && sname.length())
@ -153,7 +153,7 @@ namespace OS {
if (path.empty())
{
std::memset(memoryPointer(spec), 0, 8);
return MacOS::mFulErr;
return MacOS::mFulErr;
}
int pos = path.find_last_of('/');
@ -214,7 +214,7 @@ namespace OS {
int fd = Internal::FDEntry::open(sname, permission, 0);
if (fd < 0) return fd;
memoryWriteWord(fd, refNum);
memoryWriteWord(fd, refNum);
return 0;
}
@ -273,7 +273,7 @@ namespace OS {
{
// FUNCTION FSpCreate (spec: FSSpec; creator: OSType;
// fileType: OSType; scriptTag: ScriptCode):
// fileType: OSType; scriptTag: ScriptCode):
// OSErr;
uint16_t d0 = 0;
@ -290,8 +290,8 @@ namespace OS {
int parentID = memoryReadLong(spec + 2);
std::string sname = ToolBox::ReadPString(spec + 6, false);
Log(" FSpCreate(%s, %08x ('%s'), %08x ('%s'), %02x)\n",
sname.c_str(),
Log(" FSpCreate(%s, %08x ('%s'), %08x ('%s'), %02x)\n",
sname.c_str(),
creator, ToolBox::TypeToString(creator).c_str(),
fileType, ToolBox::TypeToString(fileType).c_str(),
scriptTag);
@ -355,7 +355,7 @@ namespace OS {
int ok = 0;
if (S_ISDIR(st.st_mode))
ok = ::rmdir(sname.c_str());
else
else
ok = ::unlink(sname.c_str());
if (ok < 0)
@ -430,7 +430,7 @@ namespace OS {
* $000D FSpOpenResFile
* $000E FSpCreateResFile
* $000F FSpExchangeFiles
*/
*/
uint16_t selector;
uint16_t d0;

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -84,7 +84,7 @@ namespace OS {
// FUNCTION FlushCodeCacheRange (address: UNIV Ptr; count: LongInt): OSErr;
uint32_t address = cpuGetAReg(0);
uint32_t count = cpuGetAReg(1);
uint32_t count = cpuGetAReg(1);
Log(" FlushCodeCacheRange(%08x, %08x)\n", address, count);
return 0;
@ -138,4 +138,4 @@ namespace OS {
}
}
}

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -53,10 +53,10 @@ namespace OS { namespace Internal {
/*
tech note PT515
ProDOS -> Macintosh conversion
ProDOS Macintosh
Filetype Auxtype Creator Filetype
$00 $0000 'pdos' 'BINA'
@ -65,24 +65,24 @@ namespace OS { namespace Internal {
$FF (SYS) (any) 'pdos' 'PSYS'
$B3 (S16) (any) 'pdos' 'PS16'
$uv $wxyz 'pdos' 'p' $uv $wx $yz
Programmer's Reference for System 6.0:
ProDOS Macintosh
File Type Auxiliary Type Creator Type File Type
$00 $0000 pdos BINA
$04 (TXT) $0000 pdos TEXT
$FF (SYS) (any) pdos PSYS
$B3 (S16) $DByz pdos p $B3 $DB $yz
$B3 (S16) (any) pdos PS16
$D7 $0000 pdos MIDI
$D8 $0000 pdos AIFF
$D8 $0001 pdos AIFC
$E0 $0005 dCpy dImg
$FF (SYS) (any) pdos PSYS
$uv $wxyz pdos p $uv $wx $yz
ProDOS Macintosh
File Type Auxiliary Type Creator Type File Type
$00 $0000 pdos BINA
$04 (TXT) $0000 pdos TEXT
$FF (SYS) (any) pdos PSYS
$B3 (S16) $DByz pdos p $B3 $DB $yz
$B3 (S16) (any) pdos PS16
$D7 $0000 pdos MIDI
$D8 $0000 pdos AIFF
$D8 $0001 pdos AIFC
$E0 $0005 dCpy dImg
$FF (SYS) (any) pdos PSYS
$uv $wxyz pdos p $uv $wx $yz
mpw standard:
$uv (any) "pdos" printf("%02x ",$uv)
@ -122,7 +122,7 @@ namespace OS { namespace Internal {
#endif
char tmp[8] = {
'p', ' ', ' ', ' ',
'p', ' ', ' ', ' ',
'p', 'd', 'o', 's'
};
tmp[1] = (char)ftype;
@ -186,7 +186,7 @@ namespace OS { namespace Internal {
if (IsTextFile(pathName))
{
std::memcpy(buffer, "TEXTMPS ", 8);
}
}
// convert pdos types...
@ -195,7 +195,7 @@ namespace OS { namespace Internal {
// mpw expects 'xx ' where
// xx are the ascii-encode hex value of the file type.
// the hfs fst uses 'p' ftype8 auxtype16
// todo -- but only if auxtype is $0000 ??
if (buffer[0] == 'p')
{
@ -329,7 +329,7 @@ namespace OS { namespace Internal {
dates[i++].tv_sec = MacToUnix(backupDate);
list.commonattr |= ATTR_CMN_BKUPTIME;
}
if (!i) return 0;
@ -471,7 +471,7 @@ namespace OS { namespace Internal {
if (size > 0)
{
std::transform(trbuffer.get(), trbuffer.get() + size, (uint8_t *)buffer,
std::transform(trbuffer.get(), trbuffer.get() + size, (uint8_t *)buffer,
[](uint8_t c) { return c == '\n' ? '\r' : c; }
);
}
@ -507,7 +507,7 @@ namespace OS { namespace Internal {
if (count > 0)
{
std::transform((const uint8_t *)buffer, (const uint8_t *)buffer + count, trbuffer.get(),
std::transform((const uint8_t *)buffer, (const uint8_t *)buffer + count, trbuffer.get(),
[](uint8_t c) { return c == '\r' ? '\n' : c; }
);
}
@ -529,7 +529,7 @@ namespace OS { namespace Internal {
if (filename.empty()) return MacOS::bdNamErr;
int access = 0;
// ignore the deny bits for now.
switch(ioPermission & 0x0f)
{
@ -548,7 +548,7 @@ namespace OS { namespace Internal {
}
std::string xname = filename;
if (fork)
if (fork)
xname.append(_PATH_RSRCFORKSPEC);
Log(" open(%s, %04x)\n", xname.c_str(), access);

View File

@ -27,8 +27,8 @@ namespace OS { namespace Internal {
std::string filename;
FDEntry() :
refcount(0),
text(false),
refcount(0),
text(false),
resource(false)
{}

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -80,12 +80,12 @@ namespace OS {
* pass a pointer to a Str31 value if you want that name returned.
* If you pass NIL in the ioNamePtr field, no volume name is
* returned.
*
*
* If you pass a working directory reference number in ioVRefNum
* (or if the default directory is a subdirectory), the number
* of files and directories in the specified directory (the
* directorys valence) is returned in ioVNmFls.
*
*
* You can read the ioVDrvInfo and ioVDRefNum fields to determine
* whether the specified volume is online, offline, or ejected.
* For online volumes, ioVDrvInfo contains the drive number of
@ -98,8 +98,8 @@ namespace OS {
* 0. If the volume is not online, the value of ioVDRefNum is
* either the negative of the drive number (if the volume is
* offline) or the drive number itself (if the volume is ejected).
*
*
*
*
* You can get information about all the online volumes by making
* repeated calls to PBHGetVInfo, starting with the value of
* ioVolIndex set to 1 and incrementing that value until PBHGetVInfo
@ -182,7 +182,7 @@ namespace OS {
uint32_t parm = cpuGetAReg(0);
Log("%04x FlushVol(%08x)\n", trap, parm);
Log("%04x FlushVol(%08x)\n", trap, parm);
// volume is specified with ioNamePtr or ioVRefNum.
// could go through open fds and fsync(fd), fcntl(fd, F_FULLFSYNC) them.

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -107,7 +107,7 @@ namespace Packages {
out.assign(buffer, length);
ToolBox::WritePString(result, out);
return 0;
return 0;
}
uint16_t GetIntlResource()

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -96,7 +96,7 @@ namespace Process {
if (!psn || memoryReadLongLong(psn) != kProcessID)
{
ToolReturn<2>(sp, MacOS::paramErr);
return MacOS::paramErr;
return MacOS::paramErr;
}
ToolReturn<2>(sp, MacOS::paramErr);

View File

@ -6,7 +6,7 @@
namespace Process {
uint16_t GetCurrentProcess();
uint16_t GetProcessInformation();
uint16_t GetProcessInformation();
}

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -111,9 +111,9 @@ namespace QD {
Log("%04x SetFScaleDisable($%04x)\n", trap, value);
// sets FScaleDisable global variable
return 0;
}
}
}
}

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -65,7 +65,7 @@ namespace
// https://developer.apple.com/library/mac/documentation/Carbon/Reference/CoreEndianReference/
OSStatus FlipperNoFlipping(OSType dataDomain, OSType dataType, SInt16 id, void *dataPtr, ByteCount dataSize, Boolean currentlyNative, void *refCon)
{
return 0;
@ -92,7 +92,7 @@ namespace
#if 0
struct ResEntry
{
ResEntry(uint32_t type = 0, uint32_t id = 0) :
ResEntry(uint32_t type = 0, uint32_t id = 0) :
resType(type), resID(id)
{}
uint32_t resType;
@ -118,8 +118,8 @@ namespace
bool LoadResType(uint32_t type)
{
// this filtering was originally to
// block cursors ('acur'). Can probably
// change it to a blacklist rather than
// block cursors ('acur'). Can probably
// change it to a blacklist rather than
// a whitelist at some point.
return true;
@ -156,7 +156,7 @@ namespace RM
namespace Native
namespace Native
{
// not to be confused with MacOS LoadResource(theHandle)
@ -240,8 +240,8 @@ namespace RM
Log("%04x CloseResFile(%04x)\n", trap, refNum);
// If the value of the refNum parameter is 0, it represents the System file and is ignored.
// If the value of the refNum parameter is 0, it represents the System file and is ignored.
if (refNum != 0)
{
::CloseResFile(refNum);
@ -277,12 +277,12 @@ namespace RM
std::string sname = ToolBox::ReadPString(name);
Log("%04x Get1NamedResource(%08x ('%s'), %s)\n",
Log("%04x Get1NamedResource(%08x ('%s'), %s)\n",
trap, theType, TypeToString(theType).c_str(), sname.c_str());
uint32_t resourceHandle;
uint32_t d0;
d0 = Native::LoadResource(theType, resourceHandle,
d0 = Native::LoadResource(theType, resourceHandle,
[theType, name](){
return ::Get1NamedResource(theType, memoryPointer(name));
}
@ -304,12 +304,12 @@ namespace RM
std::string sname = ToolBox::ReadPString(name);
Log("%04x GetNamedResource(%08x ('%s'), %s)\n",
Log("%04x GetNamedResource(%08x ('%s'), %s)\n",
trap, theType, TypeToString(theType).c_str(), sname.c_str());
uint32_t resourceHandle;
uint32_t d0;
d0 = Native::LoadResource(theType, resourceHandle,
d0 = Native::LoadResource(theType, resourceHandle,
[theType, name](){
return ::GetNamedResource(theType, memoryPointer(name));
}
@ -342,13 +342,13 @@ namespace RM
sp = StackFrame<6>(theType, theID);
Log("%04x GetResource(%08x ('%s'), %04x)\n",
Log("%04x GetResource(%08x ('%s'), %04x)\n",
trap, theType, TypeToString(theType).c_str(), theID);
uint32_t resourceHandle;
uint32_t d0;
d0 = Native::LoadResource(theType, resourceHandle,
d0 = Native::LoadResource(theType, resourceHandle,
[theType, theID](){
return ::GetResource(theType, theID);
}
@ -387,7 +387,7 @@ namespace RM
uint32_t resourceHandle;
uint32_t d0;
d0 = Native::LoadResource(theType, resourceHandle,
d0 = Native::LoadResource(theType, resourceHandle,
[theType, theID](){
return ::Get1Resource(theType, theID);
}
@ -401,7 +401,7 @@ namespace RM
uint16_t ReleaseResource(uint16_t trap)
{
// ReleaseResource (theResource: Handle);
// ReleaseResource (theResource: Handle);
/*
* ------------
@ -496,7 +496,7 @@ namespace RM
{
if (creator || fileType)
OS::Internal::SetFinderInfo(path, fileType, creator);
close(fd);
}
@ -525,12 +525,12 @@ namespace RM
// PROCEDURE CreateResFile (fileName: Str255);
/*
* CreateResFile creates a resource file containing no resource
* data. If there's no file at all with the given name, it also
* creates an empty data fork for the file. If there's already a
* resource file with the given name (that is, a resource fork
* that isn't empty), CreateResFile will do nothing and the
* ResError function will return an appropriate Operating System
* CreateResFile creates a resource file containing no resource
* data. If there's no file at all with the given name, it also
* creates an empty data fork for the file. If there's already a
* resource file with the given name (that is, a resource fork
* that isn't empty), CreateResFile will do nothing and the
* ResError function will return an appropriate Operating System
* result code.
*/
@ -562,7 +562,7 @@ namespace RM
std::string sname = ToolBox::ReadPString(fileName, true);
Log("%04x HCreateResFile(%04x, %08x, %s)\n",
Log("%04x HCreateResFile(%04x, %08x, %s)\n",
trap, vRefNum, dirID, sname.c_str());
@ -597,8 +597,8 @@ namespace RM
int parentID = memoryReadLong(spec + 2);
std::string sname = ToolBox::ReadPString(spec + 6, false);
Log(" FSpCreateResFile(%s, %08x ('%s'), %08x ('%s'), %02x)\n",
sname.c_str(),
Log(" FSpCreateResFile(%s, %08x ('%s'), %08x ('%s'), %02x)\n",
sname.c_str(),
creator, ToolBox::TypeToString(creator).c_str(),
fileType, ToolBox::TypeToString(fileType).c_str(),
scriptTag);
@ -632,10 +632,10 @@ namespace RM
::FSGetResourceForkName(&fork);
refNum = -1;
error = ::FSOpenResourceFile(&ref,
error = ::FSOpenResourceFile(&ref,
fork.length,
fork.unicode,
permission,
permission,
&refNum);
if (error != noErr)
@ -647,7 +647,7 @@ namespace RM
uint16_t OpenResFile(uint16_t trap)
{
// OpenResFile (fileName: Str255) : INTEGER;
uint32_t sp;
uint32_t fileName;
@ -680,7 +680,7 @@ namespace RM
std::string sname = ToolBox::ReadPString(fileName, true);
Log("%04x HOpenResFile(%04x, %08x, %s, %04x)\n",
Log("%04x HOpenResFile(%04x, %08x, %s, %04x)\n",
trap, vRefNum, dirID, sname.c_str(), permission);
if (vRefNum) {
@ -766,10 +766,10 @@ namespace RM
::FSGetResourceForkName(&fork);
refNum = -1;
error = ::FSOpenResourceFile(&ref,
fork.length,
fork.unicode,
permission,
error = ::FSOpenResourceFile(&ref,
fork.length,
fork.unicode,
permission,
&refNum);
ToolReturn<2>(sp, (uint16_t)refNum);
@ -787,7 +787,7 @@ namespace RM
sp = StackFrame<4>(theType);
Log("%04x Count1Resources(%08x ('%s'))\n",
Log("%04x Count1Resources(%08x ('%s'))\n",
trap, theType, TypeToString(theType).c_str());
count = ::Count1Resources(theType);
@ -825,7 +825,7 @@ namespace RM
// set the resChanged attribute so when UpdateResFile() is called
// (or the app exits)
// (or the app exits)
// also needs to update the carbon handle/data with the mpw handle
// since the data has changed....
@ -932,7 +932,7 @@ namespace RM
if (!nativeHandle) return SetResError(MacOS::addResFailed);
std::memcpy(*(uint8_t **)nativeHandle, memoryPointer(info->address), info->size);
std::memcpy(*(uint8_t **)nativeHandle, memoryPointer(info->address), info->size);
rhandle_map.insert({theData, nativeHandle});
@ -1048,12 +1048,12 @@ namespace RM
uint16_t index;
sp = StackFrame<6>(theType, index);
Log("%04x Get1IndResource(%08x ('%s'), %04x)\n",
Log("%04x Get1IndResource(%08x ('%s'), %04x)\n",
trap, theType, TypeToString(theType).c_str(), index);
uint32_t resourceHandle = 0;
uint16_t d0;
d0 = Native::LoadResource(theType, resourceHandle,
d0 = Native::LoadResource(theType, resourceHandle,
[theType, index](){
return ::Get1IndResource(theType, index);
}
@ -1115,7 +1115,7 @@ namespace RM
uint16_t GetResInfo(uint16_t trap)
{
// PROCEDURE GetResInfo (theResource: Handle;
// PROCEDURE GetResInfo (theResource: Handle;
// VAR theID: INTEGER; VAR theType: ResType; VAR name: Str255);
uint32_t theResource;
@ -1134,7 +1134,7 @@ namespace RM
Handle nativeHandle = iter->second;
ResID nativeID = 0;
ResType nativeType = 0;
ResType nativeType = 0;
Str255 nativeName = {0};
::GetResInfo(nativeHandle, &nativeID, &nativeType, nativeName);
@ -1155,9 +1155,9 @@ namespace RM
// PROCEDURE LoadResource (theResource: Handle);
// this loads the resource from disk, if not already
// loaded. (if purgeable or SetResLoad(false))
// loaded. (if purgeable or SetResLoad(false))
// this needs cooperation with MM to check if
// this needs cooperation with MM to check if
// handle was purged.
OSErr err;
@ -1265,7 +1265,7 @@ namespace RM
Log("%04x Get1IndType(%08x, %04x)\n", trap, theType, index);
ResType nativeType = 0;
ResType nativeType = 0;
::Get1IndType(&nativeType, index);

View File

@ -6,7 +6,7 @@
namespace RM
{
namespace Native
namespace Native
{
uint16_t SetResLoad(bool tf);
uint16_t GetResource(uint32_t type, uint16_t id, uint32_t &theHandle);
@ -15,7 +15,7 @@ namespace RM
uint16_t CloseResFile(uint16_t trap);
uint16_t GetNamedResource(uint16_t trap);
uint16_t Get1NamedResource(uint16_t trap);
uint16_t GetResource(uint16_t trap);
uint16_t Get1Resource(uint16_t trap);
uint16_t Get1IndResource(uint16_t trap);
@ -64,4 +64,4 @@ namespace RM
}
#endif
#endif

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -103,7 +103,7 @@ using std::to_string;
// long double is an 80-bit extended with an extra 48-bits of 0 padding.
typedef long double extended;
// comp is an int64_t but 0x8000_0000_0000_0000 is NaN
// comp is an int64_t but 0x8000_0000_0000_0000 is NaN
//typedef int64_t complex;
struct complex {
@ -215,7 +215,7 @@ using std::to_string;
std::string to_string(complex c)
{
if (c.isnan()) return std::string("nan");
return std::to_string((int64_t)c);
}
@ -289,7 +289,7 @@ using std::to_string;
// now cast...
return *((long double *)buffer);
return *((long double *)buffer);
}
@ -312,13 +312,13 @@ using std::to_string;
void writenum<int64_t>(int64_t value, uint32_t address)
{
memoryWriteLongLong(value, address);
}
}
template<>
void writenum<complex>(complex value, uint32_t address)
{
memoryWriteLongLong(value, address);
}
}
template<>
void writenum<float>(float value, uint32_t address)
@ -326,7 +326,7 @@ using std::to_string;
static_assert(sizeof(value) == 4, "unexpected float size");
memoryWriteLong(*((uint32_t *)&value), address);
}
}
template<>
void writenum<double>(double value, uint32_t address)
@ -334,7 +334,7 @@ using std::to_string;
static_assert(sizeof(value) == 8, "unexpected double size");
memoryWriteLongLong(*((uint64_t *)&value), address);
}
}
template<>
void writenum<long double>(long double value, uint32_t address)
@ -349,7 +349,7 @@ using std::to_string;
// little-endian specific.
for(unsigned i = 0; i < 10; ++i)
memoryWriteByte(buffer[9 - i], address + i);
}
}
@ -639,7 +639,7 @@ using std::to_string;
// TODO -- verify if src/dest are backwards here
//
//
// check if ordered...
@ -724,7 +724,7 @@ using std::to_string;
inline int classify(float x) { return std::fpclassify(x); }
inline int classify(double x) { return std::fpclassify(x); }
inline int classify(extended x) { return std::fpclassify(x); }
inline int classify(complex c) {
inline int classify(complex c) {
if (c.isnan()) return FP_NAN;
if ((uint64_t)c == (uint64_t)0) return FP_ZERO;
return FP_NORMAL;
@ -735,15 +735,15 @@ using std::to_string;
inline int sign(extended x) { return std::signbit(x); }
inline int sign(complex c) {
if (c.isnan()) return 0;
return ((int64_t)c < (int64_t)0) ? 1 : 0;
return ((int64_t)c < (int64_t)0) ? 1 : 0;
}
template <class SrcType>
uint16_t fclassify(const char *name)
{
/*
* The classify operations set the sign of the destination to
* the sign of the source and the value of the destination
* The classify operations set the sign of the destination to
* the sign of the source and the value of the destination
* according to the class of the source, as shown in Table E-18.
* The destination is an integer variable. (pg 273)
*
@ -821,9 +821,9 @@ using std::to_string;
/*
* environment is a uint16_t *.
* void setenvironment(environment e);
* void setenvironment(environment e);
* void getenvironment(environment *e);
* void procentry(environment *e);
* void procentry(environment *e);
* void procexit(environment e);
*/
@ -916,7 +916,7 @@ using std::to_string;
case 0x1002: return fsub<float>("FSUBS");
//case 0x3002: return fsub<complex>("FSUBC");
case 0x2002: return fsub<int16_t>("FSUBI");
case 0x2802: return fsub<int32_t>("FSUBL");
case 0x2802: return fsub<int32_t>("FSUBL");
// multiplication
case 0x0004: return fmul<extended>("FMULX");
@ -993,7 +993,7 @@ using std::to_string;
uint16_t NumToString(void)
{
/*
/*
* on entry:
* A0 Pointer to pascal string
* D0 The number
@ -1019,7 +1019,7 @@ using std::to_string;
uint32_t StringToNum(void)
{
/*
/*
* on entry:
* A0 Pointer to pascal string
*
@ -1067,7 +1067,7 @@ using std::to_string;
uint32_t fpstr2dec()
{
// void str2dec(const char *s,short *ix,decimal *d,short *vp);
// void str2dec(const char *s,short *ix,decimal *d,short *vp);
#if 0
#define SIGDIGLEN 20 /* significant decimal digits */
@ -1089,7 +1089,7 @@ struct decimal {
uint32_t indexPtr;
uint32_t decimalPtr;
uint32_t validPtr;
uint16_t valid;
uint16_t index;
decimal d;
@ -1117,7 +1117,7 @@ struct decimal {
int over = d.sig.length() - 20;
d.sig.resize(20);
d.exp += over;
}
}
memoryWriteByte(d.sgn, decimalPtr);
memoryWriteByte(0, decimalPtr + 1);
@ -1142,7 +1142,7 @@ struct decimal {
case 0x00:
return NumToString();
break;
case 0x01:
return StringToNum();
break;

View File

@ -4,7 +4,7 @@
#include <cstdint>
#include <utility>
//
//
template<int Bytes>
@ -117,4 +117,4 @@ uint32_t StackFrame(Args&&... args)
#endif
#endif

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -38,7 +38,7 @@
#include <macos/traps.h>
#include <macos/errors.h>
#include "toolbox.h"
#include "loader.h"
@ -100,9 +100,9 @@ namespace ToolBox {
return Process::GetProcessInformation();
default:
fprintf(stderr, "OSDispatch: selector %04x not implemented\n",
fprintf(stderr, "OSDispatch: selector %04x not implemented\n",
selector);
exit(1);
exit(1);
}
}
@ -164,7 +164,7 @@ namespace ToolBox {
case 0xa011:
d0 = OS::GetEOF(trap);
break;
case 0xa012:
d0 = OS::SetEOF(trap);
break;
@ -188,7 +188,7 @@ namespace ToolBox {
case 0xa215: // HSetVol
d0 = OS::HSetVol(trap);
break;
case 0xa018:
d0 = OS::GetFPos(trap);
@ -205,7 +205,7 @@ namespace ToolBox {
case 0xa060:
d0 = OS::FSDispatch(trap);
break;
case 0xa260:
d0 = OS::HFSDispatch(trap);
break;
@ -295,7 +295,7 @@ namespace ToolBox {
case 0xA01C:
d0 = MM::FreeMem(trap);
break;
// CompactMem (cbNeeded: Size) : Size;
case 0xa04c:
d0 = MM::CompactMem(trap);
@ -341,7 +341,7 @@ namespace ToolBox {
case 0xa11a:
d0 = MM::GetZone(trap);
break;
case 0xa01b:
d0 = MM::SetZone(trap);
break;
@ -372,7 +372,7 @@ namespace ToolBox {
case 0xa9c6:
d0 = OS::SecondsToDate(trap);
break;
// TickCount : LONGINT;
case 0xa975:
d0 = OS::TickCount(trap);
@ -422,7 +422,7 @@ namespace ToolBox {
case 0xA027:
d0 = MM::ReallocHandle(trap);
break;
case 0xA02B:
d0 = MM::EmptyHandle(trap);
break;
@ -541,7 +541,7 @@ namespace ToolBox {
case 0xa9a5:
d0 = RM::GetResourceSizeOnDisk(trap);
break;
case 0xa9a6:
d0 = RM::GetResAttrs(trap);
break;
@ -565,7 +565,7 @@ namespace ToolBox {
case 0xa9ad:
d0 = RM::RemoveResource(trap);
break;
// ResError : INTEGER;
case 0xa9af:
d0 = RM::ResError(trap);
@ -694,7 +694,7 @@ namespace ToolBox {
return tmp;
}
std::string ReadPString(uint32_t address, bool fname)
{
std::string tmp;
@ -702,11 +702,11 @@ namespace ToolBox {
if (address)
{
unsigned length = memoryReadByte(address);
tmp.assign((char *)memoryPointer(address + 1), length);
if (fname) tmp = MacToUnix(tmp);
}
return tmp;

View File

@ -41,4 +41,4 @@ namespace ToolBox
}
#endif
#endif

View File

@ -3,13 +3,13 @@
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -44,7 +44,7 @@ namespace Utility {
uint16_t NewString(uint16_t trap)
{
/*
* NewString allocates the specified string as a relocatable object
* NewString allocates the specified string as a relocatable object
* in the heap and returns a handle to it.
*/
@ -83,9 +83,9 @@ namespace Utility {
uint16_t GetString(uint16_t trap)
{
/*
* The GetString function loads a string from a string ('STR ')
* resource into memory. It returns a handle to the string with the
* specified resource ID, reading it from the resource file if
* The GetString function loads a string from a string ('STR ')
* resource into memory. It returns a handle to the string with the
* specified resource ID, reading it from the resource file if
* necessary.
*/
@ -107,9 +107,9 @@ namespace Utility {
// FUNCTION BitTst (bytePtr: Ptr; bitNum: LONGINT) : BOOLEAN;
uint16_t BitTst(uint16_t trap)
{
/*
* BitTst tests whether a given bit is set and returns TRUE if so or
* FALSE if not. The bit is specified by bitNum, an offset from the
/*
* BitTst tests whether a given bit is set and returns TRUE if so or
* FALSE if not. The bit is specified by bitNum, an offset from the
* high-order bit of the byte pointed to by bytePtr.
*/