1 /* $Id: init.c,v 1.2 2004-05-19 02:39:21 btb Exp $ */
16 extern HINSTANCE hInst;
18 extern LPDIRECTDRAW lpDD;
19 extern LPDIRECTDRAWSURFACE lpDDSPrimary;
20 extern LPDIRECTDRAWSURFACE lpDDSOne;
21 extern LPDIRECTDRAWPALETTE lpDDPal;
23 extern int Inferno_verbose;
25 static int mouse_hidden=0;
27 static void finiObjects()
31 if(lpDDSPrimary!=NULL)
33 IDirectDrawSurface_Release(lpDDSPrimary);
38 IDirectDrawSurface_Unlock(lpDDSOne,NULL);
39 IDirectDrawSurface_Release(lpDDSOne);
44 IDirectDrawSurface_Release(lpDDPal);
47 IDirectDrawSurface_Release(lpDD);
54 //extern unsigned int key_wparam, key_lparam, key_msg;
55 void keyboard_handler();
56 extern int WMKey_Handler_Ready;
58 void PumpMessages(void)
62 while (PeekMessage(&msg,NULL,0,0,PM_REMOVE|PM_NOYIELD))
64 TranslateMessage(&msg);
65 DispatchMessage(&msg);
69 long PASCAL DescentWndProc(HWND hWnd,UINT message,
70 WPARAM wParam,LPARAM lParam )
77 if (WMKey_Handler_Ready) {
78 // key_wparam=wParam; key_lparam=lParam; key_msg=message;
88 case WM_NCLBUTTONDOWN:
90 case WM_NCRBUTTONDOWN:
93 case WM_PALETTECHANGED:
94 case WM_PALETTEISCHANGING:
97 // Win32_Key_Hook(wParam);
98 // DPH: This doesn't work... no idea why not...
105 return DefWindowProc(hWnd,message,wParam,lParam);
108 void arch_init_start()
112 if (FindArg("-memdbg"))
113 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | /* _CRTDBG_CHECK_ALWAYS_DF | */
114 /*_CRTDBG_CHECK_CRT_DF |*/
115 _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
120 extern void key_init(void);
121 extern void mouse_init(void);
122 //added/changed 3/7/99 Owen Evans (next line)
123 extern void joy_init(int joyid);
129 WNDCLASS wcDescentClass;
131 wcDescentClass.lpszClassName = "WinD1X";
132 wcDescentClass.hInstance = hInst;
133 wcDescentClass.lpfnWndProc = DescentWndProc;
134 wcDescentClass.hCursor = LoadCursor(NULL, IDC_ARROW);
135 wcDescentClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
136 wcDescentClass.lpszMenuName = NULL;
137 wcDescentClass.hbrBackground = NULL;
138 wcDescentClass.style = CS_HREDRAW | CS_VREDRAW;
139 wcDescentClass.cbClsExtra = 0;
140 wcDescentClass.cbWndExtra = 0;
142 // Register the class
143 RegisterClass(&wcDescentClass);
144 g_hWnd = CreateWindowEx(0,
147 WS_OVERLAPPED | WS_BORDER,
149 GetSystemMetrics(SM_CXSCREEN),
150 GetSystemMetrics(SM_CYSCREEN),
157 if (!g_hWnd) return; // CRAP!
158 ShowWindow(g_hWnd,SW_SHOWNORMAL);
159 UpdateWindow(g_hWnd);
162 ddrval=DirectDrawCreate(NULL,&lpDD,NULL);
166 fprintf(stderr,"DirectDrawCreate() failed!\n");
170 if (FindArg("-semiwin"))
171 ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd,DDSCL_NORMAL);
175 ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd,
176 DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT);
178 ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd,
179 DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT);
185 fprintf(stderr,"SetCooperativeLevel() failed\n");
192 SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS);
196 //added/changed 3/7/99 Owen Evans (next line)
197 joy_init(JOYSTICKID1);
198 printf("arch_init successfully completed\n");