Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
winmain.c
Go to the documentation of this file.
1/*
2 * Win32 entry point, window, joystick, guarded heap and keyboard state.
3 *
4 * Retail object 0x453C80-0x4564EF (link order; see docs/ORDER.md).
5 */
6/* This unit owns storage declared in globals.h as statics. */
7#define WINMAIN_C
8#include "game.h"
9
10static char g_szWindowClassName[45]; /* 0x0049c278 */
11static char g_szWindowTitle[45]; /* 0x0049c2a8 */
12
13/* The debug log writer is defined near the end of this unit. */
14void WriteDebugString(const char *s);
15
16/* Function start: 0x453C80 */
17unsigned int GetF1KeyLatch(void)
18{
19 return g_bF1KeyDown;
20}
21
22#pragma function(strcmp)
23/* Function start: 0x453C95 */
25{
26 int scanned;
27 char option[100];
28 char command;
29 int ctrlFile;
30 FILE *config;
31
32 if (ReadCheaterFlagFromRegistry() != 0) {
33 *(unsigned char *)&g_bPlayerDamageEnabled = 0;
34 *(unsigned char *)&g_bPlayerCollisionEnabled = 0;
35 *(unsigned char *)&g_nOriginDevUnlock = 1;
36 }
37
38 ctrlFile = _open("ctrl.del", O_BINARY);
39 if (ctrlFile != -1) {
41 _close(ctrlFile);
42 }
43
44 config = fopen("WC2.CFG", "rt");
45 while (config != 0) {
46 scanned = fscanf(config, "%s", option);
47 if (scanned == -1) {
48 fclose(config);
49 break;
50 }
51 if (strcmp("[[log]]", option) == 0)
53
54 command = option[0];
55 if (command == '-')
56 command = option[1];
57 switch (command) {
58 case 'k':
59 *(unsigned char *)&g_bPlayerDamageEnabled = 0;
60 break;
61 case 'b':
62 *(unsigned char *)&g_bPlayerCollisionEnabled = 0;
63 break;
64 case 's':
65 break;
66 case 'f':
68 break;
69 case 'q':
71 break;
72 case 'l':
74 break;
75 case 'w':
77 break;
78 case 'm':
80 break;
81 }
82 }
83}
84
85#pragma intrinsic(strcmp)
86
87#pragma function(memset)
88/* Function start: 0x453E60 */
89int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous,
90 LPSTR commandLine, int showCommand)
91{
92 MEMORYSTATUS memoryStatus;
93 RECT clip;
94 HANDLE processHandle;
95
96 if (commandLine != 0 && strchr(commandLine, 's') != 0)
99 CreateSemaphoreA(0, 0, 1, "Wing Commander 2");
100 if (GetLastError() == ERROR_ALREADY_EXISTS) {
101 MessageBoxA(0,
102 "Only one instance of Wing Commander 2 for Windows95 may be running at a time",
103 "ATTENTION", MB_ICONERROR);
104 exit(0);
105 }
106
107 memset(&memoryStatus, 0, sizeof(memoryStatus));
108 memoryStatus.dwLength = sizeof(memoryStatus);
109 GlobalMemoryStatus(&memoryStatus);
110 if (memoryStatus.dwTotalPhys < 0x800000) {
111 MessageBoxA(0,
112 "You must have at leat 8 megs of memory available to play Wing Commander 2 for Windows95",
113 "ATTENTION", MB_ICONERROR);
114 exit(0);
115 }
116 if (memoryStatus.dwTotalPageFile < 0x800000) {
117 MessageBoxA(0,
118 "You must have at leat 8 megs of virtual memory available to play Wing Commander 2 for Window95",
119 "ATTENTION", MB_ICONERROR);
120 exit(0);
121 }
122
123 if (waveOutGetNumDevs() < 1)
124 g_nAudioEnabled = 0;
126 if (!PromptInsertCorrectCd()) {
127 CloseHandle(g_19_hOneProcessLock);
128 return 0;
129 }
130 if (!CreateMainWindow(instance, previous, showCommand))
131 return 0;
132
134 processHandle = GetCurrentProcess();
136 SetPriorityClass(processHandle, HIGH_PRIORITY_CLASS);
139 srand((unsigned int)time(0));
142 g_11_dwGameZeroTime = (unsigned int)time(0);
143 ShowCursor(FALSE);
145 clip.left = 0;
146 clip.top = 0;
147 clip.right = 320;
148 clip.bottom = 200;
149 ClipCursor(&clip);
150
151 _onexit((_onexit_t)AbortToDesktop);
155 /* argc is zero, so the argument vector is never read. */
156 RunGameApplication(0, (char **)"");
159
160 ClipCursor(0);
161 ShowCursor(TRUE);
162 g_48_dwGameExitClockValue = (unsigned int)time(0);
165 DestroyWindow(g_10_hMainWindow);
166 DIBunInstall();
167 CloseHandle(g_19_hOneProcessLock);
168 return 1;
169}
170
171/* Function start: 0x454103 */
173{
175 g_48_dwGameExitClockValue = (unsigned int)time(0);
176 ClipCursor(0);
177 ShowCursor(TRUE);
179 DestroyWindow(g_10_hMainWindow);
180 DIBunInstall();
181 ClipCursor(0);
182 ShowCursor(TRUE);
183 {
184 HANDLE process;
185
186 process = GetCurrentProcess();
187 SetPriorityClass(process, IDLE_PRIORITY_CLASS);
188 }
189 CloseHandle(g_19_hOneProcessLock);
190 exit(0);
191}
192
193/* Function start: 0x45418B */
194void ShowNoticeMessageBox(const char *text)
195{
197 MessageBoxA(0, text, "NOTICE", 0x10);
198 exit(0);
199 return;
200}
201
202#pragma function(strcpy)
203/* Function start: 0x4541BD */
204void OutputDebugPrintf(const char *format, ...)
205{
206 va_list arguments;
207 char buffer[128];
208
209 va_start(arguments, format);
210 if (format != 0)
211 vsprintf(buffer, format, arguments);
212 else
213 strcpy(buffer, va_arg(arguments, const char *));
214 va_end(arguments);
215 OutputDebugStringA(buffer);
216 return;
217}
218
219/* Function start: 0x45422D */
220unsigned int AbortToDesktop(void)
221{
222 HANDLE process;
223
225 ClipCursor(0);
226 ShowCursor(TRUE);
227 process = GetCurrentProcess();
228 SetPriorityClass(process, IDLE_PRIORITY_CLASS);
230 "Current: %i\nMax : %i\nTotal : %i\n",
234 OutputDebugStringA("Memory Info:\n");
235 OutputDebugStringA(g_29_abMemoryLoadNotice);
236 CloseHandle(g_19_hOneProcessLock);
237 return 0;
238}
239
240/* Function start: 0x4542B7 */
241int CreateMainWindow(HINSTANCE instance, HINSTANCE previous,
242 int showCommand)
243{
244 WNDCLASSA windowClass;
245 DWORD error;
246
247 g_7_hAppCopy = instance;
248 if (previous != 0)
249 return 0;
250
251 windowClass.lpszClassName = g_szWindowClassName;
252 windowClass.hInstance = g_7_hAppCopy;
253 windowClass.lpfnWndProc = MainWindowProc;
254 windowClass.hCursor = 0;
255 windowClass.hIcon = LoadIconA(0, IDI_APPLICATION);
256 windowClass.lpszMenuName = g_szWindowClassName;
257 windowClass.hbrBackground = GetStockObject(BLACK_BRUSH);
258 windowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
259 windowClass.cbClsExtra = 0;
260 windowClass.cbWndExtra = 0;
261 if (RegisterClassA(&windowClass) == 0)
262 return 0;
263
264 g_10_hMainWindow = CreateWindowExA(
266 WS_POPUP, 0, 0, 320, 200, 0, 0, g_7_hAppCopy, 0);
267 if (g_10_hMainWindow == 0) {
268 error = GetLastError();
269 return 0;
270 }
271
273 SetTextColor(g_18_hMainWindowContext, RGB(255, 0, 0));
274 SetBkColor(g_18_hMainWindowContext, RGB(0, 0, 0));
275 if (GetDeviceCaps(g_18_hMainWindowContext, BITSPIXEL) < 8) {
276 MessageBoxA(0,
277 "You must be running with 256, or more, colors to play Wing Commander",
278 "NOTICE", MB_ICONEXCLAMATION);
279 DestroyWindow(g_10_hMainWindow);
280 return 0;
281 }
282
283 g_1_hMainWndCursor = SetCursor(0);
284 ShowWindow(g_10_hMainWindow, showCommand);
285 UpdateWindow(g_10_hMainWindow);
288 return 1;
289}
290
291/* Function start: 0x45445A */
292unsigned int PumpWindowMessages(int skipMessages)
293{
294 MSG message;
295 /* Retail reserves 28 more bytes around these that nothing touches. */
296 DWORD cursor;
297 POINT point;
298 int done;
299 RECT windowRect;
300
301 done = 0;
302 g_196_nInputTimerTicks = GetTickCount();
306 if (skipMessages == 0) {
308 return 1;
313 done = 0;
314 while (done == 0 || g_bWindowInactive != 0) {
315 if (g_bWindowInactive != 0) {
316 if (GetMessageA(&message, 0, 0, 0) != 0) {
317 TranslateMessage(&message);
318 DispatchMessageA(&message);
319 done = 1;
320 } else {
323 }
324 } else {
325 if (PeekMessageA(&message, 0, 0, 0,
326 PM_NOREMOVE) != 0) {
327 if (GetMessageA(&message, 0, 0, 0) != 0) {
328 TranslateMessage(&message);
329 DispatchMessageA(&message);
330 } else {
333 }
334 done = 0;
335 } else {
336 done = 1;
337 }
338 }
339 }
341 }
342 g_196_nInputTimerTicks = GetTickCount();
347}
348
349/* Function start: 0x454625 */
350LRESULT CALLBACK MainWindowProc(HWND window, UINT message,
351 WPARAM wParam, LPARAM lParam)
352{
353 PAINTSTRUCT paint;
354 int mouseInput;
355 unsigned int menuId;
356 unsigned int primaryButtonDown;
357 unsigned int secondaryDown;
358 unsigned int pointerPositionX;
359 unsigned int cursorY;
360 unsigned int scanValue;
361 MSG textEvent;
362 unsigned int character;
363 HANDLE processHandle;
364 RECT clip;
365
366 menuId = (unsigned int)wParam & 0xffff;
367 mouseInput = 0;
368 primaryButtonDown = ((unsigned int)wParam & 1) != 0;
369 secondaryDown = ((unsigned int)wParam & 2) != 0;
370 if (message == WM_MOUSEMOVE || message == WM_RBUTTONUP ||
371 message == WM_LBUTTONUP || message == WM_LBUTTONDOWN ||
372 message == WM_RBUTTONDOWN) {
373 g_nPendingMouseX = LOWORD(lParam);
374 pointerPositionX = g_nPendingMouseX;
375 g_nPendingMouseY = HIWORD(lParam);
376 cursorY = g_nPendingMouseY;
377 } else {
378 pointerPositionX = g_nPendingMouseX;
379 cursorY = g_nPendingMouseY;
380 }
381
382 switch (message) {
383 case WM_ACTIVATEAPP:
385 if (wParam != 0) {
386 if (g_bWindowInactive == 1) {
387 clip.left = 0;
388 clip.top = 0;
389 clip.right = 320;
390 clip.bottom = 200;
391 ShowCursor(FALSE);
392 processHandle = GetCurrentProcess();
393 SetPriorityClass(processHandle, HIGH_PRIORITY_CLASS);
394 SetActiveWindow(g_10_hMainWindow);
395 SetForegroundWindow(g_10_hMainWindow);
396 DIBreInstall();
397 ClipCursor(&clip);
398 SetCursorPos(g_3_nSavedOwnerCursorX,
401 WriteDebugString("UNPAUSING...\n");
402 }
403 } else if (g_bWindowInactive == 0 &&
407 ClipCursor(0);
408 ShowCursor(TRUE);
409 processHandle = GetCurrentProcess();
410 SetPriorityClass(processHandle, IDLE_PRIORITY_CLASS);
412 WriteDebugString("PAUSING...\n");
413 }
414 return 0;
415 }
416 /* fall through */
417 case WM_ACTIVATE:
419 if (((unsigned int)wParam & 0xffff) != 0) {
420 if (HIWORD(wParam) != 0) {
422 WriteDebugString("MINIMIZED PAUSING...\n");
423 return 0;
424 } else if (g_bWindowInactive == 1) {
425 clip.left = 0;
426 clip.top = 0;
427 clip.right = 320;
428 clip.bottom = 200;
429 ShowCursor(FALSE);
430 processHandle = GetCurrentProcess();
431 SetPriorityClass(processHandle, HIGH_PRIORITY_CLASS);
432 SetActiveWindow(g_10_hMainWindow);
433 SetForegroundWindow(g_10_hMainWindow);
434 DIBreInstall();
435 ClipCursor(&clip);
436 SetCursorPos(g_3_nSavedOwnerCursorX,
439 WriteDebugString("UNPAUSING...\n");
440 }
441 } else if (g_bWindowInactive == 0 &&
445 ClipCursor(0);
446 ShowCursor(TRUE);
447 processHandle = GetCurrentProcess();
448 SetPriorityClass(processHandle, IDLE_PRIORITY_CLASS);
450 WriteDebugString("PAUSING...\n");
451 }
452 return 0;
453 }
454 /* fall through */
455 case WM_SETFOCUS:
457 return 0;
458 /* Retail retains the switch break after this return. */
459 break;
460 case WM_CREATE:
461 break;
462 case WM_COMMAND:
463 switch (menuId) {
464 case 3:
466 PostQuitMessage(0);
467 break;
468 }
469 break;
470 case WM_LBUTTONDOWN:
471 case WM_RBUTTONDOWN:
473 QueueInputEvent(1, pointerPositionX,
474 cursorY, 0,
475 primaryButtonDown, secondaryDown, 0, 0, 0);
476 mouseInput = 1;
477 break;
478 case WM_RBUTTONUP:
480 QueueInputEvent(2, pointerPositionX,
481 cursorY, 0, 0, 1, 0, 0, 0);
482 mouseInput = 1;
483 break;
484 case WM_LBUTTONUP:
486 QueueInputEvent(2, pointerPositionX,
487 cursorY, 0, 1, 0, 0, 0, 0);
488 mouseInput = 1;
489 break;
490 case WM_MOUSEMOVE:
492 QueueInputEvent(3, pointerPositionX,
493 cursorY, 0,
494 primaryButtonDown, secondaryDown, 0, 0, 0);
495 mouseInput = 1;
496 } else {
498 }
499 break;
500 case WM_KEYDOWN:
501 if (PeekMessageA(&textEvent, window, WM_CHAR, WM_CHAR,
502 PM_REMOVE) != 0) {
503 character = (unsigned int)textEvent.wParam;
504 } else {
505 character = 0;
506 }
507 if (wParam == VK_F1) {
508 if (((unsigned long)lParam & 0x40000000) == 0)
509 g_bF1KeyDown = 1;
510 else
511 g_bF1KeyDown = 0;
512 }
513 scanValue = ((unsigned long)lParam & 0xff0000) >> 16;
514 if (scanValue == 1)
516 if (((unsigned long)lParam & 0x40000000) == 0 &&
517 scanValue != 1) {
519 }
520 QueueInputEvent(4, pointerPositionX,
521 cursorY, wParam,
522 0, 0, 0, scanValue,
523 character);
524 SetInputKeyState((int)scanValue, 1);
525 break;
526 case WM_KEYUP:
527 if (PeekMessageA(&textEvent, window, WM_CHAR, WM_CHAR,
528 PM_REMOVE) != 0) {
529 character = (unsigned int)textEvent.wParam;
530 } else {
531 character = 0;
532 }
533 if (wParam == VK_F1)
534 g_bF1KeyDown = 0;
535 scanValue = ((unsigned long)lParam & 0xff0000) >> 16;
536 if (scanValue != 0x81) {
538 if (g_nInputPressCount < 0)
540 }
541 QueueInputEvent(5, pointerPositionX,
542 cursorY, wParam,
543 0, 0, 0, scanValue,
544 character);
545 SetInputKeyState((int)scanValue, 0);
546 break;
547 case WM_SYSKEYUP:
548 g_bMenuAHotkey = 0;
552 g_2_bAltHHotkey = 0;
559 break;
560 case WM_SYSKEYDOWN:
561 g_69_dwSysKeyValue = (unsigned int)wParam;
562 switch (wParam) {
563 case 'X':
565 if (((unsigned long)lParam & 0x20000000) != 0)
566 PostQuitMessage(0);
567 break;
568 case 'N':
570 break;
571 case 'M':
573 break;
574 case 'A':
575 if (((unsigned long)lParam & 0x20000000) != 0)
576 g_bMenuAHotkey = 1;
577 break;
578 case 'B':
579 if (((unsigned long)lParam & 0x20000000) != 0)
581 break;
582 case 'C':
583 if (((unsigned long)lParam & 0x20000000) != 0)
585 break;
586 case 'T':
587 if (((unsigned long)lParam & 0x20000000) != 0)
589 break;
590 case 'H':
591 if (((unsigned long)lParam & 0x20000000) != 0)
592 g_2_bAltHHotkey = 1;
593 break;
594 case 'F':
595 if (((unsigned long)lParam & 0x20000000) != 0)
597 break;
598 case 'D':
599 if (((unsigned long)lParam & 0x20000000) != 0)
601 break;
602 case VK_ADD:
603 if (((unsigned long)lParam & 0x20000000) != 0)
605 break;
606 case VK_SUBTRACT:
607 if (((unsigned long)lParam & 0x20000000) != 0)
609 break;
610 case 'Z':
611 if (((unsigned long)lParam & 0x20000000) != 0 &&
613 DebugBreak();
614 }
615 break;
616 }
617 break;
618 case WM_SIZE:
619 break;
620 case WM_PAINT:
621 BeginPaint(g_10_hMainWindow, &paint);
622 EndPaint(g_10_hMainWindow, &paint);
623 break;
624 case WM_CLOSE:
625 case WM_DESTROY:
627 ClipCursor(0);
628 ShowCursor(TRUE);
629 processHandle = GetCurrentProcess();
630 SetPriorityClass(processHandle, IDLE_PRIORITY_CLASS);
631 PostQuitMessage(0);
632 break;
633 case WM_QUIT:
635 ClipCursor(0);
636 ShowCursor(TRUE);
637 processHandle = GetCurrentProcess();
638 SetPriorityClass(processHandle, IDLE_PRIORITY_CLASS);
640 break;
641 case WM_SYSCOMMAND:
642 if ((wParam & 0xfff0) == SC_SCREENSAVE ||
643 (wParam & 0xfff0) == SC_MONITORPOWER)
644 return 0;
645 break;
646 }
647 if (mouseInput != 0) {
648 g_6_stHostMouseTextBlock.x = pointerPositionX;
649 g_6_stHostMouseTextBlock.y = cursorY;
650 g_6_stHostMouseTextBlock.primaryButton = primaryButtonDown;
652 }
653 return DefWindowProcA(window, message, wParam, lParam);
654}
655
656/* Function start: 0x4551E7 */
657void GetJoystickPosition(unsigned int *x, unsigned int *y,
658 int *buttons, unsigned short joystick,
659 unsigned int fallback)
660{
661 unsigned int slot;
662 unsigned int deviceId;
663 JOYINFO joyInfo;
664
665 slot = 0;
666 if (joystick != 0) {
667 deviceId = 1;
668 slot = 1;
669 } else {
670 deviceId = 0;
671 slot = 0;
672 }
673 if (joyGetPos(deviceId, &g_1_aJoystickInfoArray[slot]) ==
674 JOYERR_NOERROR) {
675 *x = g_1_aJoystickInfoArray[slot].wXpos;
676 *y = g_1_aJoystickInfoArray[slot].wYpos;
677 *buttons = g_1_aJoystickInfoArray[slot].wButtons;
678 joyInfo = g_1_aJoystickInfoArray[slot];
679 if ((joyInfo.wButtons & 1) != 0) {
683 } else {
685 }
686 if ((joyInfo.wButtons & 2) != 0) {
690 } else {
692 }
693 if (joystick != 0)
694 *buttons >>= 2;
695 else
696 *buttons &= 3;
697 return;
698 }
699
700 *x = fallback;
701 *y = fallback;
702 *buttons = fallback;
703}
704
705/* Function start: 0x455346 */
707{
708 short buttons;
709
710 buttons = (g_1_aJoystickInfoArray[1].wButtons << 2) |
711 g_1_aJoystickInfoArray[0].wButtons;
712 return buttons;
713}
714
715/* Function start: 0x45536F */
716void GetJoystickDevCaps(short joystick, short *xMin, short *xMax,
717 short *yMin, short *yMax)
718{
719 JOYCAPSA devCaps;
720 unsigned int deviceId = joystick != 0;
721
722 *xMin = *xMax = *yMin = *yMax = 0;
723 if (joyGetDevCapsA(deviceId, &devCaps, sizeof(devCaps)) != JOYERR_NOERROR) {
724 return;
725 }
726
727 *xMin = (short)devCaps.wXmin;
728 *xMax = (short)devCaps.wXmax;
729 *yMin = (short)devCaps.wYmin;
730 *yMax = (short)devCaps.wYmax;
731}
732
733/* Function start: 0x455427 */
735{
736 return g_7_hAppCopy;
737}
738
739/* Function start: 0x45543C */
740/* No inbound reference is known in the shipped executable; this routine is
741 * believed unreachable. */
743{
744 return g_10_hMainWindow;
745}
746
747/* Function start: 0x455451 */
748/* No inbound reference is known in the shipped executable; this routine is
749 * believed unreachable. */
754
755#pragma function(memset)
756/* Function start: 0x455466 */
757void *AllocateGuardedMemory(unsigned int size)
758{
759 if (g_pGuardedAllocationHead == 0) {
761 malloc(sizeof(GuardedAllocation));
764 } else {
766 malloc(sizeof(GuardedAllocation));
769 }
772 g_9_pGuardedAllocationLastRef->block = malloc(size + 0x800);
773
774 memset(g_9_pGuardedAllocationLastRef->block, 0xab, 0x400);
775 memset((unsigned char *)g_9_pGuardedAllocationLastRef->block +
776 0x400,
777 0, size);
778 memset((unsigned char *)g_9_pGuardedAllocationLastRef->block +
779 0x400 + size,
780 0xab, 0x400);
782 return (unsigned char *)g_9_pGuardedAllocationLastRef->block +
783 0x400;
784}
785
786#pragma intrinsic(memset)
787/* Function start: 0x455565 */
788void ReportHeapGuardCorruption(void *memory, int count, int overrun)
789{
790 char text[0x80];
791
792 sprintf(text, "Memory at %p %swritten. Corruption : (%i/%i) %s",
793 memory, overrun ? "over" : "under", count, 0x100,
794 count > 0x80
795 ? (count > 0xc0 ? "EXTREME" : "SEVERE")
796 : (count > 0x40 ? "BAD" : "NAUGHTY"));
797 MessageBoxA(0, text, "NOTICE", 0x10);
798}
799
800/* Function start: 0x455624 */
802{
803}
804
805/* Function start: 0x45562F */
806int IsFreedHeapBlockTracked(void *memory)
807{
808 FreedHeapBlock *block;
809
810 block = g_pFreedHeapBlockHead;
811 while (block != 0) {
812 if (block->block == memory)
813 return 1;
814 if (block->block == (unsigned char *)memory - 8)
815 return 1;
816 block = block->next;
817 }
818 return 0;
819}
820
821/* Function start: 0x455697 */
822int DetectDoubleFree(void *memory)
823{
824 FreedHeapBlock *block;
825
826 block = g_pFreedHeapBlockHead;
827 while (block != 0) {
828 if (block->block == memory) {
829 OutputDebugStringA("DoubleFree Detected\n");
830 return 1;
831 }
832 if (block->block == (unsigned char *)memory - 8) {
833 OutputDebugStringA("DoubleFree (pushed) Detected\n");
834 return 1;
835 }
836 block = block->next;
837 }
838 return 0;
839}
840
841/* Function start: 0x455715 */
842void TrackFreedHeapBlock(void *memory)
843{
844 if (g_pFreedHeapBlockHead == 0) {
845 g_pFreedHeapBlockHead = malloc(sizeof(FreedHeapBlock));
847 } else {
848 g_pFreedHeapBlockTail->next = malloc(sizeof(FreedHeapBlock));
850 }
853 return;
854}
855
856/* Function start: 0x455787 */
857/* Forget a block that has been handed back out, so a later free of it is not
858 * mistaken for a double free. */
859void UntrackFreedHeapBlock(void *memory)
860{
861 FreedHeapBlock *prev;
862 FreedHeapBlock *current;
863
864 prev = 0;
865 current = g_pFreedHeapBlockHead;
866 while (current != 0) {
867 if (current->block == memory) {
868 if (prev != 0) {
869 prev->next = current->next;
870 if (current->next == 0)
872 } else {
873 g_pFreedHeapBlockHead = current->next;
874 if (current->next == 0)
876 }
877 free(current);
878 return;
879 }
880 prev = current;
881 current = current->next;
882 }
883 return;
884}
885
886/* Function start: 0x455836 */
887/* Nothing in the shipped executable calls this. Frees the whole list of
888 * tracked freed-block records. */
890{
891 FreedHeapBlock *entry;
892 FreedHeapBlock *freed;
893
894 entry = g_pFreedHeapBlockHead;
895 freed = 0;
896 while (entry != 0) {
897 freed = entry;
898 entry = entry->next;
899 free(freed);
900 }
901 return;
902}
903
904void ReportHeapGuardCorruption(void *memory, int count, int overrun);
905void WriteDebugString(const char *s);
906
907/* Function start: 0x455882 */
908void FreeGuardedAllocation(void *memory)
909{
910 int found;
911 unsigned int *fence;
912 GuardedAllocation *previous;
913 GuardedAllocation *entry;
914 int corrupt;
915 int i;
916
917 found = 0;
918 fence = (unsigned int *)((unsigned char *)memory - 0x400);
919 previous = 0;
921 while (entry != 0) {
922 if (entry->block == fence) {
923 corrupt = 0;
924 for (i = 0; i < 0x100; i++) {
925 if (*fence != 0xabababab)
926 corrupt++;
927 fence++;
928 }
929 if (corrupt != 0)
930 ReportHeapGuardCorruption(memory, corrupt, 0);
931
932 fence =
933 (unsigned int *)((unsigned char *)memory + entry->size);
934 corrupt = 0;
935 for (i = 0; i < 0x100; i++) {
936 if (*fence != 0xabababab)
937 corrupt++;
938 fence++;
939 }
940 if (corrupt != 0)
941 ReportHeapGuardCorruption(memory, corrupt, 1);
942
943 fence = (unsigned int *)((unsigned char *)memory - 0x400);
944 TrackFreedHeapBlock(fence);
945 free(fence);
946 if (previous != 0)
947 previous->next = entry->next;
948 else
950 if (g_9_pGuardedAllocationLastRef == entry) {
951 if (previous != 0)
953 else
955 }
956 free(entry);
957 entry = 0;
958 found = 1;
959 break;
960 }
961 if (entry != 0) {
962 previous = entry;
963 entry = entry->next;
964 }
965 }
966 if (found == 0 && DetectDoubleFree(fence) == 0) {
968 "MEM: Unknown memory lost (%p)\n", fence);
970 }
971 return;
972}
973
974/* Function start: 0x455A85 */
975void SetMousePosition(int x, int y)
976{
977 SetCursorPos(x, y);
978}
979
980/* Function start: 0x455A9E */
981/* Nothing in the shipped executable calls this. Latches a scene escape
982 * while the Escape key is down. */
984{
985 if (GetAsyncKeyState(VK_ESCAPE) != 0)
987 return;
988}
989
990/* Function start: 0x455AC8 */
991unsigned int PollKeyboardState(void)
992{
994 g_3_nBeginKeyboardState = GetAsyncKeyState(VK_HOME);
995 g_13_nUpDirKeyState = GetAsyncKeyState(VK_UP);
996 g_nPgUpwardKeyMode = GetAsyncKeyState(VK_PRIOR);
997 g_102_nLeftDirKeyboardState = GetAsyncKeyState(VK_LEFT);
998 g_nRightDirKeyboardState = GetAsyncKeyState(VK_RIGHT);
999 g_18_nEndKeyState = GetAsyncKeyState(VK_END);
1000 g_15_nDownArrowKeyState = GetAsyncKeyState(VK_DOWN);
1001 g_1_nPageDownKeyboardMode = GetAsyncKeyState(VK_NEXT);
1002 g_nClearKeyMode = GetAsyncKeyState(VK_CLEAR);
1003 g_3_nOemPeriodKeyState = GetAsyncKeyState(0xbe);
1004 g_nOemCommaKeyState = GetAsyncKeyState(0xbc);
1005 g_nInsertKeyStatus = GetAsyncKeyState(VK_INSERT);
1006 g_nDeleteKeyState = GetAsyncKeyState(VK_DELETE);
1007
1008 if (g_3_nBeginKeyboardState != 0)
1009 return 0x47;
1010 if (g_nPgUpwardKeyMode != 0)
1011 return 0x49;
1012 if (g_18_nEndKeyState != 0)
1013 return 0x4f;
1015 return 0x51;
1016 if (g_nInsertKeyStatus != 0 ||
1018 return 0x52;
1019 if (g_nDeleteKeyState != 0 ||
1021 return 0x53;
1022 if (g_nClearKeyMode != 0)
1023 return 0x4c;
1024 if (g_13_nUpDirKeyState != 0) {
1026 return 0x47;
1027 if (g_nRightDirKeyboardState != 0)
1028 return 0x49;
1029 return 0x48;
1030 }
1031 if (g_15_nDownArrowKeyState != 0) {
1033 return 0x4f;
1034 if (g_nRightDirKeyboardState != 0)
1035 return 0x51;
1036 return 0x50;
1037 }
1039 return 0x4b;
1040 if (g_nRightDirKeyboardState != 0)
1041 return 0x4d;
1042 return 0;
1043}
1044
1045/* Function start: 0x455D2D */
1047{
1048 return GetAsyncKeyState(VK_HOME);
1049}
1050
1051/* Function start: 0x455D48 */
1053{
1054 return GetAsyncKeyState(VK_UP);
1055}
1056
1057/* Function start: 0x455D63 */
1059{
1060 return GetAsyncKeyState(VK_PRIOR);
1061}
1062
1063/* Function start: 0x455D7E */
1065{
1066 return GetAsyncKeyState(VK_LEFT);
1067}
1068
1069/* Function start: 0x455D99 */
1071{
1072 return GetAsyncKeyState(VK_RIGHT);
1073}
1074
1075/* Function start: 0x455DB4 */
1077{
1078 return GetAsyncKeyState(VK_END);
1079}
1080
1081/* Function start: 0x455DCF */
1083{
1084 return GetAsyncKeyState(VK_DOWN);
1085}
1086
1087/* Function start: 0x455DEA */
1089{
1090 return GetAsyncKeyState(VK_NEXT);
1091}
1092
1093/* Function start: 0x455E05 */
1095{
1096 return GetAsyncKeyState(VK_NUMLOCK);
1097}
1098
1099/* Function start: 0x455E23 */
1101{
1102 return GetAsyncKeyState(VK_ADD);
1103}
1104
1105/* Function start: 0x455E3E */
1107{
1108 return GetAsyncKeyState(VK_SUBTRACT);
1109}
1110
1111/* Function start: 0x455E59 */
1113{
1114 return GetAsyncKeyState(VK_RETURN);
1115}
1116
1117/* Function start: 0x455E74 */
1119{
1120 return GetAsyncKeyState(VK_SPACE);
1121}
1122
1123/* Function start: 0x455E8F */
1125{
1126 return GetAsyncKeyState(VK_SHIFT);
1127}
1128
1129/* Function start: 0x455EAA */
1130unsigned int GetKeyboardModifiers(void)
1131{
1132 return g_69_dwSysKeyValue;
1133}
1134
1135/* Function start: 0x455EBF */
1137{
1138 return GetAsyncKeyState(VK_CONTROL);
1139}
1140
1141/* Function start: 0x455EDA */
1143{
1144 return GetAsyncKeyState(0x4a);
1145}
1146
1147/* Function start: 0x455EF5 */
1148unsigned int GetGameClockTicks(void)
1149{
1150 return (GetTickCount() - g_128_dwGameClockBase) * 60 / 1000;
1151}
1152
1153/* Function start: 0x455F23 */
1155{
1156 g_13_lGameClockStartData = GetTickCount();
1157 g_128_dwGameClockBase = GetTickCount() + (rand() & 3600000);
1158 return;
1159}
1160
1161/* Function start: 0x455F59 */
1162void WriteDebugString(const char *s)
1163{
1164 if (s != 0) {
1165 OutputDebugString(s);
1166 if (g_nDebugFileLoggingEnabled != 0) {
1167 if (g_pDebugLogFile == 0)
1168 g_pDebugLogFile = fopen("log.log", "wt");
1169 fprintf(g_pDebugLogFile, "%s", s);
1170 fflush(g_pDebugLogFile);
1171 }
1172 }
1173 return;
1174}
1175
1176/* Function start: 0x455FD3 */
1178{
1179 SetCursorPos(x, y);
1180 return;
1181}
1182
1183#pragma function(memset)
1184
1185/* Function start: 0x455FF1 */
1186/* Nothing in the shipped executable calls this. Allocates a one-entry
1187 * glyph workspace of 5x5 pixels filled with colour 5. */
1189{
1190 int slot;
1191 FontWorkspace **workspace;
1192
1193 workspace = 0;
1194 workspace = (FontWorkspace **)malloc(sizeof(*workspace));
1195 *workspace = (FontWorkspace *)malloc(sizeof(**workspace));
1196 for (slot = 0; slot < 1; slot++) {
1197 workspace[0][slot].width = 5;
1198 workspace[0][slot].height = 5;
1199 workspace[0][slot].pixels = (unsigned char *)malloc(
1200 (*workspace)->height * (*workspace)->width);
1201 memset(workspace[0][slot].pixels, 5,
1202 (*workspace)->height * (*workspace)->width);
1203 }
1204 return workspace;
1205}
1206
1207/* Function start: 0x4560C0 */
1208/* Nothing in the shipped executable calls this. Frees a workspace from
1209 * AllocateFontWorkspace. */
1211{
1212 int slot;
1213
1214 for (slot = 0; slot < 1; slot++)
1215 free(workspace[0][slot].pixels);
1216 free(*workspace);
1217 free(workspace);
1218 return;
1219}
1220
1221/* Function start: 0x456123 */
1223{
1224 char current[256];
1225 char *result;
1226 char drive;
1227
1228 GetCurrentDirectoryA(0xff, current);
1229 result = g_9_szStreamsPath;
1230 drive = FindCdRomDriveByVolumeLabel("<anydisc>", "\\wc2\\streams\\");
1231 if (drive != 0) {
1232 sprintf(g_9_szStreamsPath, "%c:%s", drive,
1233 "\\wc2\\streams\\");
1234 } else {
1235 if (strstr(current, "gamedat") != 0)
1236 sprintf(g_9_szStreamsPath, "%s\\..\\%s", current,
1237 "streams\\");
1238 else
1239 sprintf(g_9_szStreamsPath, "%s\\%s", current,
1240 "streams\\");
1241 GetCurrentDirectoryA(0xff, current);
1242 if (!SetCurrentDirectoryA(g_9_szStreamsPath))
1243 result = 0;
1244 SetCurrentDirectoryA(current);
1245 }
1246 return result;
1247}
1248
1249#pragma function(strcmp)
1250/* Function start: 0x456236 */
1251char FindCdRomDriveByVolumeLabel(const char *label,
1252 const char *directory)
1253{
1254 char volumeName[256];
1255 char drivePath[12];
1256 char systemName[64];
1257 DWORD volumeFlags;
1258 DWORD maximumComponentLength;
1259 int count;
1260 char drives[26];
1261 char rootPath[12];
1262 int device;
1263 char answer;
1264
1265 count = 0;
1266 for (device = 'a'; device <= 'z'; device++) {
1267 sprintf(rootPath, "%c:\\", (char)device);
1268 if (GetDriveTypeA(rootPath) == DRIVE_CDROM) {
1269 drives[count] = (char)device;
1270 count++;
1271 }
1272 }
1273
1274 answer = 0;
1275 for (device = 0; device < count; device++) {
1276 sprintf(drivePath, "%c:\\", drives[device]);
1277 GetVolumeInformationA(drivePath, volumeName, 0xff, 0,
1278 &maximumComponentLength, &volumeFlags,
1279 systemName, sizeof(systemName));
1280 if (strcmp(label, "<anydisc>") == 0) {
1281 if (SetCurrentDirOnDrive(drives[device], directory) != 0) {
1282 answer = drives[device];
1283 break;
1284 }
1285 } else if (strcmp(volumeName, label) == 0) {
1286 if (SetCurrentDirOnDrive(drives[device], directory) != 0) {
1287 answer = drives[device];
1288 break;
1289 }
1290 }
1291 }
1292 return answer;
1293}
1294
1295#pragma intrinsic(strcmp)
1296/* Function start: 0x4563A3 */
1297int SetCurrentDirOnDrive(char drive, const char *directory)
1298{
1299 char path[256];
1300 char previous[256];
1301 int result;
1302
1303 result = 0;
1304 GetCurrentDirectoryA(0xff, previous);
1305 sprintf(path, "%c:%s", drive, directory);
1306 if (SetCurrentDirectoryA(path) != 0)
1307 result = 1;
1308 SetCurrentDirectoryA(previous);
1309 return result;
1310}
1311
1312/* Function start: 0x45641B */
1314{
1315 int pressCount;
1316
1317 pressCount = g_nInputPressCount;
1319 return pressCount;
1320}
1321
1322#pragma intrinsic(strcpy)
1323/* Function start: 0x456443 */
1325{
1326 int discNumber;
1327 char title[18];
1328 char message[1024];
1329
1330 discNumber = 1;
1331 strcpy(title, "Insert Correct CD");
1332 sprintf(message,
1333 "Please place The Kilrathi Saga disc %d into your CD-ROM drive and click OK\n"
1334 "or click cancel to quit",
1335 discNumber);
1336 while (LocateStreamsDirOnDisc() == 0) {
1337 if (MessageBoxA(0, message, title,
1338 MB_OKCANCEL | MB_ICONEXCLAMATION) == IDCANCEL)
1339 return 0;
1340 }
1341 return 1;
1342}
1343
1344/* This unit's initialized data, after its functions so that it does not
1345 * move the functions' symbol keys. */
1346int g_bDebugBreakEnabled = 0; /* 0x0049c238 */
1347int g_bApplicationShutdownStarted = 0; /* 0x0049c23c */
1348int g_bF1KeyDown = 0; /* 0x0049c240 */
1349int g_nAudioEnabled = 1; /* 0x0049c244 */
1350int g_bInputEventQueueEnabled = 0; /* 0x0049c248 */
1351unsigned int g_dwGuardedAllocationTotalBytes = 0; /* 0x0049c24c */
1352unsigned int g_dwGuardedAllocationBytes = 0; /* 0x0049c250 */
1353unsigned int g_dwGuardedAllocationPeakBytes = 0; /* 0x0049c254 */
1354int g_nInputPressCount = 0; /* 0x0049c258 */
1355int g_bApplicationControllerActive = 0; /* 0x0049c25c */
1356int g_bShowFrameRate = 0; /* 0x0049c260 */
1357int g_bConfigQuickModeEnabled = 1; /* 0x0049c264 */
1358int g_bUseHardwarePalette = 1; /* 0x0049c268 */
1359int g_bCockpitEnabled = 1; /* 0x0049c26c */
1360int g_bSkipCampaignVideo = 0; /* 0x0049c270 */
1361int g_bWindowInactive = 0; /* 0x0049c274 */
1362static char g_szWindowClassName[45] =
1363 "Wing Commander II: Vengeance of the Kilrathi"; /* 0x0049c278 */
1364static char g_szWindowTitle[45] =
1365 "Wing Commander II: Vengeance of the Kilrathi"; /* 0x0049c2a8 */
1366int g_nDebugFileLoggingEnabled = 0; /* 0x0049c2d8 */
1367FILE *g_pDebugLogFile = 0; /* 0x0049c2dc */
1368int g_bConfigMemoryOption = 0; /* 0x0049c2e0 */
1369int g_bWindowMessagePumpActive = 0; /* 0x0049c2e4 */
1370int g_nUnusedWinMainWord1 = 0; /* 0x0049c2e8 */
1371int g_nPendingMouseX = 0; /* 0x0049c2ec */
1372int g_nPendingMouseY = 0; /* 0x0049c2f0 */
1373int g_nUnusedWinMainWord2 = 0; /* 0x0049c2f4 */
1374int g_bJoystickPrimaryButtonLatched = 0; /* 0x0049c2f8 */
1375int g_bJoystickSecondaryButtonLatched = 0; /* 0x0049c2fc */
1379
1380/* Linker commons defined here. LINK lays a unit's commons out by the
1381 * identifiers' hash keys, so these spellings follow the original addresses. */
1382unsigned int g_69_dwSysKeyValue; /* 0x005d10a4 */
1383JOYINFO g_1_aJoystickInfoArray[2]; /* 0x005d10b0 */
1385HWND g_10_hMainWindow; /* 0x005d10e0 */
1386HANDLE g_19_hOneProcessLock; /* 0x005d10e4 */
1387unsigned long g_128_dwGameClockBase; /* 0x005d10e8 */
1389char g_szGuardedHeapDiagnosticMessage[0x80]; /* 0x005d10f0 */
1390char g_29_abMemoryLoadNotice[0x80]; /* 0x005d1170 */
1391int g_5_nIdleWinmainWord[32]; /* 0x005d11f0 */ /* never referenced */
1394HDC g_18_hMainWindowContext; /* 0x005d1278 */
1395int g_2_bAltFHotkeyFlag; /* 0x005d127c */
1396int g_6_bAltDChordState; /* 0x005d1280 */
1397int g_bJoystickCalibrationHotkey; /* 0x005d1284 */
1398HCURSOR g_1_hMainWndCursor; /* 0x005d1288 */
1399int g_2_bAltHHotkey; /* 0x005d128c */
1400int g_4_bMenuBHotkey; /* 0x005d1290 */
1401int g_bMenuAHotkey; /* 0x005d1294 */
1402int g_6_bMenuTHotkeySwitch; /* 0x005d1298 */
1403unsigned int g_48_dwGameExitClockValue; /* 0x005d129c */
1404int g_3_nSavedOwnerCursorX; /* 0x005d12a0 */
1406int g_bAltNumpadSubtractShortcut; /* 0x005d12a8 */
1407int g_16_bMainWindowRunning; /* 0x005d12ac */
1408HINSTANCE g_7_hAppCopy; /* 0x005d12b0 */
1409unsigned int g_11_dwGameZeroTime; /* 0x005d12b4 */
1410long g_13_lGameClockStartData; /* 0x005d12b8 */
WINUSERAPI HDC WINAPI GetDC(HWND window)
WINGDIAPI COLORREF WINAPI SetTextColor(HDC deviceContext, COLORREF colour)
WINGDIAPI COLORREF WINAPI SetBkColor(HDC deviceContext, COLORREF colour)
int GetDownArrowKeyState(void)
Definition winmain.c:1082
int GetSpaceKeyState(void)
Definition winmain.c:1118
void AllocateApplicationScratchBuffer(void)
Definition eventmgr.c:2399
void SetMousePosition(int x, int y)
Definition winmain.c:975
void GetJoystickPosition(unsigned int *x, unsigned int *y, int *buttons, unsigned short joystick, unsigned int fallback)
Definition winmain.c:657
void DestroyGlobalDebugOverlayConsole(void)
Definition console.cpp:22
short LogMemoryUsage(void)
Definition main.c:24
int GetJKeyState(void)
Definition winmain.c:1142
int GetReturnKeyState(void)
Definition winmain.c:1112
void ServiceAudioStream(void)
Definition sound.c:40
void ReleaseApplicationScratchBuffer(void)
Definition eventmgr.c:2406
void ShutdownGameWindow(void)
Definition winmain.c:172
unsigned int AbortToDesktop(void)
Definition winmain.c:220
int GetPageUpKeyState(void)
Definition winmain.c:1058
void InitializeAudioStreamer(HWND window)
Definition stream.cpp:32
unsigned int PollKeyboardState(void)
Definition winmain.c:991
void DIBunInstall(void)
Definition dib.cpp:424
void * AllocateGuardedMemory(unsigned int size)
Definition winmain.c:757
void ReportSpaceFlightMaxFps(float adjustment)
Definition dib.cpp:176
int ReadCheaterFlagFromRegistry(void)
Definition stream.cpp:224
int GetPageDownKeyState(void)
Definition winmain.c:1088
void CheckLauncherAndConfig(void)
Definition winmain.c:24
HWND GetMainWindowHandle(void)
Definition winmain.c:742
void SetInputKeyState(int scanCode, unsigned char pressed)
Definition eventmgr.c:1629
int IsFreedHeapBlockTracked(void *memory)
Definition winmain.c:806
void DIBinstall(HWND window)
Definition dib.cpp:272
void DIBreInstall(void)
Definition dib.cpp:254
void FreeGuardedAllocation(void *memory)
Definition winmain.c:908
int GetNumLockKeyState(void)
Definition winmain.c:1094
int GetRightArrowKeyState(void)
Definition winmain.c:1070
void DIBpositionWindow(void)
Definition dib.cpp:243
void QueueInputEvent(int type, int x, int y, int value, int primaryButton, int secondaryButton, unsigned int ignored, unsigned int field14, unsigned int field18)
Definition eventmgr.c:653
LRESULT CALLBACK MainWindowProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
Definition winmain.c:350
unsigned int PumpWindowMessages(int skipMessages)
Definition winmain.c:292
void KeyboardMousePump(void)
Definition kbmouse.c:17
int GetNumpadPlusKeyState(void)
Definition winmain.c:1100
void CheckAllGuardedAllocations(void)
Definition winmain.c:801
void MonoDebug_install(void)
Definition mono.c:13
int GetHomeKeyState(void)
Definition winmain.c:1046
void InitializeAudioSystem(HWND window)
Definition sound.c:26
HINSTANCE GetApplicationInstance(void)
Definition winmain.c:734
char * LocateStreamsDirOnDisc(void)
Definition winmain.c:1222
int GetNumpadMinusKeyState(void)
Definition winmain.c:1106
int TakeInputPressCount(void)
Definition winmain.c:1313
unsigned int GetF1KeyLatch(void)
Definition winmain.c:17
HDC GetMainWindowDeviceContext(void)
Definition winmain.c:750
short GetJoystickButtons(void)
Definition winmain.c:706
int DetectDoubleFree(void *memory)
Definition winmain.c:822
int GetControlKeyState(void)
Definition winmain.c:1136
int GetEndKeyState(void)
Definition winmain.c:1076
void InitGameClockRandomEpoch(void)
Definition winmain.c:1154
void UntrackFreedHeapBlock(void *memory)
Definition winmain.c:859
void GetJoystickDevCaps(short joystick, short *xMin, short *xMax, short *yMin, short *yMax)
Definition winmain.c:716
void ReportHeapGuardCorruption(void *memory, int count, int overrun)
Definition winmain.c:788
char FindCdRomDriveByVolumeLabel(const char *label, const char *directory)
Definition winmain.c:1251
void SignalAudioMixerWakeEvent(void)
Definition stream.cpp:44
unsigned int GetGameClockTicks(void)
Definition winmain.c:1148
void RunGameApplication(short argc, char **argv)
Definition main.c:89
int PromptInsertCorrectCd(void)
Definition winmain.c:1324
void SetInputCursorHostPosition(int x, int y)
Definition winmain.c:1177
void ShowNoticeMessageBox(const char *text)
Definition winmain.c:194
int SetCurrentDirOnDrive(char drive, const char *directory)
Definition winmain.c:1297
int GetShiftKeyState(void)
Definition winmain.c:1124
int GetUpArrowKeyState(void)
Definition winmain.c:1052
int GetLeftArrowKeyState(void)
Definition winmain.c:1064
int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR commandLine, int showCommand)
Definition winmain.c:89
void WriteDebugString(const char *s)
Definition winmain.c:1162
unsigned int GetKeyboardModifiers(void)
Definition winmain.c:1130
void TrackFreedHeapBlock(void *memory)
Definition winmain.c:842
void OutputDebugPrintf(const char *format,...)
Definition winmain.c:204
void CreateDebugOverlayConsole(HINSTANCE module, HWND window, short columns, short rows)
Definition console.cpp:14
int CreateMainWindow(HINSTANCE instance, HINSTANCE previous, int showCommand)
Definition winmain.c:241
Shared Win32 declarations, types and library interfaces.
FreedHeapBlock * g_pFreedHeapBlockTail
Definition winmain.c:1378
FILE * g_pDebugLogFile
Definition winmain.c:1367
HostMouseMessage g_6_stHostMouseTextBlock
Definition winmain.c:1384
WINMAIN_STATIC int g_13_nUpDirKeyState
Definition globals.h:907
unsigned long g_128_dwGameClockBase
Definition winmain.c:1387
int g_27_nLastAltCommandScanNumberWord
Definition winmain.c:1393
int g_bInputEventQueueEnabled
Definition winmain.c:1350
WINMAIN_STATIC int g_15_nDownArrowKeyState
Definition globals.h:908
int g_3_nSavedOwnerCursorX
Definition winmain.c:1404
int g_bApplicationControllerActive
Definition winmain.c:1355
WINMAIN_STATIC int g_nPgUpwardKeyMode
Definition globals.h:910
HWND g_10_hMainWindow
Definition winmain.c:1385
long g_13_lGameClockStartData
Definition winmain.c:1410
int g_16_bMainWindowRunning
Definition winmain.c:1407
HANDLE g_19_hOneProcessLock
Definition winmain.c:1386
int g_bJoystickCalibrationHotkey
Definition winmain.c:1397
signed char g_bSceneEscapeRequested
Definition eventmgr.c:2420
WINMAIN_STATIC int g_nOemCommaKeyState
Definition globals.h:902
unsigned int g_48_dwGameExitClockValue
Definition winmain.c:1403
WINMAIN_STATIC int g_nDeleteKeyState
Definition globals.h:906
WINMAIN_STATIC int g_nClearKeyMode
Definition globals.h:905
WINMAIN_STATIC int g_nRightDirKeyboardState
Definition globals.h:903
int g_2_bAltFHotkeyFlag
Definition winmain.c:1395
int g_nPendingMouseX
Definition winmain.c:1371
WINMAIN_STATIC char g_9_szStreamsPath[0x100]
Definition globals.h:909
int g_bShowFrameRate
Definition winmain.c:1356
int g_bWindowInactive
Definition winmain.c:1361
int g_bUseHardwarePalette
Definition winmain.c:1358
FreedHeapBlock * g_pFreedHeapBlockHead
Definition winmain.c:1377
int g_nDebugFileLoggingEnabled
Definition winmain.c:1366
int g_bDebugBreakEnabled
Definition winmain.c:1346
int g_2_bIgnoreNextCursorMoveFlag
Definition eventmgr.c:2534
int g_bJoystickPrimaryButtonLatched
Definition winmain.c:1374
int g_nInputPressCount
Definition winmain.c:1354
char g_29_abMemoryLoadNotice[0x80]
Definition winmain.c:1390
unsigned int g_dwGuardedAllocationTotalBytes
Definition winmain.c:1351
char g_szGuardedHeapDiagnosticMessage[0x80]
Definition winmain.c:1389
unsigned int g_dwGuardedAllocationPeakBytes
Definition winmain.c:1353
WINMAIN_STATIC int g_3_nBeginKeyboardState
Definition globals.h:900
int g_bMenuAHotkey
Definition winmain.c:1401
short g_bPlayerCollisionEnabled
Definition main.c:1947
int g_bSkipCampaignVideo
Definition winmain.c:1360
WINMAIN_STATIC int g_1_nPageDownKeyboardMode
Definition globals.h:901
GuardedAllocation * g_9_pGuardedAllocationLastRef
Definition winmain.c:1388
int g_4_bMenuBHotkey
Definition winmain.c:1400
int g_nPendingMouseY
Definition winmain.c:1372
int g_bAltNumpadSubtractShortcut
Definition winmain.c:1406
WINMAIN_STATIC int g_3_nOemPeriodKeyState
Definition globals.h:899
unsigned int g_dwGuardedAllocationBytes
Definition winmain.c:1352
int g_bConfigMemoryOption
Definition winmain.c:1368
JOYINFO g_1_aJoystickInfoArray[2]
Definition winmain.c:1383
unsigned int g_11_dwGameZeroTime
Definition winmain.c:1409
int g_6_bAltDChordState
Definition winmain.c:1396
int g_6_bMenuTHotkeySwitch
Definition winmain.c:1402
WINMAIN_STATIC int g_102_nLeftDirKeyboardState
Definition globals.h:911
volatile int g_196_nInputTimerTicks
Definition eventmgr.c:2550
int g_39_bAltNumpadAddHotkeySwitch
Definition winmain.c:1392
int g_bConfigQuickModeEnabled
Definition winmain.c:1357
int g_102_nStoredWindowCursorYWord
Definition winmain.c:1405
short g_bPlayerDamageEnabled
Definition main.c:1946
void(*) g_176_pfnCurrentInputPump(void)
Definition eventmgr.c:2526
int g_bF1KeyDown
Definition winmain.c:1348
HINSTANCE g_7_hAppCopy
Definition winmain.c:1408
int g_bCockpitEnabled
Definition winmain.c:1359
int g_2_bAltHHotkey
Definition winmain.c:1399
WINMAIN_STATIC int g_18_nEndKeyState
Definition globals.h:904
WINMAIN_STATIC int g_2_nClearedKeyboardState
Definition globals.h:898
HCURSOR g_1_hMainWndCursor
Definition winmain.c:1398
short g_nOriginDevUnlock
Definition main.c:1944
int g_bApplicationShutdownStarted
Definition winmain.c:1347
int g_bJoystickSecondaryButtonLatched
Definition winmain.c:1375
WINMAIN_STATIC int g_nInsertKeyStatus
Definition globals.h:897
int g_bWindowMessagePumpActive
Definition winmain.c:1369
GuardedAllocation * g_pGuardedAllocationHead
Definition winmain.c:1376
HDC g_18_hMainWindowContext
Definition winmain.c:1394
unsigned int g_69_dwSysKeyValue
Definition winmain.c:1382
int g_nAudioEnabled
Definition winmain.c:1349
int height
Definition game.h:275
unsigned char * pixels
Definition game.h:276
int width
Definition game.h:274
struct FreedHeapBlock * next
Definition game.h:362
void * block
Definition game.h:361
struct GuardedAllocation * next
Definition game.h:356
unsigned int size
Definition game.h:355
void * block
Definition game.h:354
int primaryButton
Definition game.h:182
int secondaryButton
Definition game.h:183
int g_nUnusedWinMainWord1
Definition winmain.c:1370
static char g_szWindowClassName[45]
Definition winmain.c:10
void FreeFontWorkspace(FontWorkspace **workspace)
Definition winmain.c:1210
int g_nUnusedWinMainWord2
Definition winmain.c:1373
int g_5_nIdleWinmainWord[32]
Definition winmain.c:1391
FontWorkspace ** AllocateFontWorkspace(short fontIndex)
Definition winmain.c:1188
void PollEscapeKey(void)
Definition winmain.c:983
void FreeTrackedHeapBlocks(void)
Definition winmain.c:889
static char g_szWindowTitle[45]
Definition winmain.c:11