Release 980517
[wine/multimedia.git] / miscemu / main.c
blob1f53c89f757a08fbcbcf763d25625a7b3d4668b6
1 /*
2 * Emulator initialisation code
4 */
6 #include "windows.h"
7 #include "callback.h"
8 #include "debugger.h"
9 #include "main.h"
10 #include "miscemu.h"
11 #include "module.h"
12 #include "options.h"
13 #include "debug.h"
16 /***********************************************************************
17 * Emulator initialisation
19 BOOL32 MAIN_EmulatorInit(void)
21 extern BOOL32 WIN16DRV_Init(void);
22 extern BOOL32 RELAY_Init(void);
24 /* Initialize the kernel */
25 if (!MAIN_KernelInit()) return FALSE;
27 /* Initialize relay code */
28 if (!RELAY_Init()) return FALSE;
30 /* Initialize signal handling */
31 if (!SIGNAL_InitEmulator()) return FALSE;
33 /* Create the Win16 printer driver */
34 if (!WIN16DRV_Init()) return FALSE;
36 /* Initialize all the USER stuff */
37 return MAIN_UserInit();
41 /**********************************************************************
42 * main
44 int main( int argc, char *argv[] )
46 extern BOOL32 PROCESS_Init(void);
47 extern void *CALL32_Init(void);
48 extern char * DEBUG_argv0;
50 int i,loaded;
51 HINSTANCE32 handle;
53 __winelib = 0; /* First of all, clear the Winelib flag */
56 * Save this so that the internal debugger can get a hold of it if
57 * it needs to.
59 DEBUG_argv0 = argv[0];
61 /* Create the initial process */
62 if (!PROCESS_Init()) return FALSE;
64 /* Parse command-line */
65 if (!MAIN_WineInit( &argc, argv )) return 1;
67 /* Handle -dll option (hack) */
69 if (Options.dllFlags)
71 if (!BUILTIN_ParseDLLOptions( Options.dllFlags ))
73 MSG("%s: Syntax: -dll +xxx,... or -dll -xxx,...\n",
74 argv[0] );
75 BUILTIN_PrintDLLs();
76 exit(1);
80 /* Initialize everything */
82 if (!MAIN_EmulatorInit()) return 1;
84 /* Initialize CALL32 routines */
85 /* This needs to be done just before task-switching starts */
86 IF1632_CallLargeStack = (int (*)(int (*func)(), void *arg))CALL32_Init();
88 loaded=0;
89 for (i = 1; i < argc; i++)
91 if ((handle = WinExec32( argv[i], SW_SHOWNORMAL )) < 32)
93 MSG("wine: can't exec '%s': ", argv[i]);
94 switch (handle)
96 case 2: MSG("file not found\n" ); break;
97 case 11: MSG("invalid exe file\n" ); break;
98 case 21: MSG("win32 executable\n" ); break; /* FIXME: Obsolete? */
99 default: MSG("error=%d\n", handle ); break;
101 return 1;
103 loaded++;
106 if (!loaded) { /* nothing loaded */
107 MAIN_Usage(argv[0]);
108 return 1;
111 if (!GetNumTasks())
113 MSG("wine: no executable file found.\n" );
114 return 0;
117 if (Options.debug) DEBUG_AddModuleBreakpoints();
119 Yield16(); /* Start the first task */
120 MSG("WinMain: Should never happen: returned from Yield16()\n" );
121 return 0;