-
Notifications
You must be signed in to change notification settings - Fork 0
/
Startup.c
53 lines (43 loc) · 1.27 KB
/
Startup.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <exec/exec.h>
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <workbench/startup.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include "NoClick.h"
#if defined(__MORPHOS__)
ULONG __abox__ = 1;
#endif
#if defined(__amigaos4__)
// Must be named _start in AmigaOS4 binaries.
int32 _start(STRPTR args, int32 argsLength, struct ExecBase *sysBase) {
struct ExecIFace *IExec = (struct ExecIFace *) sysBase->MainInterface;
IExec->Obtain();
#else
// In 68k AmigaOS and MorphOS binaries, the symbol name doesn't matter, it just have to be first.
LONG Startup(void) {
struct ExecBase *SysBase = *(struct ExecBase **) 4;
#endif
struct WBStartup *wbStartupMsg = NULL;
struct Process *thisProcess = (void *) FindTask(NULL);
if (0 == thisProcess->pr_CLI) {
// If started from Workbench, get the startup message
WaitPort(&thisProcess->pr_MsgPort);
wbStartupMsg = (void *) GetMsg(&thisProcess->pr_MsgPort);
}
#if defined(__amigaos4__)
NoClick(IExec);
#else
NoClick(SysBase);
#endif
if(NULL != wbStartupMsg) {
// This is so Workbench won't unload our segment before we exit
Forbid();
// If started from Workbench, reply to the startup message
ReplyMsg((void *) wbStartupMsg);
}
#if defined(__amigaos4__)
IExec->Release();
#endif
return RETURN_OK;
}