LaunchAPPLServer: now for System 6 / Multifinder

This commit is contained in:
Wolfgang Thaller 2018-04-27 00:50:52 +02:00
parent 692fcc073c
commit d91c257d89

View File

@ -333,6 +333,7 @@ public:
short outRefNum; short outRefNum;
long outSize, outSizeRemaining; long outSize, outSizeRemaining;
MacSerialStream *gSerialStream; MacSerialStream *gSerialStream;
int nullEventCounter = 0;
void SetBaud(long baud) void SetBaud(long baud)
{ {
@ -424,23 +425,27 @@ int main()
break; break;
} }
} }
else
nullEventCounter++;
stream.idle(); stream.idle();
if(server.state == LaunchServer::State::launch) if(server.state == LaunchServer::State::launch)
{ {
//stream.close(); //
{ {
LaunchParamBlockRec lpb; LaunchParamBlockRec lpb;
memset(&lpb, 0, sizeof(lpb)); memset(&lpb, 0, sizeof(lpb));
/* lpb.reserved1 = (unsigned long) "\pRetro68App"; #if 1
lpb.reserved1 = (unsigned long) "\pRetro68App";
lpb.reserved2 = 0; lpb.reserved2 = 0;
lpb.launchBlockID = extendedBlock; lpb.launchBlockID = extendedBlock;
lpb.launchEPBLength = 6; lpb.launchEPBLength = 6;
lpb.launchFileFlags = 0; lpb.launchFileFlags = 0;
lpb.launchControlFlags = 0xC000;*/ lpb.launchControlFlags = 0xC000;
// stream.close();
#else
FSSpec spec; FSSpec spec;
FSMakeFSSpec(0,0,"\pRetro68App",&spec); FSMakeFSSpec(0,0,"\pRetro68App",&spec);
lpb.launchBlockID = extendedBlock; lpb.launchBlockID = extendedBlock;
@ -448,21 +453,59 @@ int main()
lpb.launchFileFlags = 0; lpb.launchFileFlags = 0;
lpb.launchControlFlags = launchContinue; lpb.launchControlFlags = launchContinue;
lpb.launchAppSpec = &spec; lpb.launchAppSpec = &spec;
#endif
OSErr err = LaunchApplication(&lpb); OSErr err = LaunchApplication(&lpb);
if(err < 0)
{
server.state = LaunchServer::State::size;
SetStatus(AppStatus::ready, 0, 0);
}
else
{
psn = lpb.launchProcessSN; psn = lpb.launchProcessSN;
server.state = LaunchServer::State::wait; server.state = LaunchServer::State::wait;
nullEventCounter = 0;
SetStatus(AppStatus::running, 0, 0); SetStatus(AppStatus::running, 0, 0);
} }
} }
else if(server.state == LaunchServer::State::wait) }
else if(server.state == LaunchServer::State::wait && nullEventCounter > 3)
{ {
bool running = false;
#if 0
ProcessInfoRec info; ProcessInfoRec info;
memset(&info, 0, sizeof(info));
info.processInfoLength = sizeof(info);
OSErr err = GetProcessInformation(&psn,&info); OSErr err = GetProcessInformation(&psn,&info);
if(err) running = (err == noErr);
#else
{
uint8_t *fcbs = *(uint8_t**)0x34E; // FCBSPtr;
uint16_t bufSize = * (uint16_t*) fcbs;
uint8_t *end = fcbs + bufSize;
for(uint8_t *fcb = fcbs + 2; fcb < end; fcb += 94)
{
if(*(uint32_t*) fcb == 0)
continue;
if(*(OSType*) (fcb + 0x32) != 'APPL')
continue;
if(EqualString(fcb + 0x3E, "\pRetro68App", true, true))
{
running = true;
break;
}
}
}
#endif
if(!running)
{ {
server.state = LaunchServer::State::respond; server.state = LaunchServer::State::respond;
uint32_t zero = 0; uint32_t zero = 0;
@ -500,6 +543,9 @@ int main()
rStream.reset(0); rStream.reset(0);
} }
} }
//if(someoneExited)
// SetStatus(AppStatus::running, 50, 100);
} }
return 0; return 0;
} }