diff --git a/LaunchAPPL/Server/LaunchAPPLServer.cc b/LaunchAPPL/Server/LaunchAPPLServer.cc index acf66311db..dad0fcd772 100644 --- a/LaunchAPPL/Server/LaunchAPPLServer.cc +++ b/LaunchAPPL/Server/LaunchAPPLServer.cc @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include "MacSerialStream.h" #include "AppLauncher.h" @@ -438,21 +440,30 @@ int main() Boolean is128KROM = (ROM85 > 0); Boolean hasSysEnvirons = false; Boolean hasWaitNextEvent = false; + Boolean hasGestalt = false; Boolean hasAppleEvents = false; if (is128KROM) { UniversalProcPtr trapUnimpl = GetToolTrapAddress(_Unimplemented); UniversalProcPtr trapSysEnv = GetOSTrapAddress(_SysEnvirons); UniversalProcPtr trapWaitNextEvent = GetToolTrapAddress(_WaitNextEvent); - UniversalProcPtr trapAppleEvents = GetToolTrapAddress(_Pack8); + UniversalProcPtr trapGestalt = GetOSTrapAddress(_Gestalt); hasSysEnvirons = (trapSysEnv != trapUnimpl); hasWaitNextEvent = (trapWaitNextEvent != trapUnimpl); - hasAppleEvents = (trapAppleEvents != trapUnimpl); + hasGestalt = (trapGestalt != trapUnimpl); + + if(hasGestalt) + { + long response = 0; + OSErr err = Gestalt(gestaltAppleEventsAttr, &response); + hasAppleEvents = err == noErr && response != 0; + } } #else const Boolean hasSysEnvirons = true; const Boolean hasWaitNextEvent = true; + const Boolean hasGestalt = true; const Boolean hasAppleEvents = true; #endif @@ -574,6 +585,7 @@ int main() if(server.state == LaunchServer::State::launch) { gSerialStream->close(); + UnloadSeg((void*) &MacSerialStream::unloadSegDummy); gPrefs.inSubLaunch = true; WritePrefs(); @@ -621,6 +633,9 @@ int main() { if(!appLauncher->IsRunning("\pRetro68App")) { + appLauncher.reset(); + UnloadSeg((void*) &CreateAppLauncher); + UnloadSeg((void*) &CreateToolLauncher); gSerialStream->open(); StartResponding(server, rStream); } diff --git a/LaunchAPPL/Server/MacSerialStream.cc b/LaunchAPPL/Server/MacSerialStream.cc index 2fc760437c..0dec27d7f2 100644 --- a/LaunchAPPL/Server/MacSerialStream.cc +++ b/LaunchAPPL/Server/MacSerialStream.cc @@ -96,3 +96,7 @@ void MacSerialStream::setBaud(int baud) else if(baud == 230400) Control(outRefNum, kSERD230KBaud, nullptr); } + +void MacSerialStream::unloadSegDummy() +{ +} diff --git a/LaunchAPPL/Server/MacSerialStream.h b/LaunchAPPL/Server/MacSerialStream.h index 92d62069d5..609be7a54d 100644 --- a/LaunchAPPL/Server/MacSerialStream.h +++ b/LaunchAPPL/Server/MacSerialStream.h @@ -24,6 +24,8 @@ public: void open(); void setBaud(int baud); + + static void unloadSegDummy(); }; #endif