1 /* $Id: init.c,v 1.3 2004-05-20 23:06:24 btb Exp $ */
17 extern HINSTANCE hInst;
19 extern LPDIRECTDRAW lpDD;
20 extern LPDIRECTDRAWSURFACE lpDDSPrimary;
21 extern LPDIRECTDRAWSURFACE lpDDSOne;
22 extern LPDIRECTDRAWPALETTE lpDDPal;
24 extern int Inferno_verbose;
26 static int mouse_hidden=0;
28 static void finiObjects()
32 if(lpDDSPrimary!=NULL)
34 IDirectDrawSurface_Release(lpDDSPrimary);
39 IDirectDrawSurface_Unlock(lpDDSOne,NULL);
40 IDirectDrawSurface_Release(lpDDSOne);
45 IDirectDrawSurface_Release(lpDDPal);
48 IDirectDrawSurface_Release(lpDD);
55 //extern unsigned int key_wparam, key_lparam, key_msg;
56 void keyboard_handler();
57 extern int WMKey_Handler_Ready;
59 void PumpMessages(void)
63 while (PeekMessage(&msg,NULL,0,0,PM_REMOVE|PM_NOYIELD))
65 TranslateMessage(&msg);
66 DispatchMessage(&msg);
70 long PASCAL DescentWndProc(HWND hWnd,UINT message,
71 WPARAM wParam,LPARAM lParam )
78 if (WMKey_Handler_Ready) {
79 // key_wparam=wParam; key_lparam=lParam; key_msg=message;
89 case WM_NCLBUTTONDOWN:
91 case WM_NCRBUTTONDOWN:
94 case WM_PALETTECHANGED:
95 case WM_PALETTEISCHANGING:
98 // Win32_Key_Hook(wParam);
99 // DPH: This doesn't work... no idea why not...
106 return DefWindowProc(hWnd,message,wParam,lParam);
109 void arch_init_start()
113 if (FindArg("-memdbg"))
114 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | /* _CRTDBG_CHECK_ALWAYS_DF | */
115 /*_CRTDBG_CHECK_CRT_DF |*/
116 _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
121 extern void key_init(void);
122 extern void mouse_init(void);
123 //added/changed 3/7/99 Owen Evans (next line)
124 extern void joy_init(int joyid);
130 WNDCLASS wcDescentClass;
132 wcDescentClass.lpszClassName = "WinD1X";
133 wcDescentClass.hInstance = hInst;
134 wcDescentClass.lpfnWndProc = DescentWndProc;
135 wcDescentClass.hCursor = LoadCursor(NULL, IDC_ARROW);
136 //wcDescentClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
137 wcDescentClass.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN_ICON));
138 wcDescentClass.lpszMenuName = NULL;
139 wcDescentClass.hbrBackground = NULL;
140 wcDescentClass.style = CS_HREDRAW | CS_VREDRAW;
141 wcDescentClass.cbClsExtra = 0;
142 wcDescentClass.cbWndExtra = 0;
144 // Register the class
145 RegisterClass(&wcDescentClass);
146 g_hWnd = CreateWindowEx(0,
149 WS_OVERLAPPED | WS_BORDER,
151 GetSystemMetrics(SM_CXSCREEN),
152 GetSystemMetrics(SM_CYSCREEN),
159 if (!g_hWnd) return; // CRAP!
160 ShowWindow(g_hWnd,SW_SHOWNORMAL);
161 UpdateWindow(g_hWnd);
164 ddrval=DirectDrawCreate(NULL,&lpDD,NULL);
168 fprintf(stderr,"DirectDrawCreate() failed!\n");
172 if (FindArg("-semiwin"))
173 ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd,DDSCL_NORMAL);
177 ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd,
178 DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT);
180 ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd,
181 DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT);
187 fprintf(stderr,"SetCooperativeLevel() failed\n");
194 SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS);
198 //added/changed 3/7/99 Owen Evans (next line)
199 joy_init(JOYSTICKID1);
200 printf("arch_init successfully completed\n");