diff --git a/toolbox/loader.cpp b/toolbox/loader.cpp index 8ab5e42..8589ccb 100644 --- a/toolbox/loader.cpp +++ b/toolbox/loader.cpp @@ -43,6 +43,9 @@ #include "mm.h" #include +#include + +using MacOS::tool_return; enum { fsCurPerm = 0x00, /* open access permissions in ioPermssn */ @@ -155,7 +158,7 @@ namespace Loader { // load code seg 0. - uint16_t LoadCode0(Segment0Info &rv) + tool_return LoadCode0(Segment0Info &rv) { uint32_t rHandle; uint32_t size; @@ -208,11 +211,11 @@ namespace Loader { rv.jtEnd = rv.jtStart + rv.jtSize; // TODO -- should ReleaseResource on rHandle. - return 0; + return MacOS::noErr; } // load a standard code segment. - uint16_t LoadCode(uint16_t segment) + tool_return LoadCode(uint16_t segment) { SegmentInfo si; @@ -238,7 +241,7 @@ namespace Loader { Segments[segment] = si; - return 0; + return MacOS::noErr; } @@ -247,10 +250,10 @@ namespace Loader { namespace Native { - uint16_t LoadFile(const std::string &path) + tool_return LoadFile(const std::string &path) { - uint16_t err; + tool_return err; // open the file // load code seg 0 @@ -267,6 +270,7 @@ namespace Loader { // load code 0. Segment0Info seg0; err = LoadCode0(seg0); + if (!err) return err; // iterate through the jump table to get the other // code segments to load @@ -304,7 +308,7 @@ namespace Loader { if (seg >= Segments.size() || Segments[seg].address == 0) { err = LoadCode(seg); - if (err) return err; + if (!err) return err; const auto &p = Segments[seg]; if (p.farModel) @@ -360,7 +364,7 @@ namespace Loader { - return 0; + return MacOS::noErr; } diff --git a/toolbox/loader.h b/toolbox/loader.h index 0b6b63e..de9d0b5 100644 --- a/toolbox/loader.h +++ b/toolbox/loader.h @@ -6,11 +6,16 @@ #include +#include + + namespace Loader { typedef std::map> DebugNameTable; namespace Native { + using MacOS::tool_return; + /* * loads the file * sets registers PC and A5. @@ -18,7 +23,7 @@ namespace Loader { * * Dependencies: MM, RM */ - uint16_t LoadFile(const std::string &path); + tool_return LoadFile(const std::string &path); // scans segments for MacsBug debug names. // associates them with the start of the segment.