Separated the MZ loader and core DOS VM into dlls/winedos.
[wine] / miscemu / main.c
1 /*
2  * Emulator initialisation code
3  *
4  */
5
6 #include "winbase.h"
7 #include "wine/winbase16.h"
8 #include "wingdi.h"
9 #include "winuser.h"
10
11 #include "miscemu.h"
12 #include "callback.h"
13 #include "options.h"
14 #include "dosexe.h"
15 #include "debugtools.h"
16
17 extern void PROCESS_InitWine( int argc, char *argv[] ) WINE_NORETURN;
18
19 /***********************************************************************
20  *           Main loop of initial task
21  */
22 int WINAPI wine_initial_task( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, INT show )
23 {
24     MSG msg;
25     HINSTANCE16 instance;
26
27     if (!LoadLibraryA( "user32.dll" ))
28     {
29         MESSAGE( "Cannot load user32.dll\n" );
30         ExitProcess( GetLastError() );
31     }
32     THUNK_InitCallout();
33
34     if ((instance = WinExec16( GetCommandLineA(), show )) < 32)
35     {
36         if (instance == 11)  /* try DOS format */
37         {
38             if (DPMI_LoadDosSystem())
39                 Dosvm.LoadDosExe( GetCommandLineA() );
40             /* if we get back here it failed */
41             instance = GetLastError();
42         }
43
44         MESSAGE( "%s: can't exec '%s': ", argv0, GetCommandLineA() );
45         switch (instance) 
46         {
47         case  2: MESSAGE("file not found\n" ); break;
48         case 11: MESSAGE("invalid exe file\n" ); break;
49         default: MESSAGE("error=%d\n", instance ); break;
50         }
51         ExitProcess(instance);
52     }
53
54     /* Start message loop for desktop window */
55
56     while ( GetNumTasks16() > 1  && Callout.GetMessageA( &msg, 0, 0, 0 ) )
57     {
58         Callout.TranslateMessage( &msg );
59         Callout.DispatchMessageA( &msg );
60     }
61
62     ExitProcess( 0 );
63 }
64
65
66 /**********************************************************************
67  *           main
68  */
69 int main( int argc, char *argv[] )
70 {
71     PROCESS_InitWine( argc, argv );
72     return 1;  /* not reached */
73 }