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,6 +399,20 @@ int main()
InitMenus(); InitMenus();
TEInit(); TEInit();
InitDialogs(NULL); InitDialogs(NULL);
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 #endif
SetMenuBar(GetNewMBar(128)); SetMenuBar(GetNewMBar(128));
@ -445,15 +459,21 @@ int main()
{ {
EventRecord e; EventRecord e;
WindowRef win; WindowRef win;
Boolean hadEvent;
#if 0 && !TARGET_API_MAC_CARBON #if !TARGET_API_MAC_CARBON
if(!hasWaitNextEvent)
{
SystemTask(); SystemTask();
if(GetNextEvent(everyEvent, &e)) hadEvent = GetNextEvent(everyEvent, &e);
#else }
// actually, we should be using WaitNextEvent else
// on everything starting from System 7
if(WaitNextEvent(everyEvent, &e, 10, NULL))
#endif #endif
{
hadEvent = WaitNextEvent(everyEvent, &e, 10, NULL);
}
if(hadEvent)
{ {
switch(e.what) switch(e.what)
{ {