Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
eventmgr.c
Go to the documentation of this file.
1/*
2 * Win32 library port: random, fixed-point math, text, strings and events.
3 *
4 * Retail object 0x4618E0-0x46572F (link order; see docs/ORDER.md).
5 */
6/* This unit owns storage declared in globals.h as statics. */
7#define EVENTMGR_C
8#include "game.h"
9
10#pragma function(acos, asin, cos, sin, sqrt)
11/* Function start: 0x4618E0 */
12short RandomBelow(short n)
13{
14 return (short)(rand() % (int)n);
15}
16
17/* Function start: 0x4618FF */
19{
20 srand((unsigned int)time(0));
21 return;
22}
23
24/* Function start: 0x461922 */
25unsigned short GetRandomWord(void)
26{
27 return rand() & 0xffff;
28}
29
30/* Function start: 0x461942 */
31unsigned short RandomInRange(unsigned short lo, unsigned short hi)
32{
33 short span;
34
35 span = (short)(hi - lo);
36 if (span == 0)
37 span = 1;
38 span = (short)(rand() % (span + 1));
39 return (short)(span + lo);
40}
41
42/* Function start: 0x4619A1 */
43short RandomBelowOrEqual(short n)
44{
45 if (n == -1 || n == 0)
46 return 0;
47 return (short)(rand() % (n + 1));
48}
49
50/* Function start: 0x4619E2 */
51long MultiplyFixed(int left, int right)
52{
53 float leftFloat;
54 float rightFloat;
55 long product;
56
57 leftFloat = (float)left / 256.0;
58 rightFloat = (float)right / 256.0;
59 product = (long)(leftFloat * rightFloat * 256.0);
60 return product;
61}
62
63/* Function start: 0x461A2D */
64long DivideFixed(int numerator, int denominator)
65{
66 float numeratorValue;
67 float denominatorValue;
68 long quotient;
69
70 numeratorValue = (float)numerator / 256.0;
71 if (denominator != 0)
72 denominatorValue = (float)denominator / 256.0;
73 else
74 denominatorValue = 1.0f;
75 quotient = (long)(numeratorValue / denominatorValue * 256.0);
76 return quotient;
77}
78
79/* Function start: 0x461A91 */
80long SinFixed(short degrees)
81{
82 float angle;
83 long result;
84
85 angle = (float)degrees;
86 result = (long)(sin((double)angle * DEG2RAD) * 256.0);
87 return result;
88}
89
90/* Function start: 0x461AD6 */
91long CosFixed(short degrees)
92{
93 float angle;
94 long result;
95
96 angle = (float)degrees;
97 result = (long)(cos((double)angle * DEG2RAD) * 256.0);
98 return result;
99}
100
101/* Function start: 0x461B1B */
102short ArcSin(int value)
103{
104 float scale;
105 float normalized;
106 short result;
107
108 scale = 256.0f;
109 normalized = (float)value;
110 normalized /= scale;
111 result = (short)(asin((double)normalized) * 57.295779513082323);
112 return result;
113}
114
115/* Function start: 0x461B6B */
116short ArcCos(int value)
117{
118 float scale;
119 float normalized;
120 short result;
121
122 scale = 256.0f;
123 normalized = (float)value;
124 normalized /= scale;
125 result = (short)(acos((double)normalized) * 57.295779513082323);
126 return result;
127}
128
129/* Function start: 0x461BBB */
130long Magnitude(int value)
131{
132 float fixedScale;
133 float normalized;
134 long scaledMagnitude;
135
136 fixedScale = 256.0f;
137 normalized = (float)value;
138 normalized /= fixedScale;
139 scaledMagnitude = (long)(sqrt((double)normalized) * fixedScale);
140 return scaledMagnitude;
141}
142
143/* Function start: 0x461C06 */
144long PlanarMagnitude(int x, int y)
145{
146 float scaledX = (float)x / 256.0;
147 float scaledY = (float)y / 256.0;
148 long scaledMagnitude;
149
150 scaledX *= scaledX;
151 scaledY *= scaledY;
152 scaledMagnitude = (long)(sqrt(scaledX + scaledY) * 256.0);
153 return scaledMagnitude;
154}
155
156/* Function start: 0x461C71 */
157long Vector_magnitude(const FixedVector *vector)
158{
159 float x = (float)vector->x / 256.0;
160 float y = (float)vector->y / 256.0;
161 float z = (float)vector->z / 256.0;
162 long scaledMagnitude;
163
164 x *= x;
165 y *= y;
166 z *= z;
167 scaledMagnitude = (long)(sqrt(x + y + z) * 256.0);
168 return scaledMagnitude;
169}
170
171/* Function start: 0x461D02 */
172void SetTextCursor(unsigned short a, unsigned short b)
173{
176}
177
178/* Function start: 0x461D29 */
180{
181 g_29_pCurrentTextContext = context;
182 if (g_29_pCurrentTextContext != NULL &&
185 return;
186}
187
188/* Function start: 0x461D68 */
190{
192 return;
193}
194
195/* Function start: 0x461D7D */
196void *IdentityHandle(void *v)
197{
198 return v;
199}
200
201/* Function start: 0x461D90 */
202/* A forwarder that passes its argument through. The Ghidra label claimed a
203 * no-argument call, which was wrong. */
204void SetWholePaletteFromTriplets(unsigned char *palette)
205{
207}
208
209/* Function start: 0x461DA7 */
210short ReadWord(unsigned short *p)
211{
212 return *p;
213}
214
215/* Function start: 0x461DBD */
216short GetFontCharWidth(char i)
217{
218 return g_29_pCurrentTextContext->font[4 + (int)i];
219}
220
221/* Function start: 0x461DE0 */
223{
224 return;
225}
226
227/* Function start: 0x461DF0 */
228short GetShapeFrameBounds(short *bounds, short x, short y,
229 unsigned char *shape, short frame)
230{
231
232 frame <<= 2;
233 if (*(unsigned short *)(shape + 4) > frame) {
234 frame += 4;
235 shape += *(unsigned short *)(shape + frame);
236 bounds[2] = (short)(*(unsigned short *)shape + x);
237 bounds[0] = (short)(x - ((unsigned short *)shape)[1]);
238 bounds[1] = (short)(y - ((unsigned short *)shape)[2]);
239 bounds[3] = (short)(((unsigned short *)shape)[3] + y);
240 return -1;
241 }
242 return 0;
243}
244
245/* Function start: 0x461E97 */
246short IsPointInRect(short x, short y, const short *rect)
247{
248 if (rect[0] <= x && x <= rect[2] &&
249 rect[1] <= y && y <= rect[3])
250 return 1;
251 return 0;
252}
253
254/* Function start: 0x461EFE */
255void SplitPackedPoint(ShortPoint point, short *p)
256{
257 IsPointInRect(point.x, point.y, p);
258 return;
259}
260
261/* Function start: 0x461F22 */
262void DrawTextString(const char *text)
263{
264 int wrapPending;
265 const char *cursor;
266 const char *drawPos;
267 const char *lineBegin;
268 char ch;
269 int previousX;
270 int isDone;
271 int pixelWidth;
272
273 isDone = 0;
274 cursor = text;
275 wrapPending = 0;
277 return;
280 while (isDone == 0) {
281 pixelWidth = g_29_pCurrentTextContext->cursorX;
282 while (*cursor == ' ')
283 cursor++;
284 lineBegin = cursor;
285 while (pixelWidth <
287 ch = *cursor;
288 cursor++;
289 if (ch == '\n' || ch == '\r')
290 break;
291 if (ch == 0) {
292 isDone = 1;
293 break;
294 }
295 pixelWidth +=
297 if (pixelWidth >=
299 pixelWidth -=
301 cursor--;
302 wrapPending = 1;
303 if (*cursor != ' ') {
304 while (*cursor != ' ' && cursor > text) {
305 pixelWidth -=
307 ->font[4 + *cursor];
308 cursor--;
309 }
310 if (cursor <= text) {
312 "FATAL : INVALID STRING '%s'n", text);
315 exit(0);
316 }
317 }
318 break;
319 }
320 }
321
328 (pixelWidth - g_29_pCurrentTextContext->cursorX + 1) +
329 1) / 2);
330 }
331 for (drawPos = lineBegin; drawPos < cursor; drawPos++) {
332 DrawTextCharacter(*drawPos);
333 }
335 g_29_pCurrentTextContext->cursorX = (short)previousX;
336 if (wrapPending != 0) {
341 wrapPending = 0;
342 }
343 }
344 return;
345}
346
347/* Function start: 0x4621D5 */
348void DrawTextCharacter(char character)
349{
350 int lineHeight;
351 unsigned int glyphWidth;
352
354 return;
355 if (character == '\n') {
360 *(short *)g_29_pCurrentTextContext->font);
361 } else if (character == '\r') {
364 } else if (character != 0) {
365 lineHeight = *(short *)g_29_pCurrentTextContext->font;
366 glyphWidth = g_29_pCurrentTextContext->font[character + 4];
368 lineHeight, glyphWidth,
370 }
371 return;
372}
373
374/* Function start: 0x4622BD */
375void AppendTextCharacter(char character)
376{
380 return;
381}
382
383/* Function start: 0x4622EE */
384int MeasureShapeFrameStorage(unsigned char *shape, short frame)
385{
386 int size;
387 unsigned short lineLength;
388 unsigned char command;
389 int frameOffset;
390 unsigned char *src;
391
392 size = 0;
393 if (shape == 0)
394 return 0;
395 if (frame < 0)
396 return 0;
397 frameOffset = frame;
398 frameOffset++;
399 frameOffset <<= 2;
400 if (frameOffset < *(unsigned short *)(shape + 4)) {
401 src = shape + *(int *)(shape + frameOffset);
402 src += 8;
403 lineLength = *(unsigned short *)src;
404 src += 2;
405 while (lineLength != 0) {
406 src += 2;
407 src += 2;
408 if ((lineLength & 1) != 0) {
409 lineLength >>= 1;
410 while (lineLength > 0) {
411 command = *src;
412 src++;
413 if ((command & 1) != 0) {
414 command >>= 1;
415 lineLength =
416 (unsigned short)(lineLength - command);
417 src++;
418 size += command;
419 } else {
420 command >>= 1;
421 lineLength =
422 (unsigned short)(lineLength - command);
423 size += command;
424 src += command;
425 }
426 }
427 } else {
428 lineLength >>= 1;
429 size += lineLength;
430 src += lineLength;
431 }
432 lineLength = *(unsigned short *)src;
433 src += 2;
434 }
435 }
436 return size;
437}
438
439#pragma function(memcpy, memset, strcpy, strlen)
440/* Function start: 0x46243F */
441unsigned int DosFarPtrToNear(void *v)
442{
443 return (unsigned int)v;
444}
445
446/* Function start: 0x462452 */
447void *DosNearPtrToFar(unsigned int v)
448{
449 return (void *)v;
450}
451
452/* Function start: 0x462465 */
453char *DosStrrchr(char *s, short c)
454{
455 return strrchr(s, (int)c);
456}
457
458/* Function start: 0x462486 */
459char *DosStrchr(const char *s, short c)
460{
461 return strchr(s, (int)c);
462}
463
464/* Function start: 0x4624A7 */
465char *DosStrcpy(char *dst, const char *src)
466{
467 return strcpy(dst, src);
468}
469
470/* Function start: 0x4624C7 */
471char *CopyStringAndReturnEnd(char *destination, const char *source)
472{
473 strcpy(destination, source);
474 return destination + strlen(destination);
475 return strcpy(destination, source);
476}
477
478/* Function start: 0x46250B */
479short DosStrlen(const char *s)
480{
481 return (short)strlen(s);
482}
483
484/* Function start: 0x462527 */
485void DosMemmove(void *dst, const void *src, size_t n)
486{
487 memmove(dst, src, n & 0xffff);
488 return;
489}
490
491/* Function start: 0x462550 */
492void DosMemset(void *destination, unsigned int count, short value)
493{
494 memset(destination, value, (unsigned short)count);
495 return;
496}
497
498/* Function start: 0x46257A */
500{
501 return 0;
502}
503
504/* Function start: 0x46258D */
505/* Nothing in the shipped executable calls this; the DOS start-time recorder. */
507{
508 return;
509}
510
511/* Function start: 0x46259D */
512short InitializeInputManagerMemory(short eventQueueSize)
513{
517 return 1;
518}
519
520/* Function start: 0x4625CB */
527
528/* Function start: 0x4625F2 */
529/* Nothing in the shipped executable calls this; the DOS interrupt-vector hook, reporting failure. */
530short HookInterruptVector(short vector)
531{
532 return 0;
533}
534
535/* Function start: 0x462605 */
536/* Nothing in the shipped executable calls this; the DOS interrupt-vector restore. */
538{
539 return;
540}
541
542/* Function start: 0x462615 */
543/* Nothing in the shipped executable calls this; restores every hooked DOS vector. */
545{
546 return;
547}
548
549/* Function start: 0x462625 */
550void TranslatePolledInputEvent(unsigned short type, unsigned int value)
551{
552 HostMouseMessage *mouse;
553
554 switch (type) {
555 case 7:
556 QueueInputEvent(type,
561 0, value & 1, (value & 2) >> 1, 0, 0, 0);
562 break;
563 case 10:
569 0, value & 1, (value & 2) >> 1, 0, 0, 0);
570 break;
571 case 0x45:
577 0, value & 1, (value & 2) >> 1, 0, 0, 0);
578 break;
579 case 3:
581 QueueInputEvent(type,
584 0, 0, 0, 0, 0, 0);
585 break;
586 case 1:
588 QueueInputEvent(type,
591 0,
592 mouse->primaryButton,
593 mouse->secondaryButton,
594 mouse->secondaryButton * 2 |
595 mouse->primaryButton | value >> 2,
596 0, 0);
597 break;
598 case 4:
599 break;
600 }
601}
602
603/* Function start: 0x462849 */
604void QueueInputEventAtCursor(unsigned int type, short primaryButton,
605 short secondaryButton)
606{
607 /* Preserve the original 16-bit event ID. */
608 unsigned int eventType = type & 0xffff;
609
612 primaryButton, secondaryButton, 0, 0, 0);
613}
614
615/* Function start: 0x462890 */
617{
618 int index;
619
621 for (index = 0; index < 0x100; index++) {
624 return &g_3_aInputEventArray[index];
625 }
626 }
627 } else {
628 memset(g_3_aInputEventArray, 0,
629 sizeof(g_3_aInputEventArray));
634 return &g_3_aInputEventArray[0];
635 }
636 return 0;
637}
638
639#pragma intrinsic(memset)
640/* Function start: 0x46294F */
642{
643 int slot;
644
645 for (slot = 0; slot < 0x100; slot++) {
646 if (&g_3_aInputEventArray[slot] == event)
648 }
649 return;
650}
651
652/* Function start: 0x4629A7 */
653void QueueInputEvent(int type, int x, int y, int value,
654 int primaryButton, int secondaryButton,
655 unsigned int ignored, unsigned int field14,
656 unsigned int field18)
657{
658 unsigned int modifiers;
659
660 (void)ignored;
661
662 modifiers = 0;
663 if (GetShiftKeyState() != 0)
664 modifiers |= 0xe0;
665 if (GetControlKeyState() != 0)
666 modifiers |= 0x3800;
667 if (GetKeyboardModifiers() != 0)
668 modifiers |= 0x700;
669 if (primaryButton != 0)
670 modifiers |= 1;
671 if (secondaryButton != 0)
672 modifiers |= 2;
673
674 if (g_pInputEventHead == 0) {
676 if (g_pInputEventHead == 0) {
678 return;
679 }
683 } else {
685 if (g_pInputEventTail->next == 0) {
687 return;
688 }
693 }
694 g_pInputEventTail->type = type;
695 g_pInputEventTail->modifiers = modifiers;
696 g_pInputEventTail->x = x;
697 g_pInputEventTail->y = y;
698 g_pInputEventTail->value = value;
699 g_pInputEventTail->primaryButton = (short)primaryButton;
700 g_pInputEventTail->secondaryButton = (short)secondaryButton;
701 g_pInputEventTail->field_14 = field14;
702 g_pInputEventTail->field_18 = field18;
704 if (g_pInputEventTail->type == 3) {
707 }
708 if (g_pInputEventTail->type == 2) {
711 g_nPreviousPrimaryButton = primaryButton;
712 g_nPreviousSecondaryButton = secondaryButton;
713 }
714 if (g_pInputEventTail->type == 1 ||
715 g_pInputEventTail->type == 8 ||
716 g_pInputEventTail->type == 9) {
717 if ((g_pInputEventTail->primaryButton != 0 &&
727 }
728 }
729 }
730 return;
731}
732
733/* Function start: 0x462C43 */
735{
736 InputEvent *event;
737 InputEvent *nextEvent;
738
739 event = g_pInputEventHead;
740 while (event != 0) {
741 nextEvent = event->next;
742 ReleaseInputEvent(event);
743 event = nextEvent;
744 }
747 return;
748}
749
750/* Function start: 0x462C9C */
752{
753 InputEvent *event;
754 InputEvent *nextEvent;
755
756 event = g_pInputEventHead;
757 while (event != 0) {
758 nextEvent = event->next;
759 if (event->type != type) {
760 if (event->previous != 0)
761 event->previous->next = event->next;
762 else
763 g_pInputEventHead = event->next;
764 if (event->next != 0)
765 event->next->previous = event->previous;
766 else
768 ReleaseInputEvent(event);
769 }
770 event = nextEvent;
771 }
772 return;
773}
774
775/* Function start: 0x462D48 */
777{
778 if (event->previous != 0) {
779 if (event->next != 0) {
780 event->previous->next = event->next;
781 event->next->previous = event->previous;
782 } else {
783 event->previous->next = 0;
785 }
786 } else {
787 if (event->next != 0) {
788 g_pInputEventHead = event->next;
789 event->next->previous = 0;
790 } else {
793 }
794 }
795 ReleaseInputEvent(event);
796 return;
797}
798
799/* Function start: 0x462DFC */
801{
802 int posX;
803 int posY;
804 int clearQueue;
805 int type;
806
807 clearQueue = 0;
811 type = 0;
812 if (g_pInputEventHead != 0) {
813 posX = (int)g_pInputEventHead->x;
814 posY = (int)g_pInputEventHead->y;
819 else if ((int)g_16_stEventQueuePointerData.viewport->right < posX)
825 else if ((int)g_16_stEventQueuePointerData.viewport->bottom < posY)
828 }
829
830 state->status = (short)g_pInputEventHead->status;
831 state->modifiers =
833 switch (g_pInputEventHead->type) {
834 case 2:
838 state->x = g_pInputEventHead->x;
839 state->y = g_pInputEventHead->y;
840 *(unsigned int *)&state->value =
843 state->value = (short)*(unsigned int *)&state->value;
844 state->status = (short)g_pInputEventHead->status;
845 type = 2;
846 break;
847 case 1:
851 (unsigned char)g_pInputEventHead->primaryButton;
853 (unsigned char)g_pInputEventHead->secondaryButton;
854 state->x = g_pInputEventHead->x;
855 state->y = g_pInputEventHead->y;
856 *(unsigned int *)&state->value =
859 state->value = (short)*(unsigned int *)&state->value;
860 state->status = (short)g_pInputEventHead->status;
861 type = 1;
862 if (state->status > 1)
863 type = 1;
864 break;
865 case 4:
866 *(unsigned int *)&state->value =
868 state->value = (short)g_pInputEventHead->field_18;
869 state->status = (short)g_pInputEventHead->field_14;
872 type = 4;
873 break;
874 case 5:
875 state->x = g_pInputEventHead->value;
876 *(unsigned int *)&state->value =
878 state->value = (short)g_pInputEventHead->field_18;
879 state->status = (short)g_pInputEventHead->field_14;
882 type = 5;
883 break;
884 case 6:
885 state->x = g_pInputEventHead->value;
886 type = 6;
887 break;
888 case 7:
889 case 8:
890 case 9:
891 state->x = g_pInputEventHead->x;
892 state->y = g_pInputEventHead->y;
893 type = (int)g_pInputEventHead->type;
894 break;
895 case 3:
898 state->x = g_pInputEventHead->x;
899 state->y = g_pInputEventHead->y;
900 type = 3;
901 clearQueue = 1;
902 break;
903 default:
904 state->x = g_pInputEventHead->x;
905 state->y = g_pInputEventHead->y;
906 type = 0;
907 break;
908 }
910 if (clearQueue != 0) {
913 }
914 } else {
917 }
918 return type;
919}
920
921/* Function start: 0x46327F */
922int PollInputEvent(InputEventState *event, short deviceMask)
923{
925 return GetNextInputEvent(event);
926}
927
928/* Function start: 0x4632A5 */
929short PeekInputEvent(InputEventState *state, short type)
930{
931 unsigned int flags;
932 int eventType;
933 InputEvent *event;
934
935 flags = 0;
937 for (event = g_pInputEventHead;
938 event != 0 && event->type != type;
939 event = event->next)
940 ;
941 if (event != 0) {
942 state->type = (int)event->type;
943 *(unsigned int *)&state->value = event->modifiers;
944 state->status = (short)event->field_14;
945 state->value = (short)event->field_18;
946 state->timestamp = event->timestamp;
947 eventType = (int)event->type;
948 if (eventType == 1 || eventType == 2)
949 flags |= 8;
950 if (event->primaryButton != 0)
951 flags |= 1;
952 else
953 ;
954 if (event->secondaryButton != 0)
955 flags |= 2;
956 else
957 ;
958 state->modifiers = (unsigned short)flags;
959 state->x = event->x;
960 state->y = event->y;
961 state->status = (short)event->status;
962 state->value = (short)*(unsigned int *)&state->value;
963 return 1;
964 }
965 return 0;
966}
967
968/* Function start: 0x4633E7 */
970{
971 unsigned int modifiers;
972 InputEvent *event;
973
974 modifiers = 0;
976 for (event = g_pInputEventHead;
977 event != 0 && event->type != type;
978 event = event->next)
979 ;
980 if (event != 0) {
981 if (event->type == 3) {
984 }
985 g_1_stFoundInputEvent.type = (int)event->type;
986 *(unsigned int *)&g_1_stFoundInputEvent.value =
987 event->modifiers;
988 g_1_stFoundInputEvent.value = (short)event->field_18;
989 g_1_stFoundInputEvent.status = (short)event->field_14;
990 g_1_stFoundInputEvent.timestamp = event->timestamp;
991 if (event->type == 1 || event->type == 2)
992 modifiers |= 8;
993 if (event->primaryButton != 0)
994 modifiers |= 1;
995 else
996 ;
997 if (event->secondaryButton != 0)
998 modifiers |= 2;
999 else
1000 ;
1002 (unsigned short)modifiers;
1003 g_1_stFoundInputEvent.x = event->x;
1004 g_1_stFoundInputEvent.y = event->y;
1005 g_1_stFoundInputEvent.status = (short)event->status;
1007 (short)*(unsigned int *)&g_1_stFoundInputEvent.value;
1008 return &g_1_stFoundInputEvent;
1009 } else
1010 return 0;
1011}
1012
1013/* Function start: 0x46354F */
1015{
1018 return;
1019}
1020
1021/* Function start: 0x463571 */
1023{
1025 return 1;
1026}
1027
1028/* Function start: 0x46358F */
1029/* Nothing in the shipped executable calls this; the DOS mouse pointer set-up, reporting success. */
1031{
1032 return 1;
1033}
1034
1035/* Function start: 0x4635A3 */
1036/* Nothing in the shipped executable calls this. */
1038{
1039 return;
1040}
1041
1042/* Function start: 0x4635B3 */
1043/* Nothing in the shipped executable calls this. */
1045{
1046 return;
1047}
1048
1049/* Function start: 0x4635C3 */
1050/* Nothing in the shipped executable calls this. */
1052{
1053 return;
1054}
1055
1056/* Function start: 0x4635D3 */
1057void CheckCursor(void)
1058{
1059 return;
1060}
1061
1062/* Function start: 0x4635E3 */
1097
1098/* Function start: 0x4636F7 */
1129
1130/* Function start: 0x4637F4 */
1163
1164/* Function start: 0x4638F1 */
1182
1183/* Function start: 0x46396C */
1184/* The Win32 port draws its own cursor; the software cursor redraw that
1185 * follows the early return is disabled. */
1187{
1188 int changed;
1189 int minX;
1190 int minY;
1191 int maxX;
1192 int maxY;
1193
1194 return;
1195 minX = 319;
1196 maxX = 0;
1197 minY = 199;
1198 maxY = 0;
1200 changed = 0;
1202 if (g_pDrawnInputCursorShape != 0) {
1205 (short)g_4_nDrawnCursorX,
1206 (short)g_15_nMouseRenderY,
1210 if (g_4_nDrawnCursorX - 16 < minX)
1211 minX = g_4_nDrawnCursorX - 16;
1212 if (g_4_nDrawnCursorX + 16 > maxX)
1213 maxX = g_4_nDrawnCursorX + 16;
1214 if (g_15_nMouseRenderY - 16 < minY)
1215 minY = g_15_nMouseRenderY - 16;
1216 if (g_15_nMouseRenderY + 16 > maxY)
1217 maxY = g_15_nMouseRenderY + 16;
1218 changed = 1;
1219 }
1220 if (g_nMouseCursorDrawDepth > 0 &&
1235 if (g_4_nDrawnCursorX - 16 < minX)
1236 minX = g_4_nDrawnCursorX - 16;
1237 if (g_4_nDrawnCursorX + 16 > maxX)
1238 maxX = g_4_nDrawnCursorX + 16;
1239 if (g_15_nMouseRenderY - 16 < minY)
1240 minY = g_15_nMouseRenderY - 16;
1241 if (g_15_nMouseRenderY + 16 > maxY)
1242 maxY = g_15_nMouseRenderY + 16;
1243 changed = 1;
1244 }
1245 if (changed != 0)
1246 DIBupdate(minX, minY, maxX, maxY);
1247 }
1248 return;
1249}
1250
1251/* Function start: 0x463BA1 */
1252/* Shows the cursor. Only the first statement is live in the Win32 port;
1253 * the earlier counting and software-cursor versions follow the returns. */
1255{
1256 int minX;
1257 int minY;
1258 int maxX;
1259 int maxY;
1260
1262 return;
1264 return;
1273 return;
1275 minX = 319;
1276 maxX = 0;
1277 minY = 199;
1278 maxY = 0;
1279 if (g_nMouseCursorDrawDepth > 0 &&
1282 if (g_pDrawnInputCursorShape != 0) {
1285 (short)g_4_nDrawnCursorX,
1286 (short)g_15_nMouseRenderY,
1289 if (g_4_nDrawnCursorX - 16 < minX)
1290 minX = g_4_nDrawnCursorX - 16;
1291 if (g_4_nDrawnCursorX + 16 > maxX)
1292 maxX = g_4_nDrawnCursorX + 16;
1293 if (g_15_nMouseRenderY - 16 < minY)
1294 minY = g_15_nMouseRenderY - 16;
1295 if (g_15_nMouseRenderY + 16 > maxY)
1296 maxY = g_15_nMouseRenderY + 16;
1297 }
1308 g_pDrawnInputCursorShape = (unsigned char *)1;
1311 if (g_4_nDrawnCursorX - 16 < minX)
1312 minX = g_4_nDrawnCursorX - 16;
1313 if (g_4_nDrawnCursorX + 16 > maxX)
1314 maxX = g_4_nDrawnCursorX + 16;
1315 if (g_15_nMouseRenderY - 16 < minY)
1316 minY = g_15_nMouseRenderY - 16;
1317 if (g_15_nMouseRenderY + 16 > maxY)
1318 maxY = g_15_nMouseRenderY + 16;
1319 DIBupdate(minX, minY, maxX, maxY);
1320 }
1321 return;
1322}
1323
1324/* Function start: 0x463E19 */
1325/* Hides the cursor. Only the first statement is live in the Win32 port;
1326 * the earlier counting and software-cursor versions follow the returns. */
1355
1356/* Function start: 0x463EEE */
1375
1376/* Function start: 0x463F74 */
1377void SetMouseHomePosition(short x, short y)
1378{
1382 return;
1383}
1384
1385/* Function start: 0x463FAA */
1387{
1390 SetInputCursorHostPosition(point.x, point.y);
1391 return;
1392}
1393
1394/* Function start: 0x463FE0 */
1395/* Nothing in the shipped executable calls this. Reads back the mouse
1396 * position SetMouseHomePosition stored. */
1398{
1399 position->x = g_16_stEventQueuePointerData.x;
1400 position->y = g_16_stEventQueuePointerData.y;
1401 return;
1402}
1403
1404/* Function start: 0x464009 */
1405void SetFrameTimerPeriod(short period)
1406{
1407 SetMultimediaTimerCallback((int)period);
1408}
1409
1410/* Function start: 0x464021 */
1411void SetFrameTimerAndWait(short period)
1412{
1413 SetFrameTimerPeriod(period);
1415}
1416
1417/* Function start: 0x46403D */
1419{
1421}
1422
1423/* Function start: 0x464055 */
1425{
1426 while (g_5_nFrameTimerWaitTicksValue != 0) ;
1427}
1428
1429/* Function start: 0x464072 */
1431{
1433}
1434
1435#pragma function(memset)
1436/* Function start: 0x46409B */
1437void *AllocateZeroedRecords(int count, short elementSize, short flags)
1438{
1439 void *allocation;
1440
1441 allocation = AllocateTaggedMemory(
1442 count * elementSize, (short)(flags | 0x40));
1443 memset(allocation, 0, count * elementSize);
1444 return allocation;
1445}
1446
1447/* Function start: 0x4640E4 */
1448/* Nothing in the shipped executable calls this; the DOS far-heap dump. */
1450{
1451 return;
1452}
1453
1454#pragma intrinsic(memset)
1455/* Function start: 0x4640F4 */
1456unsigned short EnableHighMemoryResources(void)
1457{
1461 return 1;
1462}
1463
1464/* Function start: 0x464123 */
1465void *AllocateDefaultMemory(unsigned int size)
1466{
1467 return AllocateTaggedMemory(size, 0);
1468}
1469
1470/* Function start: 0x464141 */
1472{
1473 return 0;
1474}
1475
1476/* Function start: 0x464153 */
1477/* Nothing in the shipped executable calls this. Frees a block from
1478 * AllocateDefaultMemory. */
1479void FreeDefaultMemory(void *block)
1480{
1481 ReleasePacketHandle(block);
1482}
1483
1484/* Function start: 0x46416A */
1486{
1487 return;
1488}
1489
1490/* Function start: 0x46417A */
1492{
1493 return value;
1494}
1495
1496/* Function start: 0x46418D */
1497unsigned int IdentityWord(unsigned int v)
1498{
1499 return v;
1500}
1501
1502/* Function start: 0x4641A0 */
1504{
1505 return;
1506}
1507
1508/* Function start: 0x4641B0 */
1509unsigned int GetAvailableFarMemory(void)
1510{
1511 return 0x3e8000;
1512}
1513
1514/* Function start: 0x4641C5 */
1516{
1517 return 0x3e8000;
1518}
1519
1520/* Function start: 0x4641DA */
1521/* Nothing in the shipped executable calls this; the DOS EMS start-up, reporting no EMS. */
1523{
1524 return 0;
1525}
1526
1527/* Function start: 0x4641EC */
1528/* Nothing in the shipped executable calls this. */
1530{
1531 return;
1532}
1533
1534/* Function start: 0x4641FC */
1535/* Nothing in the shipped executable calls this; EMS allocations always fail. */
1536void *AllocateEmsBlock(unsigned int size)
1537{
1538 return 0;
1539}
1540
1541/* Function start: 0x46420E */
1542/* Nothing in the shipped executable calls this. */
1543unsigned int GetEmsTotalFree(void)
1544{
1545 return 0;
1546}
1547
1548/* Function start: 0x464220 */
1549/* Nothing in the shipped executable calls this. */
1550short CheckEmsPointer(void *pointer)
1551{
1552 return 0;
1553}
1554
1555/* Function start: 0x464233 */
1556/* Nothing in the shipped executable calls this. */
1557void FreeEmsBlockHook(void *block)
1558{
1559 return;
1560}
1561
1562/* Function start: 0x464243 */
1563/* Nothing in the shipped executable calls this; no pointer is an EMS pointer. */
1564int IsEmsPointer(void *pointer)
1565{
1566 return 0;
1567}
1568
1569/* Function start: 0x464255 */
1570/* Saves the EMS page mapping under DOS; there is none to save on Win32. */
1572{
1573 return 0;
1574}
1575
1576/* Function start: 0x464268 */
1577/* Restores the EMS page mapping under DOS; there is none on Win32. */
1579{
1580 return 0;
1581}
1582
1583/* Function start: 0x46427B */
1584/* Nothing in the shipped executable calls this. Flushes the keys the
1585 * keyboard handler has queued. */
1590
1591#pragma function(memset)
1592/* Function start: 0x46428B */
1594{
1595 unsigned int control = g_77_abKeyboardEventStates[0x1d];
1596 unsigned int alt = g_77_abKeyboardEventStates[0x38];
1597
1600 g_77_abKeyboardEventStates[0x1d] = control;
1601 g_77_abKeyboardEventStates[0x38] = alt;
1603}
1604
1605/* Function start: 0x4642D6 */
1607{
1611}
1612
1613/* Function start: 0x4642FA */
1614/* Nothing in the shipped executable calls this; the DOS keyboard handler's reboot request. */
1616{
1617 return;
1618}
1619
1620/* Function start: 0x46430A */
1621/* Nothing in the shipped executable calls this. */
1623{
1624 return;
1625}
1626
1627#pragma intrinsic(memset)
1628/* Function start: 0x46431A */
1629void SetInputKeyState(int scanCode, unsigned char pressed)
1630{
1631 if (scanCode >= 0 && scanCode < 0x80) {
1632 g_77_abKeyboardEventStates[scanCode] = pressed;
1633 return;
1634 }
1635 SystemDebugPrintf("keyboard almost messed up\n");
1638 exit(1);
1639}
1640
1641#pragma function(memset)
1642/* Function start: 0x46436E */
1644{
1645 /* Two slots retail reserves and never touches. */
1646 int minimumDistance;
1647 int scan;
1648 int test;
1649 int nextObject;
1650 int ceiling;
1651 int furthest;
1652 int nextFarthest;
1653 int placed;
1654 int remaining;
1655
1656 ceiling = -999999999;
1657 furthest = -1;
1658 nextObject = furthest;
1659 memset(g_11_anPlacedObjectDepths, 0,
1661 for (scan = 0; scan < SPACE_OBJECT_COUNT; scan++) {
1662 if (ceiling <
1663 (int)(unsigned short)g_asObjectDistance[scan]) {
1664 ceiling =
1665 (int)(unsigned short)g_asObjectDistance[scan];
1666 furthest = scan;
1667 }
1668 }
1669 placed = 0;
1670 nextObject = furthest;
1671 for (scan = 0; scan < SPACE_OBJECT_COUNT; scan++) {
1672 g_56_anStoredObjectSortedIndicesData[placed] = nextObject;
1673 if (nextObject == -1)
1674 return;
1675 g_11_anPlacedObjectDepths[nextObject] = 1;
1676 nextFarthest = -1;
1677 nextObject = nextFarthest;
1678 for (test = 0; test < SPACE_OBJECT_COUNT;
1679 test++) {
1680 if (g_11_anPlacedObjectDepths[test] == 0 &&
1681 g_asObjectScreenX[test] != (short)0x8001 &&
1682 nextFarthest <
1683 (int)(unsigned short)
1684 g_asObjectDistance[test] &&
1685 (int)(unsigned short)g_asObjectDistance[test] <=
1686 ceiling) {
1687 nextObject = test;
1688 nextFarthest =
1689 (int)(unsigned short)
1690 g_asObjectDistance[test];
1691 }
1692 }
1693 placed++;
1694 }
1695}
1696
1697long DivideFixed(int numerator, int denominator);
1698
1699/* Function start: 0x4644DA */
1701{
1702 int drawObject;
1703 int sortedIndex;
1704 int object;
1705
1706 for (sortedIndex = 0; sortedIndex < SPACE_OBJECT_COUNT;
1707 sortedIndex++) {
1708 object = g_56_anStoredObjectSortedIndicesData[sortedIndex];
1709 if (object < 0)
1710 break;
1711 if (g_asObjectType[object] < 0)
1712 break;
1713 if (g_aeObjectClass[object] != OBJECT_CLASS_NULL) {
1714 switch (g_aeObjectClass[object]) {
1715 case OBJECT_CLASS_STAR:
1717 case OBJECT_CLASS_DUST:
1718 drawObject = object;
1719 g_asObjectDrawX[drawObject] = (short)(
1720 g_asObjectScreenX[drawObject] +
1722 g_asObjectDrawY[drawObject] = (short)(
1723 g_asObjectScreenY[drawObject] +
1725 if (g_nNavPointerObject == drawObject) {
1728 g_asObjectDrawX[drawObject],
1729 g_asObjectDrawY[drawObject],
1730 g_apObjectShape[drawObject],
1731 g_asObjectViewFrame[drawObject]);
1732 } else {
1735 g_asObjectDrawX[drawObject],
1736 g_asObjectDrawY[drawObject],
1738 g_asObjectViewFrame[drawObject]);
1739 }
1740 break;
1741 default:
1742 drawObject = object;
1743 g_asObjectDrawX[drawObject] = (short)(
1744 g_asObjectScreenX[drawObject] +
1746 g_asObjectDrawY[drawObject] = (short)(
1747 g_asObjectScreenY[drawObject] +
1749 if (g_apObjectShape[drawObject] != 0) {
1752 g_asObjectDrawX[drawObject],
1753 g_asObjectDrawY[drawObject],
1754 g_apObjectShape[drawObject],
1755 g_asObjectViewFrame[drawObject],
1756 g_asObjectScreenAngle[drawObject],
1757 g_asObjectScreenScale[drawObject],
1758 g_asObjectFlip[drawObject]);
1759 }
1760 break;
1761 }
1762 }
1763 }
1764 return;
1765}
1766
1767/* Function start: 0x46470E */
1769{
1770 int drawObject;
1771 int object;
1772
1773 for (object = 0; object < SPACE_OBJECT_COUNT; object++) {
1774 if (g_asObjectType[object] < 0)
1775 break;
1776 if (g_aeObjectClass[object] != OBJECT_CLASS_NULL) {
1777 switch (g_aeObjectClass[object]) {
1778 case OBJECT_CLASS_STAR:
1780 case OBJECT_CLASS_DUST:
1781 drawObject = object;
1782 if (drawObject == g_nNavPointerObject)
1785 g_asObjectDrawX[drawObject],
1786 g_asObjectDrawY[drawObject],
1787 g_apObjectShape[drawObject],
1788 g_asObjectViewFrame[drawObject],
1790 else
1793 g_asObjectDrawX[drawObject],
1794 g_asObjectDrawY[drawObject],
1796 g_asObjectViewFrame[drawObject],
1798 break;
1799 default:
1800 drawObject = object;
1801 if (g_apObjectShape[drawObject] != 0)
1804 g_asObjectDrawX[drawObject],
1805 g_asObjectDrawY[drawObject],
1806 g_apObjectShape[drawObject],
1807 g_asObjectViewFrame[drawObject],
1808 g_asObjectScreenAngle[drawObject],
1809 g_asObjectScreenScale[drawObject],
1810 g_asObjectFlip[drawObject],
1812 break;
1813 }
1814 }
1815 }
1816 return;
1817}
1818
1819/* Function start: 0x4648C5 */
1820void set_up_screen_viewport(signed char mode)
1821{
1824 case 4:
1825 case 5:
1829 break;
1830 default:
1832 (const ScreenViewportGeometry *)(
1836 ->geometryOffsets[0]);
1837 break;
1838 }
1839 if (g_nCockpitDisplayMode != 0 &&
1840 g_nCockpitDisplayMode != -2) {
1844 (short)(g_nScreenWidth / 2);
1848 (short)(g_nScreenHeight / 2);
1855 g_nScreenWidth = 320;
1856 g_nScreenHeight = 200;
1857 } else {
1861 (short)(g_nScreenWidth / 2);
1865 (short)(g_nScreenHeight / 2);
1870 }
1871 return;
1872}
1873
1874/* Function start: 0x464A5E */
1875/* Nothing in the shipped executable calls this. */
1877{
1878 return 0;
1879}
1880
1881/* Function start: 0x464A70 */
1882/* Nothing in the shipped executable calls this. */
1884{
1885 return;
1886}
1887
1888/* Function start: 0x464A80 */
1889/* Nothing in the shipped executable calls this. */
1891{
1892 return;
1893}
1894
1895/* Function start: 0x464A90 */
1897{
1898 return;
1899}
1900
1901/* Function start: 0x464AA0 */
1903{
1904 return;
1905}
1906
1907/* Function start: 0x464AB0 */
1909{
1910 return 0x8000;
1911}
1912
1913/* Function start: 0x464AC4 */
1915{
1916 return 0x8000;
1917}
1918
1919/* Function start: 0x464AD8 */
1920/* Nothing in the shipped executable calls this. */
1922{
1923 return;
1924}
1925
1926/* Function start: 0x464AE8 */
1927void StartupHook(unsigned int (*callback)(unsigned int, short))
1928{
1929 (void)callback;
1930 return;
1931}
1932
1933/* Function start: 0x464AF8 */
1934/* Nothing in the shipped executable calls this; no BIOS keyboard intercept on Win32. */
1936{
1937 return 0;
1938}
1939
1940/* Function start: 0x464B0B */
1941unsigned int JoystickEdgeHook(int button)
1942{
1943 (void)button;
1944 return;
1945}
1946
1947/* Function start: 0x464B1B */
1948/* Nothing in the shipped executable calls this. Allocates a near block. */
1949void *AllocateNearMemory(short size)
1950{
1951 return AllocateTaggedMemory(size, 0x40);
1952}
1953
1954/* Function start: 0x464B3A */
1955void FreeIfNotNull(void *p)
1956{
1957 if (p != 0)
1958 free(p);
1959 return;
1960}
1961
1962/* Function start: 0x464B60 */
1963unsigned int GetStartupErrorCode(int vector)
1964{
1965 (void)vector;
1966 return 0;
1967}
1968
1969/* Function start: 0x464B72 */
1970/* Nothing in the shipped executable calls this. */
1972{
1973 return;
1974}
1975
1976/* Function start: 0x464B82 */
1977/* WC2 hands this the drive letter index; the body ignores it. */
1978void PersonnelDriveHook(short drive)
1979{
1980 return;
1981}
1982
1983/* Function start: 0x464B92 */
1984unsigned short SelectDiskDriveHook(short drive)
1985{
1986 return 0;
1987}
1988
1989/* Function start: 0x464BA5 */
1991{
1992 return 0;
1993}
1994
1995/* Function start: 0x464BB8 */
1996unsigned short GetShutdownErrorCode(unsigned char *driveState)
1997{
1998 (void)driveState;
1999 return 0;
2000}
2001
2002/* Function start: 0x464BCB */
2004{
2005 return;
2006}
2007
2008/* Function start: 0x464BDB */
2010{
2011 return;
2012}
2013
2014/* Function start: 0x464BEB */
2015/* Nothing in the shipped executable calls this; never a Tandy keyboard on Win32. */
2017{
2018 return 0;
2019}
2020
2021#pragma function(abs)
2022/* Function start: 0x464BFE */
2023short IsVectorWithinRange(FixedVector *vector, short range)
2024{
2025 int magnitude;
2026 int rangeFixed;
2027
2028 rangeFixed = (int)range << 8;
2029 magnitude = Vector_magnitude(vector);
2030 if (abs(rangeFixed) >= magnitude)
2031 return 1;
2032 return 0;
2033}
2034
2035/* Function start: 0x464C4B */
2036unsigned int shrink_vector(FixedVector *vector)
2037{
2038 unsigned int shrinking;
2039
2040 do {
2041 shrinking = 0;
2042 shrinking |= shrink(&vector->x);
2043 shrinking |= shrink(&vector->y);
2044 shrinking |= shrink(&vector->z);
2045 } while (shrinking != 0);
2046 return 0;
2047}
2048
2049/* Function start: 0x464CA4 */
2050unsigned int shrink(int *component)
2051{
2052 unsigned short whole;
2053 unsigned short fraction;
2054
2055 *component = *component / 2;
2056 whole = (unsigned short)((unsigned int)*component >> 16);
2057 fraction = (unsigned short)(*component & 0xffff);
2058 if (whole == 0) {
2059 if (fraction <= 0x0f00)
2060 return 0;
2061 return 1;
2062 } else if ((short)whole == -1) {
2063 if (fraction >= 0xf100)
2064 return 0;
2065 return 1;
2066 } else if (whole != 0)
2067 return 1;
2068}
2069
2070/* Function start: 0x464D5F */
2071short ServiceInputDevices(short deviceMask)
2072{
2073 (void)deviceMask;
2075 if (g_nInputPollPeriod == 1)
2077 else
2084 return 1;
2085 }
2087 if (g_bSceneEscapeRequested != 0)
2088 return 1;
2089 return 0;
2090}
2091
2092/* Function start: 0x464E06 */
2094{
2096 return;
2097}
2098
2099/* Function start: 0x464E1E */
2101{
2102 ConfigureInputPump(1, 0);
2103}
2104
2105/* Function start: 0x464E35 */
2110
2111/* Function start: 0x464E4F */
2112int ConfigureInputPump(int slot, void (*pump)(void))
2113{
2114 if (slot == 1)
2116 return 0;
2117}
2118
2119/* Function start: 0x464E73 */
2120short LoadInputCursorShape(const char *filename, short section,
2121 short flags)
2122{
2123 void *shape;
2124
2125 (void)flags;
2126 if (filename != 0) {
2127 shape = LoadNamedPacket(filename, section, 0, 0, 0, 1);
2130 if (shape == 0)
2131 return 0;
2132 }
2134 return 1;
2135}
2136
2137/* Function start: 0x464EE0 */
2139{
2140 return;
2141}
2142
2143/* Function start: 0x464EF0 */
2145{
2146 return;
2147}
2148
2149/* Function start: 0x464F00 */
2150/* Nothing in the shipped executable calls this. */
2152{
2153 return;
2154}
2155
2156/* Function start: 0x464F10 */
2158{
2160 return;
2161}
2162
2163/* Function start: 0x464F25 */
2164long GetNamedPacketSize(const char *filename, short section)
2165{
2166 return GetPacketSize(filename, section);
2167}
2168
2169/* Function start: 0x464F45 */
2170void *LoadNamedPacket(const char *filename, short section,
2171 void *destination, unsigned short flags,
2172 void *decompressionWorkspace,
2173 int registerHandle)
2174{
2175 return PacketLoad(filename, section, destination, flags,
2176 decompressionWorkspace, registerHandle);
2177}
2178
2179/* Function start: 0x464F75 */
2181 const SceneHotspot *hotspot,
2182 short offsetX, short offsetY)
2183{
2184 bounds->left = (short)(hotspot->left + offsetX);
2185 bounds->right = (short)(hotspot->right + offsetX);
2186 bounds->bottom = (short)(hotspot->bottom + offsetY);
2187 bounds->top = (short)(hotspot->top + offsetY);
2188 return 1;
2189}
2190
2191/* Function start: 0x464FD7 */
2193{
2194 return;
2195}
2196
2197/* This caller pushes the palette index sign-extended, as for an int
2198 * parameter (warning C4028 against the header prototype). */
2199void DIBsetPalette(int index, short *rgb);
2200
2201/* Function start: 0x464FE7 */
2202void SetPaletteEntryFromTriplet(const unsigned char *triplet, short index)
2203{
2204 short rgb[3];
2205
2206 rgb[0] = triplet[0];
2207 rgb[1] = triplet[1];
2208 rgb[2] = triplet[2];
2209 DIBsetPalette(index, rgb);
2210 return;
2211}
2212
2213/* Function start: 0x46502E */
2214void SetMusicTickRateHook(short period)
2215{
2216 (void)period;
2217 return;
2218}
2219
2220/* Function start: 0x46503E */
2221/* Nothing in the shipped executable calls this. */
2223{
2224 return;
2225}
2226
2227/* Function start: 0x46504E */
2228/* Nothing in the shipped executable calls this. */
2230{
2231 return;
2232}
2233
2234/* Function start: 0x46505E */
2236 short x, short y,
2237 unsigned char *shape,
2238 short frame)
2239{
2240 int spR;
2241 int spB;
2242 int spT;
2243 ShortRect spLimits;
2244 int spL;
2245 int rcL;
2246 int rcR;
2247 int rcB;
2248 int rcT;
2249
2250 GetShapeFrameBounds(&spLimits.left, x, y, shape, frame);
2251 rcL = rectangle->left;
2252 rcT = rectangle->top;
2253 rcR = rectangle->right;
2254 rcB = rectangle->bottom;
2255 spL = spLimits.left;
2256 spT = spLimits.top;
2257 spR = spLimits.right;
2258 spB = spLimits.bottom;
2259 if (((spL <= rcL && rcL <= spR) ||
2260 (spL <= rcR && rcR <= spR))) {
2261 if (spT <= rcT && rcT <= spB)
2262 return 1;
2263 if (spT <= rcB && rcB <= spB)
2264 return 1;
2265 }
2266 if (((rcL <= spL && spL <= rcR) ||
2267 (rcL <= spR && spR <= rcR))) {
2268 if (rcT <= spT && spT <= rcB)
2269 return 1;
2270 if (rcT <= spB && spB <= rcB)
2271 return 1;
2272 }
2273 return 0;
2274}
2275
2276/* Function start: 0x4651B7 */
2278 const ShortRect *first,
2279 const ShortRect *second)
2280{
2281 int pointXs[16];
2282 int cornerIndex;
2283 int pointCount;
2284 int pointYs[16];
2285 int insideFlags[4];
2286 int containedCount;
2287 int x;
2288 int y;
2289
2290 pointCount = 0;
2291 pointXs[pointCount] = first->left;
2292 pointYs[pointCount] = first->top;
2293 pointCount++;
2294 pointXs[pointCount] = first->left;
2295 pointYs[pointCount] = first->bottom;
2296 pointCount++;
2297 pointXs[pointCount] = first->right;
2298 pointYs[pointCount] = first->top;
2299 pointCount++;
2300 pointXs[pointCount] = first->right;
2301 pointYs[pointCount] = first->bottom;
2302 pointCount++;
2303 pointXs[pointCount] = second->left;
2304 pointYs[pointCount] = second->top;
2305 pointCount++;
2306 pointXs[pointCount] = second->left;
2307 pointYs[pointCount] = second->bottom;
2308 pointCount++;
2309 pointXs[pointCount] = second->right;
2310 pointYs[pointCount] = second->top;
2311 pointCount++;
2312 pointXs[pointCount] = second->right;
2313 pointYs[pointCount] = second->bottom;
2314 pointCount++;
2315 pointXs[pointCount] = first->left;
2316 pointYs[pointCount] = second->top;
2317 pointCount++;
2318 pointXs[pointCount] = first->left;
2319 pointYs[pointCount] = second->bottom;
2320 pointCount++;
2321 pointXs[pointCount] = first->right;
2322 pointYs[pointCount] = second->top;
2323 pointCount++;
2324 pointXs[pointCount] = first->right;
2325 pointYs[pointCount] = second->bottom;
2326 pointCount++;
2327 pointXs[pointCount] = second->left;
2328 pointYs[pointCount] = first->top;
2329 pointCount++;
2330 pointXs[pointCount] = second->left;
2331 pointYs[pointCount] = first->bottom;
2332 pointCount++;
2333 pointXs[pointCount] = second->right;
2334 pointYs[pointCount] = first->top;
2335 pointCount++;
2336 pointXs[pointCount] = second->right;
2337 pointYs[pointCount] = first->bottom;
2338 pointCount++;
2339
2340 /* The condition and step are transposed in the original: the loop
2341 * tests cornerIndex++ (zero on entry) and never runs. */
2342 for (cornerIndex = 0; cornerIndex++; cornerIndex < pointCount) {
2343 x = pointXs[cornerIndex];
2344 y = pointYs[cornerIndex];
2345 if (first->left <= x && x <= first->right &&
2346 second->left <= x && x <= second->right &&
2347 first->top <= y && y <= first->bottom &&
2348 second->top <= y && y <= second->bottom) {
2349 if (containedCount == 4)
2350 return 0;
2351 insideFlags[containedCount] = 1;
2352 containedCount++;
2353 } else {
2354 if (containedCount == 4)
2355 return 0;
2356 insideFlags[containedCount] = 0;
2357 containedCount++;
2358 }
2359 }
2360 if (containedCount != 4)
2361 return 0;
2362
2363 intersection->left = MinShort(
2364 (short)pointXs[insideFlags[0]],
2365 MinShort((short)pointXs[insideFlags[1]],
2366 (short)pointXs[insideFlags[2]]));
2367 intersection->top = MinShort(
2368 (short)pointYs[insideFlags[0]],
2369 MinShort((short)pointYs[insideFlags[1]],
2370 (short)pointYs[insideFlags[2]]));
2371 intersection->left = MaxShort(
2372 (short)pointXs[insideFlags[0]],
2373 MaxShort((short)pointXs[insideFlags[1]],
2374 (short)pointXs[insideFlags[2]]));
2375 intersection->top = MaxShort(
2376 (short)pointYs[insideFlags[0]],
2377 MaxShort((short)pointYs[insideFlags[1]],
2378 (short)pointYs[insideFlags[2]]));
2379 return 1;
2380}
2381
2382/* Function start: 0x465644 */
2383void SplitGameClockTicksForNav(unsigned char *parts)
2384{
2385 int ticks;
2386
2387 ticks = (int)GetGameClockTicks();
2388 parts[0] = (unsigned char)(ticks % 60);
2389 ticks = ticks / 60;
2390 parts[1] = (unsigned char)(ticks % 60);
2391 ticks = ticks / 60;
2392 parts[2] = (unsigned char)(ticks % 60);
2393 ticks = ticks / 60;
2394 parts[3] = (unsigned char)(ticks % 24);
2395 return;
2396}
2397
2398/* Function start: 0x4656CC */
2404
2405/* Function start: 0x4656EB */
2411
2412/* Function start: 0x46570E */
2413unsigned char *GetInputCursorShape(void)
2414{
2416}
2417
2418/* This unit's initialized data, after its functions so that it does not
2419 * move the functions' symbol keys. */
2420signed char g_bSceneEscapeRequested = 0; /* 0x0049d4b0 */
2421InputEvent *g_pInputEventHead = 0; /* 0x0049d4b4 */
2422InputEvent *g_pInputEventTail = 0; /* 0x0049d4b8 */
2423int g_nInputEventPoolInitialized = 0; /* 0x0049d4bc */
2424int g_nInputDoubleClickDeadline = 0; /* 0x0049d4c0 */
2425int g_nPreviousPrimaryButton = 0; /* 0x0049d4c4 */
2426int g_nPreviousSecondaryButton = 0; /* 0x0049d4c8 */
2427int g_nNextInputQueueFlushTick = 0; /* 0x0049d4cc */
2428unsigned char *g_pDrawnInputCursorShape = 0; /* 0x0049d4d0 */
2429int g_nMouseCursorDrawDepth = 1; /* 0x0049d4d4 */
2430short g_nScreenWidth = 320; /* 0x0049d4d8 */
2431short g_nScreenHeight = 200; /* 0x0049d4dc */
2432int g_nUnusedEventWord1 = 0; /* 0x0049d4e0 */
2433int g_nUnusedEventWord2 = 0; /* 0x0049d4e4 */
2435 { 0, 0, 0, 0, 0, 0, 0, 0 },
2436 { 0, 0, 0, 0, 0, 0, 0, 0 },
2437 { 0, 0, 0, 0, 0, 0, 0, 0 },
2438 { 0, 0, 0, 0, 0, 0, 0, 0 },
2439 { 320, 128, 0, 24, 0, 24, -24576, -1 },
2440 { 320, 200, 0, 0, 0, 0, -1536, -1 },
2441 { 0, 0, 0, 0, 0, 0, 0, 0 }
2442}; /* 0x0049d4e8 */
2445 0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2,
2446 14, 13, 12, 11, 10, 9, 8, 9, 10, 11, 12, 13,
2447 15, 16, 17, 18, 19, 20, 21, 20, 19, 18, 17, 16,
2448 28, 27, 26, 25, 24, 23, 22, 23, 24, 25, 26, 27,
2449 29, 30, 31, 32, 33, 34, 35, 34, 33, 32, 31, 30,
2450 36,
2451 0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2,
2452 14, 13, 12, 11, 10, 9, 8, 9, 10, 11, 12, 13,
2453 15, 16, 17, 18, 19, 20, 21, 20, 19, 18, 17, 16,
2454 14, 13, 12, 11, 10, 9, 8, 9, 10, 11, 12, 13,
2455 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 0,
2456 0, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2,
2457 4, 5, 6, 4, 6, 5, 4, 5, 6, 4, 6, 5,
2458 7, 8, 9, 7, 9, 8, 7, 8, 9, 7, 9, 8,
2459 10, 11, 12, 10, 12, 11, 10, 11, 12, 10, 12, 11,
2460 13, 14, 15, 13, 15, 14, 13, 14, 15, 13, 15, 14, 16
2461}; /* 0x0049d558 */
2464 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2465 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2466 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2467 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2468 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2469 0,
2470 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2471 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2472 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2473 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
2474 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2,
2475 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2476 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2477 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2478 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2479 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0
2480}; /* 0x0049d618 */
2481int g_nNextInputPollTick = 0; /* 0x0049d6d4 */
2482short g_nInputPollPeriod = 0; /* 0x0049d6d8 */
2483
2484/* The public input state occupies the retail commons block at
2485 * 0x005C80A8-0x005C8D3D, immediately after main.c's event pool.
2486 * Unused byte arrays represent gaps that alignment cannot account for.
2487 * Retail /DEBUG linking retains unused commons; their original names,
2488 * types and individual declaration boundaries are unknown. */
2489int g_15_nMouseRenderY; /* 0x005c80a8 */
2490int g_4_nDrawnCursorX; /* 0x005c80ac */
2491unsigned char g_9_abUnusedInputData[16]; /* 0x005c80b0 */
2492unsigned char *g_39_pCurrentCampaignDataOffset; /* 0x005c80c0 */
2494unsigned char g_4_abUnreferencedEventStorage[2]; /* 0x005c80c8 */
2496unsigned char g_18_abUnreferencedInputBuffer[4]; /* 0x005c80cc */
2497unsigned char g_5_abUnusedInputSpace1[2]; /* 0x005c80d0 */
2499short g_6_wQueuedButtonsState; /* 0x005c80d4 */
2500unsigned char g_88_nEventRepeatDelayState; /* 0x005c80d6 */
2501short g_15_nStoredScreenViewCentreX; /* 0x005c80d8 */
2502short g_37_nViewCenterY; /* 0x005c80da */
2503unsigned char g_3_abUnusedLibraryBytes[4]; /* 0x005c80dc */
2505short g_19_bStoredHighMemoryEnabled; /* 0x005c80e4 */
2506unsigned char g_26_bMouseCursorEnabled; /* 0x005c80e6 */
2507unsigned char g_77_abKeyboardEventStates[0x80]; /* 0x005c80f0 */
2508unsigned char g_17_abUnusedLibraryInputBuffer[8]; /* 0x005c8170 */
2509int g_10_nSavedPointerY; /* 0x005c8178 */
2510int g_4_nCapturedInputCursorX; /* 0x005c817c */
2512unsigned char g_58_abUnreferencedInputStorage1[8]; /* 0x005c8298 */
2513unsigned char g_13_abUnusedLibrarySpaceData[4]; /* 0x005c82a0 */
2514short g_96_nHighMemoryInitValue; /* 0x005c82a4 */
2515signed char g_1_cStoredViewDisplayModeValue; /* 0x005c82a6 */
2516signed char g_9_bCinematicSpriteTextEnableStatus; /* 0x005c82a7 */
2517unsigned char g_97_abUnusedInputSystemBuffer[8]; /* 0x005c82a8 */
2518const ScreenViewportGeometry * volatile
2521unsigned char g_5_abUnreferencedInputStorage2[4]; /* 0x005c83d8 */
2522unsigned char *g_13_pActiveCutscenePixelsAddress; /* 0x005c83dc */
2523unsigned char g_56_abUnusedEventBuffer[6]; /* 0x005c83e0 */
2524signed char g_cKeypadMouseSpeedValue; /* 0x005c83e6 */
2527unsigned char g_39_abUnusedInputSpace2[12]; /* 0x005c8410 */
2528short g_105_nEmsIsrBusyValue; /* 0x005c841c */
2529unsigned char g_68_abUnusedInputSpace3[16]; /* 0x005c8420 */
2530signed char g_6_bCampaignFlightRunning; /* 0x005c8430 */
2531short g_12_wInputDeviceButtonStatus; /* 0x005c8432 */
2532unsigned char g_38_abUnusedLibraryInputBufferData[4]; /* 0x005c8434 */
2533unsigned char g_8_abUnusedInputSystemBytes[4]; /* 0x005c8438 */
2535unsigned char g_10_abUnusedEventSpace[8]; /* 0x005c8440 */
2536short g_86_nCurrentInputTickInterval; /* 0x005c8448 */
2537volatile int g_5_nFrameTimerWaitTicksValue; /* 0x005c844c */
2538int g_26_bPointerDirtyValue; /* 0x005c8450 */
2539unsigned char g_1_abUnreferencedInputData[4]; /* 0x005c8454 */
2541int g_138_nCursorDirtyRightValue; /* 0x005c845c */
2542int g_15_nPointerDirtyBottom; /* 0x005c8460 */
2545unsigned char g_26_abUnusedInputStorage1[4]; /* 0x005c8494 */
2546unsigned char g_26_abUnusedInputStorage2[4]; /* 0x005c8498 */
2547short g_49_nViewportOffsetY; /* 0x005c849c */
2548short g_11_nViewportLeftOrigin; /* 0x005c849e */
2549unsigned char g_4_abUnusedEventStorage[8]; /* 0x005c84a0 */
2550volatile int g_196_nInputTimerTicks; /* 0x005c84a8 */
2551unsigned char g_37_abUnusedEventManagerBuffer[272]; /* 0x005c84b0 */
2552int g_148_nPointerDirtyLeft; /* 0x005c85c0 */
2553int g_146_nInputCursorDirtyTop; /* 0x005c85c4 */
2554unsigned char g_128_abPauseInputState[0x100]; /* 0x005c85d0 */
2555unsigned char g_12_abUnusedLibraryInputData[16]; /* 0x005c86d0 */
2556unsigned char g_13_abPreviousPauseKeyStatuses[0x100]; /* 0x005c86e0 */
2557int g_3_anCurrentInputEventEntryAllocation[0x100]; /* 0x005c87e0 */
2559unsigned char g_9_abUnusedLibrarySpace[260]; /* 0x005c8bf0 */
2560void (*g_3_pfnRenderSceneTextStringHandler)(char *text); /* 0x005c8cf4 */
2562unsigned char g_136_abUnusedInputMemoryData[12]; /* 0x005c8d10 */
2564unsigned char g_388_abUnusedLibraryBuffer1[4]; /* 0x005c8d20 */
2565int g_3_nEventClockScaleValue; /* 0x005c8d24 */
2566unsigned char g_86_abUnreferencedEventData[8]; /* 0x005c8d28 */
2567void (*g_36_pfnRenderSceneFontCharacterHandler)(char character); /* 0x005c8d30 */
2568unsigned char g_59_abUnusedLibraryBuffer2[4]; /* 0x005c8d34 */
2569unsigned char g_138_abUnusedLibraryData[4]; /* 0x005c8d38 */
2570short g_18_nInterfaceEventMode; /* 0x005c8d3c */
void(__cdecl *g_pIxFree)(void *)
void InputDeviceShutdownHook(void)
Definition eventmgr.c:2151
void ResetPointerViewportsHook(void)
Definition eventmgr.c:1037
unsigned char g_3_abUnusedLibraryBytes[4]
Definition eventmgr.c:2503
void UnhookInterruptVectorHook(short vector)
Definition eventmgr.c:537
void StopMusicTimerHook(void)
Definition eventmgr.c:2222
unsigned char g_388_abUnusedLibraryBuffer1[4]
Definition eventmgr.c:2564
unsigned char g_86_abUnreferencedEventData[8]
Definition eventmgr.c:2566
unsigned char g_68_abUnusedInputSpace3[16]
Definition eventmgr.c:2529
unsigned int GetEmsTotalFree(void)
Definition eventmgr.c:1543
int g_nUnusedEventWord1
Definition eventmgr.c:2432
short HookInterruptVector(short vector)
Definition eventmgr.c:530
void * AllocateEmsBlock(unsigned int size)
Definition eventmgr.c:1536
void DumpVideoPageMapHook(void)
Definition eventmgr.c:1890
unsigned char g_56_abUnusedEventBuffer[6]
Definition eventmgr.c:2523
unsigned char g_18_abUnreferencedInputBuffer[4]
Definition eventmgr.c:2496
short HasKeyIntercept(void)
Definition eventmgr.c:1935
void SpeedCalibrationHook(void)
Definition eventmgr.c:1971
void RecordStartTimeHook(void)
Definition eventmgr.c:506
unsigned char g_136_abUnusedInputMemoryData[12]
Definition eventmgr.c:2562
unsigned char g_138_abUnusedLibraryData[4]
Definition eventmgr.c:2569
unsigned char g_26_abUnusedInputStorage2[4]
Definition eventmgr.c:2546
unsigned char g_9_abUnusedInputData[16]
Definition eventmgr.c:2491
void RebootMachineHook(void)
Definition eventmgr.c:1615
short DetectTandyKeyboard(void)
Definition eventmgr.c:2016
void CalibrateDelayHook(void)
Definition eventmgr.c:1921
short CheckEmsPointer(void *pointer)
Definition eventmgr.c:1550
unsigned char g_17_abUnusedLibraryInputBuffer[8]
Definition eventmgr.c:2508
void KeyboardNullHook(void)
Definition eventmgr.c:1622
unsigned char g_128_abPauseInputState[0x100]
Definition eventmgr.c:2554
unsigned char g_5_abUnreferencedInputStorage2[4]
Definition eventmgr.c:2521
int SetupBackBufferHook(void)
Definition eventmgr.c:1876
void SetPointerViewportHook(void)
Definition eventmgr.c:1044
int InitializeEms(void)
Definition eventmgr.c:1522
void DumpFarHeapHook(void)
Definition eventmgr.c:1449
unsigned char g_5_abUnusedInputSpace1[2]
Definition eventmgr.c:2497
void GetMouseHomePosition(ShortPoint *position)
Definition eventmgr.c:1397
void RemovePointerViewportHook(void)
Definition eventmgr.c:1051
void MusicTimerIsrHook(void)
Definition eventmgr.c:2229
unsigned char g_13_abPreviousPauseKeyStatuses[0x100]
Definition eventmgr.c:2556
void * AllocateNearMemory(short size)
Definition eventmgr.c:1949
void FreeDefaultMemory(void *block)
Definition eventmgr.c:1479
short InitializeMousePointer(void)
Definition eventmgr.c:1030
unsigned char g_4_abUnusedEventStorage[8]
Definition eventmgr.c:2549
unsigned char g_8_abUnusedInputSystemBytes[4]
Definition eventmgr.c:2533
unsigned char g_26_abUnusedInputStorage1[4]
Definition eventmgr.c:2545
unsigned char g_1_abUnreferencedInputData[4]
Definition eventmgr.c:2539
unsigned char g_4_abUnreferencedEventStorage[2]
Definition eventmgr.c:2494
unsigned char g_9_abUnusedLibrarySpace[260]
Definition eventmgr.c:2559
int IsEmsPointer(void *pointer)
Definition eventmgr.c:1564
unsigned char g_59_abUnusedLibraryBuffer2[4]
Definition eventmgr.c:2568
unsigned char g_39_abUnusedInputSpace2[12]
Definition eventmgr.c:2527
unsigned char g_97_abUnusedInputSystemBuffer[8]
Definition eventmgr.c:2517
unsigned char g_12_abUnusedLibraryInputData[16]
Definition eventmgr.c:2555
void FreeEmsBlockHook(void *block)
Definition eventmgr.c:1557
void FormatEmsHeapHook(void)
Definition eventmgr.c:1529
void FreeVideoPagesHook(void)
Definition eventmgr.c:1883
int g_nUnusedEventWord2
Definition eventmgr.c:2433
unsigned char g_10_abUnusedEventSpace[8]
Definition eventmgr.c:2535
unsigned char g_13_abUnusedLibrarySpaceData[4]
Definition eventmgr.c:2513
unsigned char g_37_abUnusedEventManagerBuffer[272]
Definition eventmgr.c:2551
unsigned char g_58_abUnreferencedInputStorage1[8]
Definition eventmgr.c:2512
unsigned char g_38_abUnusedLibraryInputBufferData[4]
Definition eventmgr.c:2532
void FlushBiosKeys(void)
Definition eventmgr.c:1586
void UnhookAllInterruptVectorsHook(void)
Definition eventmgr.c:544
void set_up_screen_viewport(signed char mode)
Definition eventmgr.c:1820
short ReadWord(unsigned short *p)
Definition eventmgr.c:210
void RefreshMouseCursorDisplay(void)
Definition eventmgr.c:1165
void SetMouseHomePosition(short x, short y)
Definition eventmgr.c:1377
short IsVectorWithinRange(FixedVector *vector, short range)
Definition eventmgr.c:2023
int ConfigureInputPump(int slot, void(*pump)(void))
Definition eventmgr.c:2112
unsigned int GetLargestFreeMemoryBlock(void)
Definition eventmgr.c:1515
void SetInputViewport(Viewport *viewport)
Definition eventmgr.c:2093
unsigned int DosFarPtrToNear(void *v)
Definition eventmgr.c:441
void AllocateApplicationScratchBuffer(void)
Definition eventmgr.c:2399
short MaxShort(short a, short b)
Definition disk.c:36
long MultiplyFixed(int left, int right)
Definition eventmgr.c:51
void TimerResetHook(void)
Definition eventmgr.c:1485
char PumpMessagesDuringWait(void)
Definition console.cpp:46
void BuildObjectDepthOrder(void)
Definition eventmgr.c:1643
short LoadInputCursorShape(const char *filename, short section, short flags)
Definition eventmgr.c:2120
void * PacketLoad(const char *filename, short section, void *destination, short flags, void *decompressionWorkspace, int registerHandle)
Definition pload.c:16
unsigned int IdentityWord(unsigned int v)
Definition eventmgr.c:1497
void * AllocateDefaultMemory(unsigned int size)
Definition eventmgr.c:1465
void SplitGameClockTicksForNav(unsigned char *parts)
Definition eventmgr.c:2383
void VideoReleaseHook(void)
Definition eventmgr.c:2003
void ApplyPackedMousePosition(ShortPoint point)
Definition eventmgr.c:1386
short InitializePostPaletteState(void)
Definition eventmgr.c:499
short ServiceInputDevices(short deviceMask)
Definition eventmgr.c:2071
void StartupHook(unsigned int(*callback)(unsigned int, short))
Definition eventmgr.c:1927
void DrawSolidColourSpriteScaled(Viewport *viewport, short x, short y, unsigned char *shape, short frame, short angle, short scale, short flip, unsigned short colour)
Definition gr.c:1505
void ReleaseApplicationScratchBuffer(void)
Definition eventmgr.c:2406
long Vector_magnitude(const FixedVector *vector)
Definition eventmgr.c:157
void DosMemmove(void *dst, const void *src, unsigned short n)
void intro_drawbackgroundships(void)
Definition eventmgr.c:1768
void SetMusicTickRateHook(short period)
Definition eventmgr.c:2214
void RestoreMouseCursorBackground(void)
Definition eventmgr.c:1131
void PersonnelDriveHook(short drive)
Definition eventmgr.c:1978
void ApplySpacePaletteModeHook(void)
Definition eventmgr.c:222
short DosStrlen(const char *s)
Definition eventmgr.c:479
InputEventState * FindQueuedInputEvent(int type)
Definition eventmgr.c:969
void ClearInputKeyStatePreservingModifiers(void)
Definition eventmgr.c:1593
void SetTextContext(TextContext *context)
Definition eventmgr.c:179
long GetNamedPacketSize(const char *filename, short section)
Definition eventmgr.c:2164
void ResumeMouseCursorHook(void)
Definition eventmgr.c:1186
short GetViewportIntersection(ShortRect *intersection, const ShortRect *first, const ShortRect *second)
Definition eventmgr.c:2277
short ArcCos(int value)
Definition eventmgr.c:116
void DrawSolidColourSprite(Viewport *viewport, short x, short y, unsigned char *shape, short frame, unsigned short colour)
Definition gr.c:981
void DrawSpriteDefault(Viewport *viewport, short x, short y, unsigned char *shape, short frame)
Definition gr.c:682
void * LoadNamedPacket(const char *filename, short section, void *destination, unsigned short flags, void *decompressionWorkspace, int registerHandle)
Definition eventmgr.c:2170
int PollInputEvent(InputEventState *event, short)
Definition eventmgr.c:922
void FlushInputEvents(void)
Definition eventmgr.c:1014
void SetInputKeyState(int scanCode, unsigned char pressed)
Definition eventmgr.c:1629
void SetMultimediaTimerCallback(int period)
Definition timer.c:21
long SinFixed(short degrees)
Definition eventmgr.c:80
short MinShort(short a, short b)
Definition disk.c:27
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
short GetOriginalFreeMemory(void)
Definition eventmgr.c:1914
void DrawMouseCursor(void)
Definition eventmgr.c:1099
unsigned int PumpWindowMessages(int skipMessages)
Definition winmain.c:292
void SetFrameTimerPeriodDirect(short p)
Definition eventmgr.c:1418
void DIBsetPalette(short index, short *rgb)
Definition dib.cpp:854
void SetWholePaletteFromTriplets(unsigned char *palette)
Definition eventmgr.c:204
void * DosNearPtrToFar(unsigned int v)
Definition eventmgr.c:447
void ClearInputKeyState(void)
Definition eventmgr.c:1606
void CaptureMouseCursorBackground(void)
Definition eventmgr.c:1063
void * AllocateZeroedRecords(int count, short elementSize, short flags)
Definition eventmgr.c:1437
short GetShapeFrameBounds(short *bounds, short x, short y, unsigned char *shape, short frame)
Definition eventmgr.c:228
long PlanarMagnitude(int x, int y)
Definition eventmgr.c:144
InputEvent * AllocateInputEvent(void)
Definition eventmgr.c:616
void * AllocateTaggedMemory(unsigned int size, short flags)
Definition memapi.c:92
unsigned int GetPacketSize(const char *filename, short section)
Definition pktsize.c:9
void DrawTextString(const char *text)
Definition eventmgr.c:262
unsigned char * GetInputCursorShape(void)
Definition eventmgr.c:2413
void CheckCursor(void)
Definition eventmgr.c:1057
void WaitForVerticalBlankThunk(void)
Definition eventmgr.c:189
void SetPaletteEntryFromTriplet(const unsigned char *triplet, short index)
Definition eventmgr.c:2202
void ClearDebugPauseFlags(void)
Definition console.cpp:82
void CaptureSpriteBackground(Viewport *viewport, unsigned char *background, short x, short y, unsigned char *shape, short frame)
Definition gr.c:705
void SeedRandomFromClock(void)
Definition eventmgr.c:18
long CosFixed(short degrees)
Definition eventmgr.c:91
void TranslatePolledInputEvent(unsigned short type, unsigned int value)
Definition eventmgr.c:550
void MouseIdleHook(void)
Definition eventmgr.c:1902
void ExitCleanupHook(void)
Definition eventmgr.c:2009
short InitializeInputManagerMemory(short eventQueueSize)
Definition eventmgr.c:512
void draw_sorted_objects_to_buffer(void)
Definition eventmgr.c:1700
unsigned short SelectDiskDriveHook(short drive)
Definition eventmgr.c:1984
unsigned short GetRandomWord(void)
Definition eventmgr.c:25
void RetainInputEventsOfType(int type)
Definition eventmgr.c:751
void RestoreSpriteBackground(Viewport *viewport, unsigned char *background, short x, short y, unsigned char *shape, short frame)
Definition gr.c:846
long DivideFixed(int numerator, int denominator)
Definition eventmgr.c:64
void FinalizeInputManagerHook(void)
Definition eventmgr.c:1896
void DosMemset(void *destination, unsigned int count, short value)
Definition eventmgr.c:492
char * DosStrcpy(char *dst, const char *src)
Definition eventmgr.c:465
void DisableMouseCursorDrawing(void)
Definition eventmgr.c:1327
int GetControlKeyState(void)
Definition winmain.c:1136
short RandomBelow(short n)
Definition eventmgr.c:12
void SetFrameTimerPeriod(short period)
Definition eventmgr.c:1405
long Magnitude(int value)
Definition eventmgr.c:130
void ReleaseInputEvent(InputEvent *event)
Definition eventmgr.c:641
void WaitForFrameTick(void)
Definition eventmgr.c:1424
void DIBwholePaletteFromTriplets(unsigned char *palette)
Definition dib.cpp:908
void PollMenuInputDevices(void)
Definition input.c:115
int MeasureShapeFrameStorage(unsigned char *shape, short frame)
Definition eventmgr.c:384
void EnableMouseCursorDrawing(void)
Definition eventmgr.c:1254
void AppendTextCharacter(char character)
Definition eventmgr.c:375
char * CopyStringAndReturnEnd(char *destination, const char *source)
Definition eventmgr.c:471
void ServiceCutsceneRuntimeHook(void)
Definition eventmgr.c:2192
int GetSoundHardwareFlag(void)
Definition eventmgr.c:1471
unsigned short GetShutdownErrorCode(unsigned char *driveState)
Definition eventmgr.c:1996
void * IdentityHandle(void *v)
Definition eventmgr.c:196
short EmsRestoreMapping(void)
Definition eventmgr.c:1578
short InitializeMouseCursorDepth()
Definition eventmgr.c:1022
short OffsetSceneHotspotBounds(ShortRect *bounds, const SceneHotspot *hotspot, short offsetX, short offsetY)
Definition eventmgr.c:2180
void ClearInputPump(void)
Definition eventmgr.c:2100
char * DosStrchr(const char *s, short c)
Definition eventmgr.c:459
unsigned int shrink_vector(FixedVector *vector)
Definition eventmgr.c:2036
unsigned int GetGameClockTicks(void)
Definition winmain.c:1148
void SetMenuInputPump(void)
Definition eventmgr.c:2106
unsigned int GetStartupErrorCode(int vector)
Definition eventmgr.c:1963
unsigned int JoystickEdgeHook(int button)
Definition eventmgr.c:1941
void ReleasePacketHandle(void *handle)
Definition memapi.c:108
char * DosStrrchr(char *s, short c)
Definition eventmgr.c:453
void SetInputCursorHostPosition(int x, int y)
Definition winmain.c:1177
void TimerStopHook(void)
Definition eventmgr.c:1503
void DrawFontGlyph(char character, TextContext *context, int height, int width, int y)
Definition gr.c:540
unsigned int shrink(int *component)
Definition eventmgr.c:2050
void DrawSpriteScaled(Viewport *viewport, short x, short y, unsigned char *shape, short frame, short angle, short scale, short flip)
Definition gr.c:1494
short IsFrameTickElapsed(void)
Definition eventmgr.c:1430
short GetCurrentDiskDriveHook(void)
Definition eventmgr.c:1990
void DIBupdate(int left, int top, int right, int bottom)
Definition dib.cpp:708
void SetTextCursor(unsigned short a, unsigned short b)
Definition eventmgr.c:172
int GetShiftKeyState(void)
Definition winmain.c:1124
short PeekInputEvent(InputEventState *event, short type)
Definition eventmgr.c:929
unsigned short EnableHighMemoryResources(void)
Definition eventmgr.c:1456
void DIBwaitForVerticalBlank(void)
Definition dib.cpp:988
short EmsSaveMapping(void)
Definition eventmgr.c:1571
void SplitPackedPoint(ShortPoint point, short *p)
Definition eventmgr.c:255
unsigned short RandomInRange(unsigned short lo, unsigned short hi)
Definition eventmgr.c:31
unsigned int GetKeyboardModifiers(void)
Definition winmain.c:1130
void InitializeInputDriverHook(void)
Definition eventmgr.c:2138
void QueueInputEventAtCursor(unsigned int type, short primaryButton, short secondaryButton)
Definition eventmgr.c:604
unsigned int GetAvailableFarMemory(void)
Definition eventmgr.c:1509
void FreeIfNotNull(void *p)
Definition eventmgr.c:1955
short ArcSin(int value)
Definition eventmgr.c:102
void FinalizeInputDriverHook(void)
Definition eventmgr.c:2144
void SetFrameTimerAndWait(short period)
Definition eventmgr.c:1411
short IsSpriteFrameOverlappingRect(const ShortRect *rectangle, short x, short y, unsigned char *shape, short frame)
Definition eventmgr.c:2235
short RandomBelowOrEqual(short n)
Definition eventmgr.c:43
DwordPtr IdentityDword(DwordPtr value)
Definition eventmgr.c:1491
void RemoveInputEvent(InputEvent *event)
Definition eventmgr.c:776
int GetNextInputEvent(InputEventState *event)
Definition eventmgr.c:800
void FlushPendingInputEvents(void)
Definition eventmgr.c:2157
short GetFontCharWidth(char i)
Definition eventmgr.c:216
short GetNavRangeSentinel(void)
Definition eventmgr.c:1908
void SystemDebugPrintf(const char *format,...)
Definition console.cpp:30
void DrawTextCharacter(char character)
Definition eventmgr.c:348
short IsPointInRect(short x, short y, const short *rect)
Definition eventmgr.c:246
void ShutdownEventManager(void)
Definition eventmgr.c:521
void SetMouseCursorShape(unsigned char *shape, short frame)
Definition eventmgr.c:1357
void ReleaseInputEventQueue(void)
Definition eventmgr.c:734
Shared Win32 declarations, types and library interfaces.
unsigned int DwordPtr
Definition game.h:45
#define DEG2RAD
Definition game.h:107
#define DIRECTION_SHAPE_TABLE_COUNT
Definition game_data.h:1583
#define DIRECTION_VIEW_COUNT
Definition game_data.h:1582
#define SPACE_OBJECT_COUNT
Definition game_data.h:1578
@ OBJECT_CLASS_PLANET
Definition game_data.h:40
@ OBJECT_CLASS_DUST
Definition game_data.h:41
@ OBJECT_CLASS_STAR
Definition game_data.h:39
@ OBJECT_CLASS_NULL
Definition game_data.h:37
short g_asObjectScreenAngle[SPACE_OBJECT_COUNT]
Definition viewrect.c:97
int g_4_nDrawnCursorX
Definition eventmgr.c:2490
HostMouseMessage g_6_stHostMouseTextBlock
Definition winmain.c:1384
int g_nNextInputPollTick
Definition eventmgr.c:2481
short g_11_nViewportLeftOrigin
Definition eventmgr.c:2548
unsigned char * g_apObjectShape[SPACE_OBJECT_COUNT]
Definition viewrect.c:100
short g_asObjectDrawX[SPACE_OBJECT_COUNT]
Definition viewrect.c:98
short g_asObjectDistance[SPACE_OBJECT_COUNT]
Definition viewrect.c:104
unsigned char * g_pCockpitBackgroundPacket
Definition personnel.c:8
int g_nCockpitDisplayMode
Definition main.c:1929
int g_3_anCurrentInputEventEntryAllocation[0x100]
Definition eventmgr.c:2557
QueuedMouseState g_16_stEventQueuePointerData
Definition eventmgr.c:2525
short g_96_nHighMemoryInitValue
Definition eventmgr.c:2514
void(*) g_59_pfnEventShutdownCallback(void)
Definition eventmgr.c:2558
short g_86_nCurrentInputTickInterval
Definition eventmgr.c:2536
signed char g_bSceneEscapeRequested
Definition eventmgr.c:2420
const ScreenViewportGeometry *volatile g_15_pScreenViewportGeometry
Definition eventmgr.c:2519
signed char g_9_bCinematicSpriteTextEnableStatus
Definition eventmgr.c:2516
unsigned char * g_pConstellationSprite
Definition message.c:230
unsigned char * g_pDrawnInputCursorShape
Definition eventmgr.c:2428
int g_148_nPointerDirtyLeft
Definition eventmgr.c:2552
int g_6_bCurrentInputCursorBackgroundCapturedState
Definition eventmgr.c:2493
short g_aeObjectClass[SPACE_OBJECT_COUNT]
Definition viewrect.c:125
short g_nInputPollPeriod
Definition eventmgr.c:2482
short g_asObjectType[SPACE_OBJECT_COUNT]
Definition viewrect.c:124
short g_9_nStoredHighMemoryResourceSetupWord
Definition eventmgr.c:2540
InputManagerState * g_18_pEventManager
Definition eventmgr.c:2543
short g_asObjectFlip[SPACE_OBJECT_COUNT]
Definition viewrect.c:102
short g_asObjectScreenX[SPACE_OBJECT_COUNT]
Definition viewrect.c:95
int g_26_bPointerDirtyValue
Definition eventmgr.c:2538
MouseCursorState g_37_stPersonnelMousePointerState
Definition eventmgr.c:2544
short g_105_nEmsIsrBusyValue
Definition eventmgr.c:2528
TextContext * g_29_pCurrentTextContext
Definition eventmgr.c:2563
unsigned char g_77_abKeyboardEventStates[0x80]
Definition eventmgr.c:2507
int g_2_bIgnoreNextCursorMoveFlag
Definition eventmgr.c:2534
short g_asObjectDrawY[SPACE_OBJECT_COUNT]
Definition viewrect.c:99
short g_12_wInputDeviceButtonStatus
Definition eventmgr.c:2531
unsigned char * g_13_pActiveCutscenePixelsAddress
Definition eventmgr.c:2522
int g_15_nPointerDirtyBottom
Definition eventmgr.c:2542
short g_6_wQueuedButtonsState
Definition eventmgr.c:2499
int g_nPreviousPrimaryButton
Definition eventmgr.c:2425
signed char g_cKeypadMouseSpeedValue
Definition eventmgr.c:2524
unsigned char g_26_bMouseCursorEnabled
Definition eventmgr.c:2506
short g_asObjectScreenScale[SPACE_OBJECT_COUNT]
Definition viewrect.c:103
signed char g_acDirectionShapeFlip[DIRECTION_VIEW_COUNT *DIRECTION_SHAPE_TABLE_COUNT]
Definition eventmgr.c:2463
InputEvent * g_pInputEventHead
Definition eventmgr.c:2421
int g_nMouseCursorDrawDepth
Definition eventmgr.c:2429
short g_37_nViewCenterY
Definition eventmgr.c:2502
void(*) g_3_pfnRenderSceneTextStringHandler(char *text)
Definition eventmgr.c:2560
unsigned char g_88_nEventRepeatDelayState
Definition eventmgr.c:2500
short g_nScreenHeight
Definition eventmgr.c:2431
short g_18_bEventManagerInitializationState
Definition eventmgr.c:2495
void(*) g_36_pfnRenderSceneFontCharacterHandler(char character)
Definition eventmgr.c:2567
Viewport g_27_stViewScratchInfo
Definition cockpt.c:3841
EVENTMGR_STATIC InputEventState g_1_stFoundInputEvent
Definition globals.h:1109
short g_nNavPointerObject
Definition viewrect.c:52
int g_nPreviousSecondaryButton
Definition eventmgr.c:2426
short g_14_nCurrentGraphicsModeDetectedValue
Definition eventmgr.c:2498
volatile int g_196_nInputTimerTicks
Definition eventmgr.c:2550
EVENTMGR_STATIC unsigned char g_abInputCursorBehind[0x1000]
Definition globals.h:1097
unsigned char g_cPrimaryViewBufferColour
Definition startup.c:559
int g_3_nEventClockScaleValue
Definition eventmgr.c:2565
int g_56_anStoredObjectSortedIndicesData[SPACE_OBJECT_COUNT]
Definition eventmgr.c:2520
int g_146_nInputCursorDirtyTop
Definition eventmgr.c:2553
int g_nInputDoubleClickDeadline
Definition eventmgr.c:2424
short g_19_bStoredHighMemoryEnabled
Definition eventmgr.c:2505
InputDeviceSample g_aInputDeviceSamplesList[2]
Definition joystick.c:75
ScreenViewportGeometry g_aScreenViewportGeometry[7]
Definition eventmgr.c:2434
signed char g_6_bCampaignFlightRunning
Definition eventmgr.c:2530
Viewport g_101_stScrViewInfo
Definition cockpt.c:3831
int g_10_nSavedPointerY
Definition eventmgr.c:2509
void(*) g_176_pfnCurrentInputPump(void)
Definition eventmgr.c:2526
signed char g_1_cStoredViewDisplayModeValue
Definition eventmgr.c:2515
InputEvent g_3_aInputEventArray[0x100]
Definition main.c:2012
int g_11_anPlacedObjectDepths[SPACE_OBJECT_COUNT]
Definition eventmgr.c:2511
short g_8_nActiveInputDeviceWord
Definition joystick.c:57
volatile int g_5_nFrameTimerWaitTicksValue
Definition eventmgr.c:2537
signed char g_acDirectionShapeFrame[DIRECTION_VIEW_COUNT *DIRECTION_SHAPE_TABLE_COUNT]
Definition eventmgr.c:2444
InputEvent * g_pInputEventTail
Definition eventmgr.c:2422
unsigned char * g_39_pCurrentCampaignDataOffset
Definition eventmgr.c:2492
short g_15_nStoredScreenViewCentreX
Definition eventmgr.c:2501
int g_138_nCursorDirtyRightValue
Definition eventmgr.c:2541
short g_nScreenWidth
Definition eventmgr.c:2430
int g_nInputEventPoolInitialized
Definition eventmgr.c:2423
short g_18_nInterfaceEventMode
Definition eventmgr.c:2570
void * g_26_pLibraryCurrentLastPacketAllocation
Definition eventmgr.c:2504
PersonnelMouseSample g_6_stPersonnelMouseData
Definition eventmgr.c:2561
int g_4_nCapturedInputCursorX
Definition eventmgr.c:2510
int g_nNextInputQueueFlushTick
Definition eventmgr.c:2427
short g_49_nViewportOffsetY
Definition eventmgr.c:2547
short g_asObjectScreenY[SPACE_OBJECT_COUNT]
Definition viewrect.c:96
int g_15_nMouseRenderY
Definition eventmgr.c:2489
short g_asObjectViewFrame[SPACE_OBJECT_COUNT]
Definition viewrect.c:94
int primaryButton
Definition game.h:182
int secondaryButton
Definition game.h:183
short status
Definition game.h:213
unsigned short modifiers
Definition game.h:215
short value
Definition game.h:212
unsigned int timestamp
Definition game.h:214
unsigned int modifiers
Definition game.h:197
short value
Definition game.h:196
short x
Definition game.h:194
struct InputEvent * next
Definition game.h:204
struct InputEvent * previous
Definition game.h:205
unsigned int status
Definition game.h:203
short secondaryButton
Definition game.h:200
unsigned int field_18
Definition game.h:202
short type
Definition game.h:193
unsigned int field_14
Definition game.h:201
short y
Definition game.h:195
short primaryButton
Definition game.h:199
void * scratchBuffer
Definition game.h:174
unsigned char primaryButton
Definition globals.h:1010
Viewport * viewport
Definition globals.h:1017
unsigned char * shape
Definition globals.h:1014
unsigned char secondaryButton
Definition globals.h:1011
unsigned char shapeChanged
Definition globals.h:1019
short top
Definition game_data.h:480
short left
Definition game_data.h:479
short right
Definition game_data.h:481
short bottom
Definition game_data.h:482
short cursorY
Definition game.h:286
unsigned char * font
Definition game.h:287
char * text
Definition game.h:290
signed char alignment
Definition game.h:292
char * textCursor
Definition game.h:291
short cursorX
Definition game.h:285
Viewport * viewport
Definition game.h:284
short right
Definition game.h:154
short bottom
Definition game.h:155
short left
Definition game.h:152
short top
Definition game.h:153