2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
13 #define __PILOT_CODE__
16 extern void main_init(void * memory
, Long size
);
19 static Boolean
MainFormHandleEvent (EventPtr e
)
21 Boolean handled
= false;
24 Long MEMSIZE
= 0x9500;
29 frm
= FrmGetActiveForm();
32 mem
= MemPtrNew(MEMSIZE
);
34 * Memory must be properly aligned!
36 (Long
)mem
= ((Long
)mem
+ 7) & ~7;
37 if (0 != mem
&& 0 == ((Long
)mem
& 7)) {
39 main_init(mem
,MEMSIZE
);
46 MenuEraseStatus(NULL
);
48 switch(e
->data
.menu
.itemID
) {
55 switch(e
->data
.ctlSelect
.controlID
) {
68 static Boolean
ApplicationHandleEvent(EventPtr e
)
72 Boolean handled
= false;
74 if (e
->eType
== frmLoadEvent
) {
75 formId
= e
->data
.frmLoad
.formID
;
76 frm
= FrmInitForm(formId
);
77 FrmSetActiveForm(frm
);
81 FrmSetEventHandler(frm
, MainFormHandleEvent
);
90 /* Get preferences, open (or create) app database */
91 static Word
StartApplication(void)
93 FrmGotoForm(MainForm
);
97 /* Save preferences, close forms, close app database */
98 static void StopApplication(void)
104 /* The main event loop */
105 static void EventLoop(void)
111 EvtGetEvent(&e
, evtWaitForever
);
112 if (! SysHandleEvent (&e
))
113 if (! MenuHandleEvent (NULL
, &e
, &err
))
114 if (! ApplicationHandleEvent (&e
))
115 FrmDispatchEvent (&e
);
116 } while (e
.eType
!= appStopEvent
);
121 /* Main entry point; it is unlikely you will need to change this except to
122 handle other launch command codes */
123 DWord
PilotMain(Word cmd
, Ptr cmdPBP
, Word launchFlags
)
128 if (cmd
== sysAppLaunchCmdNormalLaunch
) {
130 err
= StartApplication();
137 return sysErrParamErr
;