Wing Commander
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
geom.c
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup data
4 * @brief Vector, angle and fixed-point geometry, and ship speed and fuel
5 * limits.
6 *
7 * Address range 418080-41a9cf. Text, packet, music and palette helpers open
8 * the range and get_right_shape closes it; the modal-panel block at 41a9d0
9 * belongs with the barracks data and save/load routines.
10 */
11#include "wc1.h"
12
13/* Linker commons defined here; LINK orders them by identifier hash. */
14signed char cCapitalShipLogicalFile; /* 0x005a7da0 */
16
17/* Function start: 0x418080 */
18short __stdcall MeasureTextPixelWidthClamped(const char *text)
19{
20 short width = 0;
21
22 while (*text != 0) {
23 width = (short)(width + GetFontCharWidth(*text++));
24 if (width >= 320)
25 break;
26 }
27 if (*text-- != 0) {
28 width = (short)(width - GetFontCharWidth(*text));
29 }
30 return width;
31}
32
33/* Function start: 0x4180C0 */
34int __stdcall SeekPacketSection(PacketSectionHandle *handle, int offset,
35 short origin)
36{
37 int position;
38 int sectionEnd;
39 int result;
40
41 result = (int)handle->dataOffset;
42 sectionEnd = (int)((unsigned int)result + handle->dataSize);
43 switch (origin) {
44 case 0:
45 position = result;
46 break;
47 case 1:
48 position = (int)((unsigned int)result + handle->position);
49 break;
50 case 2:
51 position = sectionEnd;
52 break;
53 }
54 position += offset;
55 if (result > position)
56 position = result;
57 if (sectionEnd < position && handle->finalSection == 0)
58 position = sectionEnd;
59 result = SeekDataFile((unsigned short)handle->file, position, 0);
60 if (result != -1)
61 handle->position = (unsigned int)(result - handle->dataOffset);
62}
63
64/* Function start: 0x418130 */
65unsigned short GetMusicDriverPresent(short mode)
66{
67 return 1;
68}
69
70/* Function start: 0x418140 */
71short __stdcall CollectActivePaletteIndices(Viewport *viewport,
72 unsigned char *indices,
73 short capacity)
74{
75 unsigned char *active;
76 short count;
77 short index;
78
79 count = 0;
80 active = AllocateTaggedMemory((unsigned int)capacity, 0);
81 if (active == 0)
82 return 0;
83
84 memset(active, 0, (unsigned int)capacity);
85 MarkActivePaletteEntries(viewport, active);
86 for (index = 0; index < capacity; index++) {
87 if (active[index] != 0)
88 indices[count++] = (unsigned char)index;
89 }
90 ReleasePacketHandle(active);
91 return count;
92}
93
94/* Function start: 0x4181C0 */
95short get_ship_max_velocity(short obj)
96{
97 short velocity = aObjectTypeData[
99
100 if (obj < 10 && acShipRating[obj] > 8)
101 return velocity + velocity / 3;
102 return velocity;
103}
104
105/* Function start: 0x418210 */
106short recalc_max_velocity(short ship)
107{
108 short oldVelocity;
109
110 oldVelocity = asShipMaximumSpeedArray[ship];
111 if (anShipFuelsTable[ship] <= 0) {
112 asShipMaximumSpeedArray[ship] = 5;
113 } else {
115 (short)((get_ship_max_velocity(ship) *
116 (4 - acShipIonDriveDmg[ship])) >> 2);
117 }
118 if (asShipMaximumSpeedArray[ship] != oldVelocity)
119 celerate(ship, 0);
120 return 0;
121}
122
123/* Function start: 0x418280 */
124void drain_fuel(short ship, short amount)
125{
126 anShipFuelsTable[ship] -= (int)amount;
127 if (anShipFuelsTable == 0)
129}
130
131/* Function start: 0x4182B0 */
132void damage_ion_drive(short ship, short amount, short maximum)
133{
134 acShipIonDriveDmg[ship] = (signed char)max(0,
135 min(acShipIonDriveDmg[ship] + amount, maximum));
137}
138
139/* Function start: 0x4182F0 */
141{
142 enum ObjectType objectType = aeObjectTypeList[ship];
143 int acceleration = aObjectTypeData[objectType].acceleration;
144
145 if (ship < 10 && (acShipRating[ship] > RATING_ACE_ICEMAN
146 ))
147 return acceleration + acceleration / 3;
148 return acceleration;
149}
150
151/* Function start: 0x418330 */
152void point_at(short obj, FixedVector point)
153{
154 FixedVector direction;
155 void (*computeDelta)(const FixedVector *from, const FixedVector *to,
157 unsigned int (*shrink)(FixedVector *) = shrink_vector;
158
159 computeDelta(&aShipPositionsArray[obj], &point, &direction);
160 shrink(&direction);
161 aShipFwdVec[obj] = direction;
162 fix_objects_ijk(obj);
163}
164
165/* Function start: 0x4183A0 */
166void look_at(short obj)
167{
169}
170
171/* Function start: 0x4183D0 */
172void position_relative(FixedVector *position, FixedVector direction,
173 short distance)
174{
175 if (distance != 0) {
176 NormalizeFixedVector(&direction);
177 ScaleFixedVector(&direction, (int)distance << 8, &direction);
178 AddFixedVectors(position, &direction, position);
179 }
180}
181
182/* Function start: 0x418420 */
183void position_relative_ijk(FixedVector *position, short obj,
184 short right, short up, short forward)
185{
186 *position = aShipPositionsArray[obj];
187 position_relative(position, aShipRightVector[obj], right);
188 position_relative(position, aShipUpVector[obj], up);
189 position_relative(position, aShipFwdVec[obj], forward);
190}
191
192/* Function start: 0x4184C0 */
194{
195 if (value < -0x7fff00)
196 return -0x7fff;
197 if (value > 0x7fff00)
198 return 0x7fff;
199 return (short)(value >> 8);
200}
201
202/* Function start: 0x4184E0 */
203int MinInt(int a, int b)
204{
205 if (a <= b) b = a;
206 return b;
207}
208
209/* Function start: 0x4184F0 */
210int MaxInt(int a, int b)
211{
212 if (b <= a) b = a;
213 return b;
214}
215
216/* Function start: 0x418500 */
217int AbsInt(int v)
218{
219 if (v < 0)
220 v = -v;
221 return v;
222}
223
224/* Function start: 0x418510 */
225/* Exact Mac symbol: intfract_sign. No inbound reference is known in the
226 * shipped executable; this routine is believed unreachable. */
227int intfract_sign(int sign, int magnitude)
228{
229 int result;
230
231 result = magnitude;
232 if (sign >= 0)
233 return result;
234 return -result;
235}
236
237/* Function start: 0x418520 */
238unsigned short SignShort(short v)
239{
240 if (v < 0)
241 return 0xffff;
242 return (unsigned short)(0 < v);
243}
244
245/* Function start: 0x418540 */
246unsigned int SignFixed(int v)
247{
248 if (v < 0)
249 return 0xffffff00;
250 return v > 0 ? 0x100 : 0;
251}
252
253/* Function start: 0x418560 */
254/* Normalise a degree value into (-180, 180]. 0x168 == 360, 0xB4 == 180. */
255short WrapDegrees(short degrees)
256{
257 short v = degrees % 0x168;
258
259 if (v < -0xb4)
260 v = v + 0x168;
261 if (0xb4 < v)
262 v = v - 0x168;
263 return v;
264}
265
266/* Function start: 0x418590 */
267int equ_vector(const FixedVector *left, const FixedVector *right)
268{
269 return left->x == right->x && left->y == right->y &&
270 left->z == right->z;
271}
272
273/* Function start: 0x4185C0 */
274int IsPairEqualityDifferentFromFlag(const unsigned int *values)
275{
276 return ((values[1] == values[0]) == values[2]) == 0;
277}
278
279/* Function start: 0x4185F0 */
281{
282 vector->z = 0;
283 vector->y = 0;
284 vector->x = 0;
285}
286
287/* Function start: 0x418600 */
289{
290 vector->x = -vector->x;
291 vector->y = -vector->y;
292 vector->z = -vector->z;
293}
294
295/* Function start: 0x418620 */
296void AddFixedVectors(const FixedVector *left, const FixedVector *right,
297 FixedVector *sum)
298{
299 sum->x = right->x + left->x;
300 sum->y = right->y + left->y;
301 sum->z = right->z + left->z;
302}
303
304/* Function start: 0x418650 */
306 FixedVector *difference)
307{
308 difference->x = left->x - right->x;
309 difference->y = left->y - right->y;
310 difference->z = left->z - right->z;
311}
312
313/* Function start: 0x418680 */
314void ComputeVectorDelta(const FixedVector *from, const FixedVector *to, FixedVector *delta)
315{
316 delta->x = to->x - from->x;
317 delta->y = to->y - from->y;
318 delta->z = to->z - from->z;
319}
320
321/* Function start: 0x4186B0 */
322void ScaleFixedVector(const FixedVector *vector, int scale, FixedVector *result)
323{
324 result->x = MultiplyFixed(vector->x, scale);
325 result->y = MultiplyFixed(vector->y, scale);
326 result->z = MultiplyFixed(vector->z, scale);
327}
328
329/* Function start: 0x418700 */
330void divide_vector(FixedVector *vector, int divisor, FixedVector *result)
331{
332 result->x = DivideFixed(vector->x, divisor);
333 result->y = DivideFixed(vector->y, divisor);
334 result->z = DivideFixed(vector->z, divisor);
335}
336
337/* Function start: 0x418750 */
338short ChooseRandomSignedMagnitude(short minimum, short maximum,
339 int allowNegative)
340{
341 short value = RandomInRange(minimum, maximum);
342
343 if (allowNegative != 0 && RandomInRange(0, 1) != 0)
344 value = -value;
345 return value;
346}
347
348/* Function start: 0x418780 */
349void MakeRandomVectorFixed(short minimum, short maximum, FixedVector *vector)
350{
351 vector->x = ChooseRandomSignedMagnitude(minimum, maximum, 1) << 8;
352 vector->y = ChooseRandomSignedMagnitude(minimum, maximum, 1) << 8;
353 vector->z = ChooseRandomSignedMagnitude(minimum, maximum, 1) << 8;
354}
355
356/* Function start: 0x4187E0 */
358{
359 MakeRandomVectorFixed(0, limit, vector);
360}
361
362/* Function start: 0x418800 */
363void random_radial(const FixedVector *center, short radius,
364 FixedVector *position)
365{
366 FixedVector offset;
367
369 RandomBelowOrEqual(radius), &offset);
370 AddFixedVectors(center, &offset, position);
371}
372
373/* Function start: 0x418840 */
375{
376 vector->x = (unsigned short)RandomInRange(0x40, 0xff);
377 vector->y = (unsigned short)RandomInRange(0x40, 0xff);
378 vector->z = (unsigned short)RandomInRange(0x40, 0xff);
379 NormalizeFixedVector(vector);
380}
381
382/* Function start: 0x418890 */
383void rectangular_to_spherical(const FixedVector *rectangular,
384 SphericalVector *spherical)
385{
386 int z;
387
388 spherical->radius = Vector_magnitude(rectangular);
389 if (spherical->radius == 0)
390 return;
391 z = rectangular->z;
392 spherical->yaw = (short)ArcCos(
393 DivideFixed(z, PlanarMagnitude(rectangular->x, z)));
394 if (rectangular->x < 0)
395 spherical->yaw = -spherical->yaw;
396 spherical->pitch = (short)(ArcCos(
397 DivideFixed(rectangular->y, spherical->radius)) - 90);
398}
399
400/* Fixed-point trigonometry callee of the orientation routines below. */
401long SinFixed(short degrees);
402
403/* Function start: 0x418900 */
404/* Nothing in the shipped executable calls this routine. */
406 FixedVector *rectangular)
407{
408 int horizontalLength;
409
410 horizontalLength = MultiplyFixed(spherical->radius,
411 SinFixed(spherical->pitch));
412 rectangular->x = MultiplyFixed(horizontalLength,
413 CosFixed(spherical->yaw));
414 rectangular->z = MultiplyFixed(horizontalLength,
415 SinFixed(spherical->yaw));
416 rectangular->y = MultiplyFixed(spherical->radius,
417 CosFixed(spherical->pitch));
418}
419
420/* Function start: 0x418980 */
422 FixedVector *destination)
423{
424 destination->x = (int)source->x << 8;
425 destination->y = (int)source->y << 8;
426 destination->z = (int)source->z << 8;
427}
428
429/* Function start: 0x4189B0 */
430/* No inbound reference is known in the shipped executable; this routine is
431 * believed unreachable. */
433 ShortVector *destination)
434{
435 destination->x = (short)(source->x >> 8);
436 destination->y = (short)(source->y >> 8);
437 destination->z = (short)(source->z >> 8);
438}
439
440/* Function start: 0x4189E0 */
441int dot_product(const FixedVector *left, const FixedVector *right)
442{
443 int product;
444
445 product = MultiplyFixed(left->y, right->y);
446 product += MultiplyFixed(left->z, right->z);
447 return product + MultiplyFixed(left->x, right->x);
448}
449
450/* Function start: 0x418A30 */
452{
454 NormalizeFixedVector(&right);
455 return (short)(((short)dot_product(&left, &right) * 100) / 0x100);
456}
457
458/* Function start: 0x418A80 */
459void vector_cross_product(const FixedVector *left, const FixedVector *right,
460 FixedVector *product)
461{
462 product->x = MultiplyFixed(left->y, right->z) -
463 MultiplyFixed(left->z, right->y);
464 product->y = MultiplyFixed(left->z, right->x) -
465 MultiplyFixed(left->x, right->z);
466 product->z = MultiplyFixed(left->x, right->y) -
467 MultiplyFixed(left->y, right->x);
468}
469
470/* Function start: 0x418B10 */
472{
473 int magnitude = Vector_magnitude(vector);
474
475 if (magnitude != 0) {
476 vector->x = DivideFixed(vector->x, magnitude);
477 vector->y = DivideFixed(vector->y, magnitude);
478 vector->z = DivideFixed(vector->z, magnitude);
479 return 1;
480 }
481 return 0;
482}
483
484/* Function start: 0x418B60 */
486 const FixedVector *direction)
487{
488 FixedVector normalized;
489
490 normalized = *vector;
491 NormalizeFixedVector(&normalized);
492 return MultiplyFixed(
493 Vector_magnitude(vector), dot_product(direction, &normalized));
494}
495
496/* Function start: 0x418BB0 */
498 const FixedVector *direction,
499 FixedVector *component)
500{
501 int length;
502
503 length = vector_length_in_dir(vector, direction);
504 ScaleFixedVector(direction, length, component);
505}
506
507/* Function start: 0x418BE0 */
508void rotate_about_i(short angle, FixedVector *j, FixedVector *k)
509{
510 int cosine;
511 int sine;
512 int old;
513
514 cosine = CosFixed(angle);
515 sine = SinFixed(angle);
516 old = j->x;
517 j->x = MultiplyFixed(old, cosine) - MultiplyFixed(k->x, sine);
518 k->x = MultiplyFixed(old, sine) + MultiplyFixed(k->x, cosine);
519 old = j->y;
520 j->y = MultiplyFixed(old, cosine) - MultiplyFixed(k->y, sine);
521 k->y = MultiplyFixed(old, sine) + MultiplyFixed(k->y, cosine);
522 old = j->z;
523 j->z = MultiplyFixed(old, cosine) - MultiplyFixed(k->z, sine);
524 k->z = MultiplyFixed(old, sine) + MultiplyFixed(k->z, cosine);
525}
526
527/* Function start: 0x418D00 */
528void rotate_about_j(short angle, FixedVector *i, FixedVector *k)
529{
530 int cosine;
531 int sine;
532 int old;
533
534 cosine = CosFixed(angle);
535 sine = SinFixed(angle);
536 old = i->x;
537 i->x = MultiplyFixed(k->x, sine) + MultiplyFixed(old, cosine);
538 k->x = MultiplyFixed(k->x, cosine) - MultiplyFixed(old, sine);
539 old = i->y;
540 i->y = MultiplyFixed(k->y, sine) + MultiplyFixed(old, cosine);
541 k->y = MultiplyFixed(k->y, cosine) - MultiplyFixed(old, sine);
542 old = i->z;
543 i->z = MultiplyFixed(k->z, sine) + MultiplyFixed(old, cosine);
544 k->z = MultiplyFixed(k->z, cosine) - MultiplyFixed(old, sine);
545}
546
547/* Function start: 0x418E40 */
548void rotate_about_k(short angle, FixedVector *i, FixedVector *j)
549{
550 int sine;
551 int cosine;
552 int old;
553
554 cosine = CosFixed(angle);
555 sine = SinFixed(angle);
556 old = i->x;
557 i->x = MultiplyFixed(old, cosine) - MultiplyFixed(j->x, sine);
558 j->x = MultiplyFixed(old, sine) + MultiplyFixed(j->x, cosine);
559 old = i->y;
560 i->y = MultiplyFixed(old, cosine) - MultiplyFixed(j->y, sine);
561 j->y = MultiplyFixed(old, sine) + MultiplyFixed(j->y, cosine);
562 old = i->z;
563 i->z = MultiplyFixed(old, cosine) - MultiplyFixed(j->z, sine);
564 j->z = MultiplyFixed(old, sine) + MultiplyFixed(j->z, cosine);
565}
566
567/* Function start: 0x418F60 */
568void init_ijk(short obj)
569{
570 aShipFwdVec[obj].z = 0x100;
571 aShipUpVector[obj].y = 0x100;
572 aShipRightVector[obj].x = 0x100;
573 aShipFwdVec[obj].y = 0;
574 aShipUpVector[obj].z = 0;
575 aShipFwdVec[obj].x = 0;
576 aShipUpVector[obj].x = 0;
577 aShipRightVector[obj].z = 0;
578 aShipRightVector[obj].y = 0;
580 anObjectYawRotation[obj] = 0;
581 anObjPitchRot[obj] = 0;
582}
583
584/* Function start: 0x418FD0 */
585void copy_frame(short source, short destination)
586{
587 aShipRightVector[destination] =
588 aShipRightVector[source];
589 aShipUpVector[destination] =
590 aShipUpVector[source];
591 aShipFwdVec[destination] =
592 aShipFwdVec[source];
593}
594
595/* Function start: 0x419050 */
608
609/* Function start: 0x4190B0 */
611 FixedVector *destination, short obj)
612{
613 destination->x = dot_product(source, &aShipRightVector[obj]);
614 destination->y = dot_product(source, &aShipUpVector[obj]);
615 destination->z = dot_product(source, &aShipFwdVec[obj]);
616}
617
618/* Function start: 0x419110 */
619void alter_pitch(short angle, short obj)
620{
621 rotate_about_i(angle, &aShipUpVector[obj],
622 &aShipFwdVec[obj]);
623 fix_objects_ijk(obj);
624}
625
626/* Function start: 0x419150 */
627void alter_yaw(short angle, short obj)
628{
629 rotate_about_j(angle, &aShipRightVector[obj],
630 &aShipFwdVec[obj]);
631 fix_objects_ijk(obj);
632}
633
634/* Function start: 0x419190 */
635void alter_roll(short angle, short obj)
636{
637 rotate_about_k(angle, &aShipRightVector[obj],
638 &aShipUpVector[obj]);
639 fix_objects_ijk(obj);
640}
641
642/* Function start: 0x4191D0 */
644 const FixedVector *to)
645{
646 FixedVector delta;
647 long magnitude;
648
649 ComputeVectorDelta(from, to, &delta);
650 magnitude = Vector_magnitude(&delta);
651 return FixedToShortSaturating((int)magnitude);
652}
653
654/* Function start: 0x419210 */
655short distance_from_point(short obj, const FixedVector *point)
656{
657 long magnitude;
658
660 point, &vToTgt);
661 magnitude = Vector_magnitude(&vToTgt);
662 return FixedToShortSaturating((int)magnitude) -
664}
665
666/* Function start: 0x419260 */
667short distance_from_object(short obj, short other)
668{
669 return distance_from_point(obj, &aShipPositionsArray[other]) -
671}
672
673/* Function start: 0x419290 */
674/* The facing reads the low word of the dot product through the local's
675 * address, which is why the original keeps an unused stack slot for it. */
676void get_facing_range_from_point(short obj, const FixedVector *point)
677{
678 long facing;
679
680 nTgtRange =
681 distance_from_point(obj, point) -
686 &aShipFwdVec[obj]);
687 nFacingToTargetValue = (short)((*(short *)&facing * 100) >> 8);
688}
689
690/* Function start: 0x419310 */
691void get_facing_range_from_object(short obj, short other)
692{
693 long facing;
694
699 &aShipFwdVec[other]);
700 nTargetFacingValue = (short)((*(short *)&facing * 100) >> 8);
701}
702
703/* Function start: 0x419390 */
704void ship_vs_point(short obj, const FixedVector *point)
705{
706 get_facing_range_from_point(obj, point);
707}
708
709/* Function start: 0x4193B0 */
710void ship_vs_ship(short obj, short other)
711{
713}
714
715/* Function start: 0x4193D0 */
716short facing_to_object(short obj, FixedVector *point)
717{
718 FixedVector direction;
719
721 point, &direction);
722 NormalizeFixedVector(&direction);
724 (short)(((short)dot_product(
725 &direction, &aShipFwdVec[obj]) * 100) >> 8);
727}
728
729/* Function start: 0x419440 */
730short match_roll_orientation(short obj, short reference)
731{
732 FixedVector roll;
733 short angle;
734
735 roll.x = dot_product(&aShipUpVector[obj],
736 &aShipRightVector[reference]);
737 roll.y = dot_product(&aShipUpVector[obj],
738 &aShipUpVector[reference]);
739 roll.z = 0;
741 angle = (short)ArcCos(roll.y);
742 if (roll.x >= 0)
743 angle = 360 - angle;
744 return WrapDegrees(angle);
745}
746
747/* Function start: 0x4194D0 */
748int set_ship_rotation_goals(short obj, short turnRate,
749 const FixedVector *direction,
750 short pointingMode,
751 short *yawGoal, short *pitchGoal)
752{
753 SphericalVector spherical;
754 FixedVector localDirection;
755 int magnitude;
756
757 transform_to_objects_frame(direction, &localDirection, obj);
758 if (pointingMode == 1) {
759 rectangular_to_spherical(&localDirection, &spherical);
760 if (spherical.radius == 0)
761 return 1;
762 if (spherical.yaw > 0)
763 spherical.yaw = (short)(spherical.yaw - turnRate);
764 else
765 spherical.yaw = (short)(spherical.yaw + turnRate);
766 } else {
767 magnitude = Vector_magnitude(&localDirection);
768 if (magnitude == 0)
769 return 1;
770 spherical.yaw = (short)ArcSin(DivideFixed(
771 localDirection.x,
772 PlanarMagnitude(localDirection.x, localDirection.z)));
773 spherical.pitch = (short)-ArcSin(
774 DivideFixed(localDirection.y, magnitude));
775 if (localDirection.z < 0) {
776 spherical.yaw = (short)-spherical.yaw;
777 if (spherical.pitch > 0)
778 spherical.pitch = (short)(spherical.pitch + 180);
779 else
780 spherical.pitch = (short)(spherical.pitch - 180);
781 }
782 if (spherical.pitch > 0)
783 spherical.pitch = (short)(spherical.pitch - turnRate);
784 else
785 spherical.pitch = (short)(spherical.pitch + turnRate);
786 }
787 *yawGoal = WrapDegrees((short)-spherical.yaw);
788 *pitchGoal = WrapDegrees((short)-spherical.pitch);
789 return 0;
790}
791
792/* Function start: 0x419620 */
793void point_ship(short obj, short turnRate, const FixedVector *direction)
794{
795 set_ship_rotation_goals(obj, turnRate, direction,
797 &anYawTarget[obj],
798 &anPitchGoal[obj]);
799}
800
801/* Function start: 0x419660 */
802void point_ship_at_point(short obj, const FixedVector *point)
803{
804 FixedVector direction;
805
807 point, &direction);
808 point_ship(obj, 0, &direction);
809}
810
811/* Function start: 0x4196A0 */
812void point_ship_at_object(short obj, short other)
813{
815}
816
817/* Function start: 0x4196C0 */
818void point_capital_ship_at_object(short obj, short other)
819{
820 FixedVector direction;
821
823 &aShipPositionsArray[obj], &direction);
824 point_ship(obj, 0, &direction);
825}
826
827/* Function start: 0x419710 */
828void point_ship_behind_object(short obj, short other)
829{
830 FixedVector point = aShipPositionsArray[other];
831
832 position_relative(&point, aShipFwdVec[other],
833 (short)(-500 -
835 point_ship_at_point(obj, &point);
836}
837
838/* Function start: 0x419790 */
839void point_ship_below_object(short obj, short other)
840{
841 FixedVector point = aShipPositionsArray[other];
842
843 position_relative(&point, aShipUpVector[other],
844 (short)(asObjectCollisionRadius[other] +
845 500));
846 point_ship_at_point(obj, &point);
847}
848
849/* Function start: 0x419810 */
850void point_perpendicular_to_point(short obj, const FixedVector *point)
851{
852 point_ship_at_point(obj, point);
853 if (anYawTarget[obj] < 0)
854 anYawTarget[obj] += 90;
855 else
856 anYawTarget[obj] -= 90;
857}
858
859/* Function start: 0x419850 */
860void point_perpendicular(short obj, short other)
861{
863}
864
865/* Function start: 0x419870 */
866void point_parallel(short obj, short other)
867{
868 if (other != -1)
869 point_ship(obj, 0, &aShipFwdVec[other]);
870}
871
872/* Function start: 0x4198A0 */
873void MoveObjectAlongDirection(short obj, const FixedVector *direction,
874 short distance)
875{
876 FixedVector offset;
877
878 offset = *direction;
879 SetVectorFixedPoint(&offset, distance);
881 &aShipPositionsArray[obj]);
882}
883
884/* Function start: 0x4198F0 */
885/* Nothing in the shipped executable calls this routine. */
887 FixedVector *delta)
888{
889 ComputeVectorDelta(&aShipPositionsArray[obj], point, delta);
890}
891
892/* Function start: 0x419920 */
893/* Nothing in the shipped executable calls this routine. */
894void ComputeObjectToObjectDelta(short obj, short other, FixedVector *delta)
895{
897}
898
899/* Function start: 0x419950 */
900void NormalizeAndScaleVector(FixedVector *vector, int scale)
901{
902 NormalizeFixedVector(vector);
903 ScaleFixedVector(vector, scale, vector);
904}
905
906/* Function start: 0x419970 */
908{
909 NormalizeAndScaleVector(p, (int)v << 8);
910}
911
912/* Function start: 0x419990 */
913unsigned int IsPointWithinRange(const FixedVector *from, const FixedVector *to, short range)
914{
915 FixedVector delta;
916
917 ComputeVectorDelta(from, to, &delta);
918 return IsVectorWithinRange(&delta, range);
919}
920
921/* Function start: 0x4199C0 */
922short check_for_collision(short obj)
923{
924 short other;
925 short range;
926 FixedVector *objectPosition;
927 FixedVector *position;
928
929 objectPosition = &aShipPositionsArray[obj];
930 position = aShipPositionsArray;
931 for (other = 0; other <= SPACE_LAST_MOVING_OBJECT;
932 other++, position++) {
933 if (other != obj &&
935 ComputeVectorDelta(objectPosition, position,
937 range = asObjectCollisionRadius[other] +
939 if (aeObjectClass[other] == OBJECT_CLASS_SHIP &&
941 range >>= 1;
942 if (IsVectorWithinRange(&vCollisionDelta, range) != 0)
943 return other;
944 }
945 }
946 return -1;
947}
948
949/* Function start: 0x419A70 */
950void position_child(short parent, short hardpoint, FixedVector *position)
951{
952 const ShortVector *offset = &aChildOffsets[hardpoint];
953
954 position->x = aShipFwdVec[parent].x * offset->z +
955 aShipUpVector[parent].x * offset->y +
956 aShipRightVector[parent].x * offset->x +
957 aShipPositionsArray[parent].x;
958 position->y = aShipFwdVec[parent].y * offset->z +
959 aShipUpVector[parent].y * offset->y +
960 aShipRightVector[parent].y * offset->x +
961 aShipPositionsArray[parent].y;
962 position->z = aShipFwdVec[parent].z * offset->z +
963 aShipUpVector[parent].z * offset->y +
964 aShipRightVector[parent].z * offset->x +
965 aShipPositionsArray[parent].z;
966}
967
968/* Function start: 0x419B40 */
969void child_object(short hardpoint, short child, short parent)
970{
971 position_child(parent, hardpoint, &aShipPositionsArray[child]);
972 acObjOwnersTable[child] = (signed char)parent;
973}
974
975/* Function start: 0x419B70 */
976short get_ship_slot(void)
977{
978 short slot;
979
980 for (slot = 1; slot <= 9; slot++)
981 if (aeObjectClass[slot] == OBJECT_CLASS_NULL)
982 return nFreeShipSlot = slot;
983 return nFreeShipSlot = -1;
984}
985
986/* Function start: 0x419BA0 */
988{
989 short i = 10;
990
991 do {
993 asObjectScreenXList[i] = (short)0x8001;
994 return i;
995 }
996 i = i + 1;
997 } while (i <= 0x3c);
998 return -1;
999}
1000
1001/* Function start: 0x419BD0 */
1002void remove_object(short obj)
1003{
1004 short slot;
1005
1006 if (obj == -1)
1007 return;
1008 asObjectScreenXList[obj] = (short)0x8001;
1009 asObjDistancesTable[obj] = 0;
1010 if (obj == nNavPointerObject)
1011 nNavPointerObject = -1;
1012 if (obj == nYourWingman)
1013 nYourWingman = -1;
1014 for (slot = 0; slot < 20; slot++) {
1015 if (abHazardObjects[slot] == obj) {
1016 abHazardObjects[slot] = -1;
1017 break;
1018 }
1019 }
1020 if (obj < 10) {
1023 acShipRating[obj] = -1;
1025 aeShipSide[obj] = SIDE_NEUTRAL;
1027 clear_alert(obj);
1029 }
1031 apObjShapeArray[obj] = 0;
1032}
1033
1034/* Function start: 0x419CC0 */
1036{
1037 FixedVector acceleration;
1038
1039 divide_vector(force, awObjMassArray[obj] << 8, &acceleration);
1040 AddFixedVectors(&aShipVelocity[obj], &acceleration,
1041 &aShipVelocity[obj]);
1042}
1043
1044/* Function start: 0x419D10 */
1046 short obj)
1047{
1048 FixedVector localPoint;
1049 FixedVector localForce;
1050 FixedVector acceleration;
1051 int rotationalMass;
1052 int mass;
1053
1054 transform_to_objects_frame(force, &localForce, obj);
1055 transform_to_objects_frame(point, &localPoint, obj);
1056 mass = awObjMassArray[obj];
1057 rotationalMass = DivideFixed(
1058 (unsigned short)asObjAfterburnerVelocities[obj]
1059 << 8,
1060 (int)asObjectCollisionRadius[obj] << 8);
1061
1062 anObjectRollRotationList[obj] += (short)(DivideFixed(
1063 MultiplyFixed(localPoint.x, localForce.y) -
1064 MultiplyFixed(localPoint.y, localForce.x),
1065 rotationalMass) >> 8);
1066 anObjectYawRotation[obj] += (short)(DivideFixed(
1067 MultiplyFixed(localPoint.x, localForce.z) -
1068 MultiplyFixed(localPoint.z, localForce.x),
1069 rotationalMass) >> 8);
1070 anObjPitchRot[obj] += (short)(DivideFixed(
1071 MultiplyFixed(localPoint.z, localForce.y) -
1072 MultiplyFixed(localPoint.y, localForce.z),
1073 rotationalMass) >> 8);
1074 ClampTo30(&anObjPitchRot[obj]);
1077
1078 mass <<= 8;
1079 acceleration.x = DivideFixed(
1080 MultiplyFixed(0x16a -
1081 PlanarMagnitude(localPoint.y, localPoint.z),
1082 localForce.x),
1083 MultiplyFixed(0x16a, mass));
1084 acceleration.y = DivideFixed(
1085 MultiplyFixed(0x16a -
1086 PlanarMagnitude(localPoint.x, localPoint.z),
1087 localForce.y),
1088 MultiplyFixed(0x16a, mass));
1089 acceleration.z = DivideFixed(
1090 MultiplyFixed(0x16a -
1091 PlanarMagnitude(localPoint.x, localPoint.y),
1092 localForce.z),
1093 MultiplyFixed(0x16a, mass));
1094 AddFixedVectors(&aShipVelocity[obj], &acceleration,
1095 &aShipVelocity[obj]);
1096 if (aeObjectClass[obj] == OBJECT_CLASS_SHIP)
1098}
1099
1100/* Function start: 0x419F70 */
1102 short obj)
1103{
1104 FixedVector localPoint;
1105 FixedVector localForce;
1106 int denominator;
1107
1108 transform_to_objects_frame(force, &localForce, obj);
1109 transform_to_objects_frame(point, &localPoint, obj);
1110 denominator = DivideFixed(
1111 (unsigned short)asObjAfterburnerVelocities[obj]
1112 << 8,
1114 (int)asObjectCollisionRadius[obj] << 8,
1115 0x123c));
1116
1117 anObjectRollRotationList[obj] += (short)(DivideFixed(
1118 MultiplyFixed(localPoint.x, localForce.y) -
1119 MultiplyFixed(localPoint.y, localForce.x),
1120 denominator) >> 8);
1121 anObjectYawRotation[obj] += (short)(DivideFixed(
1122 MultiplyFixed(localPoint.x, localForce.z) -
1123 MultiplyFixed(localPoint.z, localForce.x),
1124 denominator) >> 8);
1125 anObjPitchRot[obj] += (short)(DivideFixed(
1126 MultiplyFixed(localPoint.z, localForce.y) -
1127 MultiplyFixed(localPoint.y, localForce.z),
1128 denominator) >> 8);
1129 ClampTo30(&anObjPitchRot[obj]);
1132 if (aeObjectClass[obj] == OBJECT_CLASS_SHIP)
1134}
1135
1136/* Function start: 0x41A0F0 */
1137void ClampVectorTo30(short *p)
1138{
1139 short v = *p;
1140
1141 if (v < 0) {
1142 *p = v + 1;
1143 return;
1144 }
1145 if (0 < v)
1146 *p = v - 1;
1147}
1148
1149/* Function start: 0x41A110 */
1150void ClampTo30(short *p)
1151{
1152 if (*p > 0x1e) {
1153 *p = 0x1e;
1154 return;
1155 }
1156 if (*p < -0x1e)
1157 *p = -0x1e;
1158}
1159
1160/* Function start: 0x41A130 */
1161unsigned short IsPointWithinEyeViewCone(const FixedVector *point)
1162{
1163 FixedVector direction;
1164 FixedVector viewPosition;
1165 int distance;
1166 long projection;
1167
1169 point, &direction);
1170 distance = Vector_magnitude(&direction);
1171 if (asObjectCollisionRadius[EYE_OBJECT] * 0x100 >
1172 distance)
1173 return 0;
1174 transform_to_objects_frame(&direction, &viewPosition,
1175 EYE_OBJECT);
1176 if (asObjectCollisionRadius[EYE_OBJECT] * 0x100 >
1177 viewPosition.z)
1178 return 0;
1179 projection = DivideFixed(viewPosition.z, distance);
1180 if (projection < 0x94)
1181 return 0;
1182 return 1;
1183}
1184
1185/* Function start: 0x41A1D0 */
1187{
1188 FixedVector direction;
1189 int objectRadius;
1190 short dustSize;
1191 int distance;
1192 int scaleFactor;
1193 short screenScale;
1194 short obj;
1195
1198 for (obj = 0; obj <= SPACE_LAST_MOVING_OBJECT; obj++) {
1199 if (aeObjectClass[obj] != OBJECT_CLASS_NULL &&
1200 aeObjectClass[obj] !=
1202 obj != nNavPointerObject) {
1205 asObjDistancesTable[obj] = 0;
1206 if (aeObjectClass[obj] ==
1208 asObjectScreenXList[obj] = (short)0x8001;
1209 continue;
1210 }
1211 if (aeObjectClass[obj] ==
1214 direction = aShipPositionsArray[obj];
1215 } else {
1217 &aShipPositionsArray[obj],
1218 &direction);
1219 }
1220 distance = Vector_magnitude(&direction);
1221 if (distance <
1223 asObjectScreenXList[obj] = (short)0x8001;
1224 continue;
1225 }
1226 if (aeObjectClass[obj] == OBJECT_CLASS_DUST &&
1227 distance > (1400 << 8)) {
1228 asObjectScreenXList[obj] = (short)0x8001;
1229 continue;
1230 }
1231 transform_to_objects_frame(&direction,
1233 obj],
1234 EYE_OBJECT);
1235 if (aObjectViewPositionsList[obj].z <
1237 asObjectScreenXList[obj] = (short)0x8001;
1238 continue;
1239 }
1241 distance) < 0x94) {
1242 asObjectScreenXList[obj] = (short)0x8001;
1243 continue;
1244 }
1245 objectRadius =
1246 asObjectCollisionRadius[obj] * 0x100;
1247 if (distance <= objectRadius)
1248 distance = objectRadius + 1;
1250 scaleFactor = DivideFixed(
1251 (short)(nScreenWidth & ~1) << 15,
1252 distance - objectRadius);
1253 screenScale = (short)(
1254 MultiplyFixed((unsigned short)
1255 awObjectScales[obj],
1256 scaleFactor) >> 8);
1257 if ((unsigned short)screenScale >= 0x2000)
1258 screenScale = 0x2000;
1259 asObjScreenScalesArray[obj] = screenScale;
1260 if ((unsigned short)screenScale <= 4) {
1261 asObjectScreenXList[obj] =
1262 (short)0x8001;
1263 continue;
1264 }
1265 }
1266 asObjDistancesTable[obj] =
1267 (unsigned short)(distance >> 8);
1268 asObjectScreenXList[obj] = (short)(DivideFixed(
1270 (short)(nScreenWidth & ~1) << 7,
1272 aObjectViewPositionsList[obj].z) >> 8);
1273 asObjectScreenYArray[obj] = (short)(DivideFixed(
1275 (short)(nScreenWidth & ~1) << 7,
1277 aObjectViewPositionsList[obj].z) >> 8);
1278 switch (aeObjectClass[obj]) {
1280 if (asObjScreenScalesArray[obj] == 0xff)
1281 set_background_objects_rotation(obj, &direction);
1282 break;
1283 case OBJECT_CLASS_DUST:
1284 dustSize = (short)(MultiplyFixed(
1285 0x900, DivideFixed(
1287 distance)) >> 8);
1288 if (dustSize > 3)
1289 dustSize = 3;
1290 dustSize = (short)(
1291 (asObjScreenAngles[obj] & 0x10) +
1292 (3 - dustSize) * 4);
1293 asObjectViewFrames[obj] =
1294 (short)(((asObjectCounterArray[obj] +
1296 dustSize);
1297 break;
1299 dustSize = 0;
1300 break;
1302 dustSize = 1;
1303 break;
1305 case OBJECT_CLASS_SHIP:
1307 get_right_shape(obj, &direction);
1308 break;
1309 }
1310 }
1311 }
1312}
1313
1314/* Function start: 0x41A530 */
1316{
1317 SphericalVector spherical;
1318 FixedVector projectedUp;
1319 short angle;
1320
1321 negate_vector(direction);
1322 rectangular_to_spherical(direction, &spherical);
1323 init_ijk(63);
1324 alter_yaw((short)-spherical.yaw, 63);
1325 alter_pitch((short)-spherical.pitch, 63);
1326 projectedUp.z = 0;
1327 projectedUp.x = dot_product(&aShipUpVector[EYE_OBJECT],
1328 &aShipRightVector[63]);
1329 projectedUp.y = dot_product(&aShipUpVector[EYE_OBJECT],
1330 &aShipUpVector[63]);
1331 NormalizeFixedVector(&projectedUp);
1332 angle = (short)ArcCos(projectedUp.y);
1333 angle %= 360;
1334 if (projectedUp.x >= 0)
1335 angle = 360 - angle;
1336 asObjScreenAngles[obj] = angle;
1337 asObjScreenScalesArray[obj] = 0xff;
1338}
1339
1340/* Function start: 0x41A610 */
1341void get_right_shape(short obj, FixedVector *direction)
1342{
1343 FixedVector right = { 0x100, 0, 0 };
1344 FixedVector up = { 0, 0x100, 0 };
1345 FixedVector forward = { 0, 0, 0x100 };
1346 FixedVector objectForward;
1347 FixedVector eyeUp;
1348 FixedVector projectedUp;
1349 SphericalVector spherical;
1350 short objectClass;
1351 short type;
1352 short pitchBand;
1353 short yawSector;
1354 short directionIndex;
1355 signed char frame;
1356 short remainder;
1357 short angle;
1358 short slot;
1359
1360 negate_vector(direction);
1361 rectangular_to_spherical(direction, &spherical);
1362 rotate_about_j((short)-spherical.yaw, &right, &forward);
1363 rotate_about_i((short)-spherical.pitch, &up, &forward);
1365 NormalizeFixedVector(&forward);
1366 transform_to_objects_frame(&forward, &objectForward, obj);
1368 &eyeUp, obj);
1369 rectangular_to_spherical(&objectForward, &spherical);
1370 pitchBand = (short)(spherical.pitch / 30 + 3);
1371 remainder = (short)(spherical.pitch % 30);
1372 if (remainder > 15) {
1373 pitchBand = (short)(pitchBand + 1 < 6 ? pitchBand + 1 : 6);
1374 } else if (remainder < -15) {
1375 pitchBand = (short)(pitchBand - 1 > 0 ? pitchBand - 1 : 0);
1376 }
1377 yawSector = (short)((12 - spherical.yaw / 30) % 12);
1378 remainder = (short)(spherical.yaw % 30);
1379 if (remainder > 15)
1380 yawSector = (short)((yawSector + 11) % 12);
1381 else if (remainder < -15)
1382 yawSector = (short)((yawSector + 1) % 12);
1383 /* The original leaves directionIndex unset outside the seven pitch bands. */
1384 switch (pitchBand) {
1385 case 0:
1386 directionIndex = 0;
1387 break;
1388 case 1:
1389 case 2:
1390 case 3:
1391 case 4:
1392 case 5:
1393 directionIndex = (short)(pitchBand * 12 + yawSector - 11);
1394 break;
1395 case 6:
1396 directionIndex = 61;
1397 break;
1398 }
1399
1400 projectedUp.z = 0;
1401 projectedUp.x = dot_product(
1402 &eyeUp, &aDirectionViewRightVector[directionIndex]);
1403 projectedUp.y = dot_product(
1404 &eyeUp, &aDirectionViewUpVectorArray[directionIndex]);
1405 NormalizeFixedVector(&projectedUp);
1406 angle = (short)ArcCos(projectedUp.y);
1407 if (projectedUp.x >= 0)
1408 angle = (short)(360 - angle);
1409
1410 objectClass = (short)aeObjectClass[obj];
1411 if (objectClass == OBJECT_CLASS_MISSILE ||
1412 (type = (short)aeObjectTypeList[obj]) == OBJECT_TYPE_TURRET) {
1413 directionIndex += DIRECTION_VIEW_COUNT;
1414 } else if (type == OBJECT_TYPE_KILRATHI_BASE) {
1415 directionIndex += DIRECTION_VIEW_COUNT * 2;
1416 }
1417 frame = acDirectionShapeFrame[directionIndex];
1418 if (frame == 0)
1419 angle += 90;
1420 if (frame == 36 &&
1421 objectClass != OBJECT_CLASS_MISSILE)
1422 angle -= 90;
1423 asObjectFlipArray[obj] =
1424 (short)(acDirectionShapeFlip[directionIndex] << 4);
1425 angle %= 360;
1426 if (angle < 0)
1427 angle += 360;
1428 asObjScreenAngles[obj] = angle;
1429
1430 if (objectClass == OBJECT_CLASS_CAPITAL_SHIP) {
1431 if (asCapitalShipViewFramesTable[obj] != frame) {
1432 for (slot = 1; slot < 3; slot++) {
1433 if (aObjectResourceSlotsArray[slot].type ==
1434 type) {
1435 break;
1436 }
1437 }
1438 asObjectViewFrames[obj] = 0;
1439 asCapitalShipViewFramesTable[obj] = frame;
1440 if (stSpaceBufferViewport.pixels != 0 &&
1442 (unsigned short)apObjShapeArray[obj]) == 0) {
1444 }
1446 apObjShapeArray[obj] =
1448 } else {
1452 (signed char)(type + 22);
1453 apObjShapeArray[obj] =
1457 }
1459 }
1460 } else {
1461 asObjectViewFrames[obj] = frame;
1462 }
1463}
void(__cdecl *pIxFree)(void *)
void ConvertSphericalToRectangular(const SphericalVector *spherical, FixedVector *rectangular)
Definition geom.c:405
void ComputeObjectToPointDelta(short obj, FixedVector *point, FixedVector *delta)
Definition geom.c:886
void ComputeObjectToObjectDelta(short obj, short other, FixedVector *delta)
Definition geom.c:894
short nNavPointerObject
Definition cockpt.c:71
signed char acShipRating[16]
Definition joycal.c:25
short asObjScreenScalesArray[SPACE_OBJECT_COUNT]
Definition dib.c:105
signed char acDirectionShapeFrame[DIRECTION_VIEW_COUNT *DIRECTION_SHAPE_TABLE_COUNT]
Definition data.c:63
enum Side aeShipSide[12]
Definition ending.c:22
short asObjScreenAngles[SPACE_OBJECT_COUNT]
Definition joycal.c:26
enum ShipManeuver aeShipManeuversTable[12]
Definition screen.c:25
ObjectTypeData aObjectTypeData[OBJECT_TYPE_COUNT]
Definition objdata.c:86
short anPitchGoal[16]
Definition screen.c:13
short anObjectRollRotationList[SPACE_OBJECT_COUNT]
Definition screen.c:16
short anObjectYawRotation[SPACE_OBJECT_COUNT]
Definition joycal.c:33
short anObjPitchRot[SPACE_OBJECT_COUNT]
Definition data.c:247
signed char acWingmanMessageStatesArray[16]
Definition video.c:25
signed char acShipIonDriveDmg[16]
Definition comm.c:56
FixedVector aDirectionViewUpVectorArray[DIRECTION_VIEW_COUNT]
Definition pload.c:16
short nTgtRange
Definition joycal.c:27
int anShipFuelsTable[12]
Definition data.c:252
FixedVector aObjectViewPositionsList[SPACE_OBJECT_COUNT]
Definition data.c:246
short asShipMaximumSpeedArray[16]
Definition game.c:552
short nFacingToTargetValue
Definition screen.c:19
FixedVector vToTgt
Definition comm.c:58
FixedVector aShipRightVector[64]
Definition smart.c:15
short asObjAfterburnerVelocities[SPACE_OBJECT_COUNT]
Definition dib.c:106
enum ObjectClass aeObjectClass[SPACE_OBJECT_COUNT]
Definition video.c:21
short nYourWingman
Definition game.c:61
signed char acShipPointingModeList[16]
Definition ending.c:28
short asObjectScreenYArray[SPACE_OBJECT_COUNT]
Definition screen.c:20
short nClosestVisibleObject
Definition game.c:58
FixedVector aShipVelocity[SPACE_OBJECT_COUNT]
Definition smart.c:21
short asObjectCollisionRadius[64]
Definition ending.c:27
short asCapitalShipViewFramesTable[16]
Definition screen.c:28
short asPreviousObjectDistance[SPACE_OBJECT_COUNT]
Definition video.c:20
short nScreenWidth
Definition data.c:34
void * aapPacketReferences[4][0x25]
Definition mission.c:17
unsigned short asObjDistancesTable[SPACE_OBJECT_COUNT]
Definition data.c:253
Viewport stSpaceBufferViewport
Definition timer.c:13
signed char cCapitalShipLogicalFile
Definition geom.c:14
short nTargetFacingValue
Definition input.c:17
short asObjectCounterArray[SPACE_OBJECT_COUNT]
Definition game.c:547
FixedVector aShipUpVector[64]
Definition smart.c:16
short asObjectScreenXList[SPACE_OBJECT_COUNT]
Definition screen.c:21
signed char acObjOwnersTable[64]
Definition joycal.c:29
short nCurrentSpaceFrameValue
Definition data.c:249
unsigned short awObjectScales[SPACE_OBJECT_COUNT]
Definition music.c:86
struct Shape * apObjShapeArray[SPACE_OBJECT_COUNT]
Definition comm.c:48
short nFreeShipSlot
Definition game.c:25
enum ObjectType aeObjectTypeList[SPACE_OBJECT_COUNT]
Definition data.c:255
short asObjectViewFrames[SPACE_OBJECT_COUNT]
Definition video.c:23
ObjectResourceSlot aObjectResourceSlotsArray[4]
Definition screen.c:30
short asObjectFlipArray[SPACE_OBJECT_COUNT]
Definition dib.c:97
unsigned short awObjMassArray[SPACE_OBJECT_COUNT]
Definition game.c:557
FixedVector aShipPositionsArray[SPACE_OBJECT_COUNT]
Definition game.c:556
ShortVector aChildOffsets[56]
Definition objdata.c:559
FixedVector aShipFwdVec[64]
Definition smart.c:17
short anYawTarget[16]
Definition smart.c:22
signed char abHazardObjects[0x14]
Definition game.c:43
FixedVector vCollisionDelta
Definition ending.c:24
FixedVector aDirectionViewRightVector[DIRECTION_VIEW_COUNT]
Definition pload.c:15
signed char acDirectionShapeFlip[DIRECTION_VIEW_COUNT *DIRECTION_SHAPE_TABLE_COUNT]
Definition data.c:83
FixedVector vNormalizedToTarget
Definition geom.c:15
short maximumVelocity
Definition wcdata.h:378
int acceleration
Definition wcdata.h:381
unsigned int dataOffset
Definition wcdata.h:757
unsigned int dataSize
Definition wcdata.h:759
unsigned int position
Definition wcdata.h:758
short z
Definition wcdata.h:435
short x
Definition wcdata.h:433
short y
Definition wcdata.h:434
unsigned char * pixels
Definition wc1base.h:74
Umbrella header for the game core.
void clear_alert(short obj)
Definition logic.c:189
short match_roll_orientation(short obj, short reference)
Definition geom.c:730
void transform_to_objects_frame(const FixedVector *source, FixedVector *destination, short obj)
Definition geom.c:610
void * AllocateTaggedMemory(int size, unsigned short flags)
Definition ending.c:31
void damage_ion_drive(short ship, short amount, short maximum)
Definition geom.c:132
void apply_force_to_object(FixedVector *point, FixedVector *force, short obj)
Definition geom.c:1045
void look_at(short obj)
Definition geom.c:166
unsigned short __stdcall GetFontCharWidth(char i)
Definition mathfp.c:184
void get_facing_range_from_point(short obj, const FixedVector *point)
Definition geom.c:676
long MultiplyFixed(int left, int right)
Definition mathfp.c:67
short distance_between_points(const FixedVector *from, const FixedVector *to)
Definition geom.c:643
void ClampTo30(short *p)
Definition geom.c:1150
void fix_objects_ijk(short obj)
Definition geom.c:596
void point_ship_at_object(short obj, short other)
Definition geom.c:812
long ArcSin(int value)
Definition mathfp.c:101
short distance_from_point(short obj, const FixedVector *point)
Definition geom.c:655
void ship_vs_ship(short obj, short other)
Definition geom.c:710
void FillFixedVectorWithRandomComponents(short limit, FixedVector *vector)
Definition geom.c:357
int set_ship_rotation_goals(short obj, short turnRate, const FixedVector *direction, short pointingMode, short *yawGoal, short *pitchGoal)
Definition geom.c:748
void rotate_about_i(short angle, FixedVector *j, FixedVector *k)
Definition geom.c:508
int dot_product(const FixedVector *left, const FixedVector *right)
Definition geom.c:441
void __stdcall MarkActivePaletteEntries(Viewport *viewport, unsigned char *active)
Definition gr.c:633
void remove_object(short obj)
Definition geom.c:1002
void MakeRandomNormalizedVector(FixedVector *vector)
Definition geom.c:374
int __stdcall SeekDataFile(unsigned short fd, int offset, unsigned int origin)
Definition mono.c:79
short recalc_max_velocity(short ship)
Definition geom.c:106
void alter_pitch(short angle, short obj)
Definition geom.c:619
long Vector_magnitude(const FixedVector *vector)
Definition mathfp.c:132
void * FetchDiskPacketRetrying(short logicalFile, short section, short flags)
Definition disk.c:126
void AddFixedVectors(const FixedVector *left, const FixedVector *right, FixedVector *sum)
Definition geom.c:296
void draw_nav_pointer(void)
Definition cockpt.c:2015
void point_capital_ship_at_object(short obj, short other)
Definition geom.c:818
void alter_roll(short angle, short obj)
Definition geom.c:635
void position_relative_ijk(FixedVector *position, short obj, short right, short up, short forward)
Definition geom.c:183
int equ_vector(const FixedVector *left, const FixedVector *right)
Definition geom.c:267
int __stdcall SeekPacketSection(PacketSectionHandle *handle, int offset, short origin)
Definition geom.c:34
short __stdcall MeasureTextPixelWidthClamped(const char *text)
Definition geom.c:18
unsigned int IsPointWithinRange(const FixedVector *from, const FixedVector *to, short range)
Definition geom.c:913
short check_for_collision(short obj)
Definition geom.c:922
void init_ijk(short obj)
Definition geom.c:568
unsigned short IsPointWithinEyeViewCone(const FixedVector *point)
Definition geom.c:1161
int vector_length_in_dir(const FixedVector *vector, const FixedVector *direction)
Definition geom.c:485
void rotational_acceleration(FixedVector *point, FixedVector *force, short obj)
Definition geom.c:1101
short FixedToShortSaturating(int value)
Definition geom.c:193
short get_ship_slot(void)
Definition geom.c:976
long SinFixed(short degrees)
Definition mathfp.c:89
unsigned int GetScreenUpdateFlag(void)
Definition main.c:361
short get_ship_max_velocity(short obj)
Definition geom.c:95
unsigned short GetMusicDriverPresent(short mode)
Definition geom.c:65
void set_background_objects_rotation(short obj, FixedVector *direction)
Definition geom.c:1315
void point_ship(short obj, short turnRate, const FixedVector *direction)
Definition geom.c:793
long ArcCos(int value)
Definition mathfp.c:108
short distance_from_object(short obj, short other)
Definition geom.c:667
int intfract_sign(int sign, int magnitude)
Definition geom.c:227
short vector_angle(FixedVector left, FixedVector right)
Definition geom.c:451
int IsPairEqualityDifferentFromFlag(const unsigned int *values)
Definition geom.c:274
void copy_frame(short source, short destination)
Definition geom.c:585
int MaxInt(int a, int b)
Definition geom.c:210
unsigned int initialize_view_buffer(void)
Definition main.c:371
long PlanarMagnitude(int x, int y)
Definition mathfp.c:121
void point_perpendicular(short obj, short other)
Definition geom.c:860
void alter_yaw(short angle, short obj)
Definition geom.c:627
void apply_force_to_objects_center(FixedVector *force, short obj)
Definition geom.c:1035
short WrapDegrees(short degrees)
Definition geom.c:255
long CosFixed(short degrees)
Definition mathfp.c:95
void point_perpendicular_to_point(short obj, const FixedVector *point)
Definition geom.c:850
void ScaleFixedVector(const FixedVector *vector, int scale, FixedVector *result)
Definition geom.c:322
void SetVectorFixedPoint(FixedVector *p, short v)
Definition geom.c:907
void rotate_about_k(short angle, FixedVector *i, FixedVector *j)
Definition geom.c:548
void ship_vs_point(short obj, const FixedVector *point)
Definition geom.c:704
short facing_to_object(short obj, FixedVector *point)
Definition geom.c:716
void position_child(short parent, short hardpoint, FixedVector *position)
Definition geom.c:950
long DivideFixed(int numerator, int denominator)
Definition mathfp.c:76
void get_right_shape(short obj, FixedVector *direction)
Definition geom.c:1341
void zero_vector(FixedVector *vector)
Definition geom.c:280
void child_object(short hardpoint, short child, short parent)
Definition geom.c:969
void SubtractFixedVectors(FixedVector *left, FixedVector *right, FixedVector *difference)
Definition geom.c:305
int AbsInt(int v)
Definition geom.c:217
int MinInt(int a, int b)
Definition geom.c:203
void MakeRandomVectorFixed(short minimum, short maximum, FixedVector *vector)
Definition geom.c:349
void point_ship_behind_object(short obj, short other)
Definition geom.c:828
unsigned short IdentityWord(unsigned short v)
Definition eventmgr.c:681
void position_relative(FixedVector *position, FixedVector direction, short distance)
Definition geom.c:172
short ChooseRandomSignedMagnitude(short minimum, short maximum, int allowNegative)
Definition geom.c:338
void ConvertFixedVectorToShortVector(const FixedVector *source, ShortVector *destination)
Definition geom.c:432
short find_vacant_3d_object(void)
Definition geom.c:987
void get_facing_range_from_object(short obj, short other)
Definition geom.c:691
unsigned int IsVectorWithinRange(FixedVector *vector, short range)
Definition eventmgr.c:1212
void rectangular_to_spherical(const FixedVector *rectangular, SphericalVector *spherical)
Definition geom.c:383
unsigned int shrink_vector(FixedVector *vector)
Definition eventmgr.c:1222
void point_at(short obj, FixedVector point)
Definition geom.c:152
unsigned short SignShort(short v)
Definition geom.c:238
void transform_objects_to_your_view(void)
Definition geom.c:1186
void NormalizeAndScaleVector(FixedVector *vector, int scale)
Definition geom.c:900
short __stdcall CollectActivePaletteIndices(Viewport *viewport, unsigned char *indices, short capacity)
Definition geom.c:71
void vector_cross_product(const FixedVector *left, const FixedVector *right, FixedVector *product)
Definition geom.c:459
void ClampVectorTo30(short *p)
Definition geom.c:1137
void ReleasePacketHandle(void *handle)
Definition ending.c:50
unsigned int check_for_lost_control(short obj)
Definition ship.c:364
unsigned int shrink(int *component)
Definition eventmgr.c:1235
void divide_vector(FixedVector *vector, int divisor, FixedVector *result)
Definition geom.c:330
void ConvertShortVectorToFixedVector(const ShortVector *source, FixedVector *destination)
Definition geom.c:421
void ComputeVectorDelta(const FixedVector *from, const FixedVector *to, FixedVector *delta)
Definition geom.c:314
void random_radial(const FixedVector *center, short radius, FixedVector *position)
Definition geom.c:363
void vector_component_in_dir(const FixedVector *vector, const FixedVector *direction, FixedVector *component)
Definition geom.c:497
void MoveObjectAlongDirection(short obj, const FixedVector *direction, short distance)
Definition geom.c:873
void FreePacketAndClear(void *slot, unsigned short releaseFlags)
Definition mathutil.c:37
unsigned int SignFixed(int v)
Definition geom.c:246
short __stdcall RandomInRange(short lo, short hi)
Definition mathfp.c:49
void point_ship_at_point(short obj, const FixedVector *point)
Definition geom.c:802
unsigned int celerate(short ship, int delta)
Definition ship.c:390
void point_parallel(short obj, short other)
Definition geom.c:866
short RandomBelowOrEqual(short n)
Definition mathfp.c:59
short NormalizeFixedVector(FixedVector *vector)
Definition geom.c:471
void drain_fuel(short ship, short amount)
Definition geom.c:124
void negate_vector(FixedVector *vector)
Definition geom.c:288
void rotate_about_j(short angle, FixedVector *i, FixedVector *k)
Definition geom.c:528
int GetShipAccelerationRate(short ship)
Definition geom.c:140
void point_ship_below_object(short obj, short other)
Definition geom.c:839
@ RATING_ACE_ICEMAN
Definition wcdata.h:191
#define SPACE_LAST_MOVING_OBJECT
Definition wcdata.h:1005
#define DIRECTION_VIEW_COUNT
Definition wcdata.h:1007
#define EYE_OBJECT
Definition wcdata.h:1006
ObjectType
Definition wcdata.h:54
@ OBJECT_TYPE_KILRATHI_BASE
Definition wcdata.h:76
@ OBJECT_TYPE_TURRET
Definition wcdata.h:82
@ SIDE_NEUTRAL
Definition wcdata.h:176
@ MANEUVER_NONE
Definition wcdata.h:207
@ OBJECT_CLASS_PLANET
Definition wcdata.h:41
@ OBJECT_CLASS_FIXED_OBJECT
Definition wcdata.h:45
@ OBJECT_CLASS_MISSILE
Definition wcdata.h:49
@ OBJECT_CLASS_SHIP
Definition wcdata.h:50
@ OBJECT_CLASS_DUST
Definition wcdata.h:42
@ OBJECT_CLASS_DEBRIS
Definition wcdata.h:44
@ OBJECT_CLASS_CAPITAL_SHIP
Definition wcdata.h:51
@ OBJECT_CLASS_STAR
Definition wcdata.h:40
@ OBJECT_CLASS_FUTURION
Definition wcdata.h:39
@ OBJECT_CLASS_ASTEROID
Definition wcdata.h:47
@ OBJECT_CLASS_PROJECTILE
Definition wcdata.h:46
@ OBJECT_CLASS_EXPLOSION
Definition wcdata.h:43
@ OBJECT_CLASS_NULL
Definition wcdata.h:38