Replaced PTR_SEG_TO_LIN macro by exported MapSL function.
[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 "callback.h"
12 #include "options.h"
13 #include "dosexe.h"
14 #include "debugtools.h"
15
16 extern void PROCESS_InitWine( int argc, char *argv[] ) WINE_NORETURN;
17
18 /***********************************************************************
19  *           Main loop of initial task
20  */
21 void wine_initial_task(void)
22 {
23     MSG msg;
24     HINSTANCE16 instance;
25     STARTUPINFOA info;
26
27     if (!LoadLibraryA( "user32.dll" ))
28     {
29         MESSAGE( "Cannot load user32.dll\n" );
30         ExitProcess( GetLastError() );
31     }
32     THUNK_InitCallout();
33
34     GetStartupInfoA( &info );
35     if (!(info.dwFlags & STARTF_USESHOWWINDOW)) info.wShowWindow = SW_SHOWNORMAL;
36
37     if ((instance = WinExec16( GetCommandLineA(), info.wShowWindow )) < 32)
38     {
39         if (instance == 11)  /* try DOS format */
40         {
41             MZ_LoadImage( GetCommandLineA() );
42             /* if we get back here it failed */
43             instance = GetLastError();
44         }
45
46         MESSAGE( "%s: can't exec '%s': ", argv0, GetCommandLineA() );
47         switch (instance) 
48         {
49         case  2: MESSAGE("file not found\n" ); break;
50         case 11: MESSAGE("invalid exe file\n" ); break;
51         default: MESSAGE("error=%d\n", instance ); break;
52         }
53         ExitProcess(instance);
54     }
55
56     /* Start message loop for desktop window */
57
58     while ( GetNumTasks16() > 1  && Callout.GetMessageA( &msg, 0, 0, 0 ) )
59     {
60         Callout.TranslateMessage( &msg );
61         Callout.DispatchMessageA( &msg );
62     }
63
64     ExitProcess( 0 );
65 }
66
67
68 /**********************************************************************
69  *           main
70  */
71 int main( int argc, char *argv[] )
72 {
73     PROCESS_InitWine( argc, argv );
74     return 1;  /* not reached */
75 }