LaunchAPPLServer System 4 compatibility: check for WNE availability

This commit is contained in:
Wolfgang Thaller 2018-05-02 01:47:33 +02:00
parent 1871a9cbad
commit c3dd084fbf

View File

@ -26,7 +26,7 @@
#include <TextUtils.h> #include <TextUtils.h>
#include <Dialogs.h> #include <Dialogs.h>
#include <Devices.h> #include <Devices.h>
#include <Traps.h>
#include "MacSerialStream.h" #include "MacSerialStream.h"
#include "AppLauncher.h" #include "AppLauncher.h"
@ -399,8 +399,22 @@ int main()
InitMenus(); InitMenus();
TEInit(); TEInit();
InitDialogs(NULL); InitDialogs(NULL);
#endif
short& ROM85 = *(short*) 0x028E;
Boolean is128KROM = (ROM85 > 0);
Boolean hasSysEnvirons = false;
Boolean hasWaitNextEvent = false;
if (is128KROM)
{
UniversalProcPtr trapSysEnv = GetOSTrapAddress(_SysEnvirons);
UniversalProcPtr trapWaitNextEvent = GetToolTrapAddress(_WaitNextEvent);
UniversalProcPtr trapUnimpl = GetToolTrapAddress(_Unimplemented);
hasSysEnvirons = (trapSysEnv != trapUnimpl);
hasWaitNextEvent = (trapWaitNextEvent != trapUnimpl);
}
#endif
SetMenuBar(GetNewMBar(128)); SetMenuBar(GetNewMBar(128));
AppendResMenu(GetMenu(128), 'DRVR'); AppendResMenu(GetMenu(128), 'DRVR');
DrawMenuBar(); DrawMenuBar();
@ -445,15 +459,21 @@ int main()
{ {
EventRecord e; EventRecord e;
WindowRef win; WindowRef win;
Boolean hadEvent;
#if 0 && !TARGET_API_MAC_CARBON
SystemTask(); #if !TARGET_API_MAC_CARBON
if(GetNextEvent(everyEvent, &e)) if(!hasWaitNextEvent)
#else {
// actually, we should be using WaitNextEvent SystemTask();
// on everything starting from System 7 hadEvent = GetNextEvent(everyEvent, &e);
if(WaitNextEvent(everyEvent, &e, 10, NULL)) }
else
#endif #endif
{
hadEvent = WaitNextEvent(everyEvent, &e, 10, NULL);
}
if(hadEvent)
{ {
switch(e.what) switch(e.what)
{ {