15 extern HINSTANCE hInst;
17 extern LPDIRECTDRAW lpDD;
18 extern LPDIRECTDRAWSURFACE lpDDSPrimary;
19 extern LPDIRECTDRAWSURFACE lpDDSOne;
20 extern LPDIRECTDRAWPALETTE lpDDPal;
22 extern int Inferno_verbose;
24 static int mouse_hidden=0;
26 static void finiObjects()
30 if(lpDDSPrimary!=NULL)
32 IDirectDrawSurface_Release(lpDDSPrimary);
37 IDirectDrawSurface_Unlock(lpDDSOne,NULL);
38 IDirectDrawSurface_Release(lpDDSOne);
43 IDirectDrawSurface_Release(lpDDPal);
46 IDirectDrawSurface_Release(lpDD);
53 //extern unsigned int key_wparam, key_lparam, key_msg;
54 void keyboard_handler();
55 extern int WMKey_Handler_Ready;
57 void PumpMessages(void)
61 while (PeekMessage(&msg,NULL,0,0,PM_REMOVE|PM_NOYIELD))
63 TranslateMessage(&msg);
64 DispatchMessage(&msg);
68 long PASCAL DescentWndProc(HWND hWnd,UINT message,
69 WPARAM wParam,LPARAM lParam )
76 if (WMKey_Handler_Ready) {
77 // key_wparam=wParam; key_lparam=lParam; key_msg=message;
87 case WM_NCLBUTTONDOWN:
89 case WM_NCRBUTTONDOWN:
92 case WM_PALETTECHANGED:
93 case WM_PALETTEISCHANGING:
96 // Win32_Key_Hook(wParam);
97 // DPH: This doesn't work... no idea why not...
104 return DefWindowProc(hWnd,message,wParam,lParam);
107 void arch_init_start()
109 WNDCLASS wcDescentClass;
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);
120 wcDescentClass.lpszClassName = "WinD1X";
121 wcDescentClass.hInstance = hInst;
122 wcDescentClass.lpfnWndProc = DescentWndProc;
123 wcDescentClass.hCursor = LoadCursor(NULL, IDC_ARROW);
124 wcDescentClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
125 wcDescentClass.lpszMenuName = NULL;
126 wcDescentClass.hbrBackground = NULL;
127 wcDescentClass.style = CS_HREDRAW | CS_VREDRAW;
128 wcDescentClass.cbClsExtra = 0;
129 wcDescentClass.cbWndExtra = 0;
131 // Register the class
132 RegisterClass(&wcDescentClass);
133 g_hWnd = CreateWindowEx(0,
136 WS_OVERLAPPED | WS_BORDER,
138 GetSystemMetrics(SM_CXSCREEN),
139 GetSystemMetrics(SM_CYSCREEN),
146 if (!g_hWnd) return; // CRAP!
147 ShowWindow(g_hWnd,SW_SHOWNORMAL);
148 UpdateWindow(g_hWnd);
151 extern void key_init(void);
152 extern void mouse_init(void);
153 //added/changed 3/7/99 Owen Evans (next line)
154 extern void joy_init(int joyid);
161 ddrval=DirectDrawCreate(NULL,&lpDD,NULL);
165 fprintf(stderr,"DirectDrawCreate() failed!\n");
169 if (FindArg("-semiwin"))
170 ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd,DDSCL_NORMAL);
174 ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd,
175 DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT);
177 ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd,
178 DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT);
184 fprintf(stderr,"SetCooperativeLevel() failed\n");
191 SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS);
195 //added/changed 3/7/99 Owen Evans (next line)
196 joy_init(JOYSTICKID1);
197 printf("arch_init successfully completed\n");