-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2dPolys.c
3307 lines (2877 loc) · 106 KB
/
2dPolys.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* The X Men, June 1996
* Copyright (c) 1996 Probe Entertainment Limited
* All Rights Reserved
*
* $Revision: 124 $
*
* $Header: /PcProjectX/2dPolys.c 124 7/04/98 22:13 Collinsd $
*
* $Log: /PcProjectX/2dPolys.c $
*
* 124 7/04/98 22:13 Collinsd
* Hack for chris's goals. CWClear screen added.
*
* 123 3/04/98 11:39 Collinsd
* Tidy
*
* 122 30/03/98 10:20 Collinsd
* SOFTWARE_ENABLE # fixed.
*
* 121 28/03/98 15:25 Collinsd
* SoftwareVersion Transparency fixed.
*
* 120 18/03/98 14:06 Collinsd
* Bubbles now work through groups.
*
* 119 23/02/98 21:20 Collinsd
* Optimised Load/Save Functions.
*
* 118 20/02/98 16:29 Collinsd
* Added score zone display.
*
* 117 16/02/98 14:33 Collinsd
* Started LoadSave
*
* 116 2/02/98 10:06 Collinsd
* Reduced poly's on splash and splash does not effect water.
*
* 115 30/01/98 9:12 Collinsd
* Added Laser for exogenon and added corruption checking for componented
* objects.
*
* 114 29/01/98 12:06 Collinsd
* Added fireball, blue photon, tentacle and changed spotfx laser.
*
* 113 28/01/98 11:05 Collinsd
* Decreased Drip Effect
*
* 112 28/01/98 9:04 Collinsd
* Done more work on Afterburners.
*
* 111 20/01/98 16:34 Collinsd
* Added SpotFX to bikes.
*
* 110 5/01/98 10:39 Collinsd
* Water Splash is now tinted by water colour.
*
* 109 3/01/98 19:14 Collinsd
* Added Splash for secondary weapons
*
* 108 20/12/97 17:45 Collinsd
* Added new restart point.
*
* 107 20/12/97 15:48 Collinsd
* Restart points deactivated and startpoint loading added ollypad.
*
* 106 19/12/97 14:16 Collinsd
*
* 105 13/12/97 15:06 Collinsd
* Added light to explosion and slowed down the light on sparks.
*
* 104 12/12/97 17:43 Collinsd
* Started Beard afterburner.
*
* 103 9/12/97 10:45 Collinsd
* Done ship burning and change body parts and pickups now explode in
* direction of ship movement.
*
* 102 6/12/97 19:22 Collinsd
* Added burning effect on deathmode.
*
* 101 1/12/97 15:05 Collinsd
* Framelagged new transpulse/trojax explosion
*
* 100 25/11/97 12:56 Collinsd
* Added Photon Missile
*
* 99 18/11/97 11:50 Collinsd
* Added Drip and Fixed Enemy damage calculation.
*
* 98 17/11/97 19:09 Collinsd
* Added enemy generation effect. New Compobject format and relative flag
* for fmpolys.
*
* 97 15/11/97 16:57 Collinsd
* Secondary weapons now effect water, and bubbles hitting surface effect
* water.
*
* 96 15/11/97 15:20 Collinsd
* Added Bubbles
*
* 95 10/11/97 11:12 Collinsd
* Added new graphjcs ( transpulse, trojax .... )
*
* 94 3/11/97 18:27 Collinsd
* Added flames and shrapnel explosions. ( Also effect Water ).
*
* 93 29/10/97 9:26 Collinsd
* Added new spotfx and pointdir stuff.
*
* 92 23/10/97 13:52 Collinsd
* Added code to enable/disable compilation of software version.
* SOFTWARE_ENABLE & softblit.lib.
*
* 91 16/10/97 17:55 Collinsd
* Added new pointdir effect for models.
*
* 90 10/10/97 12:12 Collinsd
* Added flame and coloured sparks.
*
* 89 9/10/97 11:33 Collinsd
* Added new spotfx and enemies have ambient lights.
*
* 88 8/10/97 16:32 Collinsd
* Added spotfx and started lightning bolt.
*
* 87 16/09/97 10:59 Collinsd
* Added Chris's code
*
* 86 8/08/97 9:55 Collinsd
* Change TPage info structure.
*
* 85 7/08/97 21:25 Collinsd
* Change FmPolys to use tpage link list.
*
* 84 31/07/97 10:59 Collinsd
* Changed model modify buffer.
*
* 83 24/07/97 16:09 Collinsd
* Added enemy bullet and changed reflection of bullets
*
* 82 17/07/97 15:38 Collinsd
* BGObjects now use compobjs.
*
* 81 8/07/97 16:30 Collinsd
* Dicked about with include files FUCK!
*
* 80 5/07/97 16:31 Collinsd
* Put OPT_ON's around opimisations off
*
* 79 6/24/97 11:10a Phillipd
* Object Stuff is added.....
*
* 78 18/06/97 17:00 Collinsd
* Added PowerVR Trans
*
* 77 6/12/97 2:27p Phillipd
* bPolySort added as opposed to just basing it on PowerVR
*
* 76 10/06/97 14:27 Collinsd
* Added ACTUAL_TRANS to use transluecency values.
*
* 75 5/06/97 15:48 Collinsd
* Added edge enable flags
*
* 74 17/05/97 20:15 Collinsd
* Add PowerVR code for polys and screenpolys as well.......
*
* 73 5/17/97 6:14p Phillipd
*
* 72 17/05/97 16:01 Collinsd
* Added PVR polys
*
* 71 26/04/97 14:49 Collinsd
* Optimisations now on def.
*
* 70 17-03-97 8:57a Collinsd
* Poly's, Screen Polys, FmPolys now can create up to 1000 each.
*
* 69 12-03-97 4:47p Collinsd
* Added recoil and new shrapnel model.
*
* 68 27-02-97 2:08p Collinsd
* Added optimisation to various files.
*
* 67 25-02-97 12:05p Collinsd
* Framelaged pyrolite rifle.
*
* 66 25-02-97 10:20a Collinsd
* Corrected framelag on various bits.
*
* 65 2/03/97 5:16p Phillipd
* Translusceny is now controlled by global execute buffers.... which is
* much better...
*
* 64 12/27/96 3:38p Phillipd
* Primary.h Secondary.h pickups.h are now clean....
* Still Lots to do though.....
*
* 63 12/27/96 12:33p Phillipd
* all files are not dependant on mydplay.h...just some..
* including it several times in the same files didnt help..
*
* 62 12/17/96 12:56p Collinsd
* Added team missile stuff. and fixed translucency on 3DFX.
*
* 61 12/09/96 5:25p Collinsd
* Started smoke when hull damaged ( still need positions )
*
* 60 21/11/96 16:12 Collinsd
* Added code to reduce packet loss for pickups.
* Changed Trojax to be constant dir.
*
* 59 19/11/96 11:06 Collinsd
* Added new blood graphics.
*
* 58 4/11/96 16:35 Collinsd
* Fixed fmpolys/polys/lines exec lists.
*
* 57 3/11/96 16:40 Collinsd
* fixed groups visible.
*
* 56 29/10/96 14:49 Collinsd
* Added big explosion flash.
*
* 55 24/10/96 15:16 Collinsd
* No message if sfx, mine now collide immediatly if not owner
*
* 54 24/10/96 12:50 Collinsd
* Backface culling optimisation
*
* 53 23/10/96 19:12 Collinsd
* Execute buffer for fmpolys/polys now 64k
*
* 52 22/10/96 12:08 Collinsd
* Added body parts and blood splats.
*
* 51 17/10/96 12:40 Collinsd
* Added blend types to all transparent exec lists.
*
* 50 9/10/96 16:12 Collinsd
* Added regeneration sparkle. And model display flag.
*
* 49 9/10/96 10:02 Collinsd
* Old Sfx back, new gravgon trail.
*
* 48 7/10/96 13:52 Collinsd
* Added new smoke trails
*
* 47 5/10/96 21:34 Collinsd
* Added drop pickup mode. speeded up pickups even more now 0.9% of
* processing
*
* 46 10/05/96 2:02p Phillipd
*
* 45 4/10/96 10:47 Collinsd
* Added visible group pickup as well as using proper ray for movement of
* ship picking up.
*
* 44 1/10/96 17:43 Collinsd
* Reduced pulsar to half. Tidied up primary weapons.
* deleted redundant code in 2dpolys/primary weapons.
*
* 43 20/09/96 17:12 Collinsd
* Changed 2Dpolys and Polys to display only polys in visible groups.
* Changed secondary ammo to use array.
* Pickups now use correct index's. You can now drop a mine using 'B'.
*
* 42 17/09/96 13:58 Collinsd
* Added autoselection of primary and secondary weapons.
* Also you can pickup anything if F12 enabled.
*
* 41 15/09/96 14:48 Collinsd
* Scaled primary weapons, changed defauls ammo levels.
*
* 40 13/09/96 12:59 Collinsd
* Added shield effect to external views.
*
* 39 11/09/96 19:00 Collinsd
* Added tests for RAMP emulation ( Although may not work)
* Also fixed gravity effect to be dependent on GLOBAL_SCALE
*
* 38 11/09/96 16:17 Collinsd
* now use destalpha
*
* 37 11/09/96 14:19 Collinsd
* Added global scale to hopefully everything that needs it.
*
* 36 11/09/96 10:31 Collinsd
* Now use global scale for polys.
*
* 35 9/10/96 9:00a Phillipd
*
* 34 30/08/96 17:30 Collinsd
* Fixed bug in rgba colours ( Cheers Dan ).
*
* 33 8/21/96 5:49p Phillipd
*
* 32 21/08/96 8:46 Collinsd
* Added descent level, and powerlevel bar for trojax.
*
* 31 16/08/96 15:18 Collinsd
* Pickups now have bubble
*
* 30 16/08/96 11:01 Collinsd
* You now see explosions close to walls and when hit. Pickups and bullets
* don't dissapear when changing mode.
*
* 29 13/08/96 12:49 Collinsd
* Working on primary weapons
*
* 28 8/08/96 9:13 Collinsd
* Added Sfx and pickups
*
* 27 4/08/96 17:04 Collinsd
* All primary weapons are now in. ( no power ups )
*
* 26 2/08/96 15:28 Collinsd
* Added pickups
*
* 25 2/08/96 9:28 Collinsd
* Added double sided 2D polys, Static 2D polys.
* Added transpulse cannon and pyrolite weapon.
* Weapons should work correctly over network.
*
* 24 31/07/96 16:07 Collinsd
* Added new pyrolite weapon, added type into bullets/missiles. Fixed bug
* with 2d polys
*
* 23 29/07/96 16:43 Collinsd
* Fixed bug in missile hit & changed transpulse.
*
* 22 25/07/96 17:44 Collinsd
* Trojax weapon now has variable sizes. Primary weapon collision with
* ships now creates the proper explosion
*
* 21 25/07/96 10:08 Collinsd
* Added variable speed to trojax weapon.
*
* 20 24/07/96 12:59 Collinsd
* Started on primary weapons.
*
* 19 23/07/96 15:26 Collinsd
* Added new offset file loading/format.
*
* 18 21/07/96 20:42 Collinsd
* Added plasma sparks. ( Crap at the moment ! ).
*
* 17 21/07/96 12:52 Collinsd
* Now all works with Dan's new tloader
*
* 16 21/07/96 12:28 Collinsd
* Primary Weapon Selection added. Missiles now have multiple fireing
* methods/directions. Now uses tload.
*
* 15 19/07/96 16:56 Collinsd
*
* 14 19/07/96 12:36 Collinsd
* New Explosions and better smoke trails.
*
* 13 17/07/96 15:28 Collinsd
* Missiles/2DPolys altered to work better
*
* 12 15/07/96 14:30 Collinsd
* Transparency & Translucency work (With hardware)
*
* 11 11/07/96 12:50 Collinsd
* Drop missiles started
*
* 10 10/07/96 17:10 Collinsd
* Smoke trails added to missiles, explosions improved.
*
* 9 8/07/96 10:54 Collinsd
* Added rotations to FmPolys.
*
* 8 6/07/96 22:25 Collinsd
* Added pulse to 2dPoly's.
*
* 7 6/07/96 20:49 Collinsd
* FmPolys now caluate position of explosion constantly.
*
* 6 6/07/96 16:36 Collinsd
* Explosion moved away from wall, toward camera.
*
* 5 5/07/96 17:59 Collinsd
* Faceme poly's now use boxtoppm data
*
* 4 4/07/96 16:09 Collinsd
*
* 3 6/27/96 12:23p Phillipd
* removed d3dvertex types from routine prototypes
*
* 2 6/25/96 11:37a Phillipd
* First SS update
*
*/
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
* 2 d p o l y s . c
* All routines to do with 2d always face you polygons...
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
#include <stdio.h>
#include "typedefs.h"
#include <dplay.h>
#include "new3d.h"
#include "quat.h"
#include "CompObjects.h"
#include "bgobjects.h"
#include "Object.h"
#include "mydplay.h"
#include "2dpolys.h"
#include "camera.h"
#include "Primary.h"
#include "polysort.h"
#include "spotfx.h"
#include "water.h"
#ifdef OPT_ON
#pragma optimize( "gty", on )
#endif
#define FMPOLYSCALE 32.0F
#ifdef SOFTWARE_ENABLE
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Chris's Code
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
#define CHRISFLAG 8192
void CWExecute2( LPDIRECT3DDEVICE lpDev,
LPDIRECT3DEXECUTEBUFFER execbuf,
LPDIRECT3DVIEWPORT lpView,
WORD cwFlags);
extern BOOL SoftwareVersion;
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
#endif
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Externs
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
extern CAMERA CurrentCamera;
extern D3DMATRIX view;
extern MATRIX Identity;
extern MATRIX ProjMatrix;
extern VECTOR Camera_Dir;
extern VECTOR Forward;
extern VECTOR SlideUp;
extern VECTOR SlideLeft;
extern D3DMATERIALHANDLE hMat2;
extern D3DTEXTUREHANDLE bTex;
extern BYTE WhoIAm;
extern TLOADHEADER Tloadheader;
extern FRAME_INFO * Troj_Exp_Header;
extern FRAME_INFO * Shrapnel_Header;
extern float framelag;
extern BOOL UsedStippledAlpha;
extern MATRIX MATRIX_Identity;
extern DWORD CurrentSrcBlend;
extern DWORD CurrentDestBlend;
extern DWORD CurrentTextureBlend;
extern BOOL CanCullFlag;
extern BOOL PowerVR;
extern BOOL bPolySort;
extern MLOADHEADER Mloadheader;
extern MCLOADHEADER MCloadheader;
extern MCLOADHEADER MCloadheadert0;
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Globals
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
FMPOLY FmPolys[ MAXNUMOF2DPOLYS ];
uint16 FirstFmPolyUsed;
uint16 FirstFmPolyFree;
uint32 TotalFmPolysInUse = 0;
int16 MakeColourMode = MCM_Normal;
TPAGEINFO FmPolyTPages[ MAXTPAGESPERTLOAD + 1 ];
void DebugPrintf( const char * format, ... );
void FadeColour( uint8 * Colour, uint8 WantedColour, float Speed );
#define RGBA_MAKE2(r, g, b, a) ((D3DCOLOR) (( (DWORD) ((a) & 0xff) << 24) | ( (DWORD) ((r) & 0xff) << 16) | ( (DWORD) ((g) & 0xff) << 8) | (DWORD) ((b) & 0xff)))
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Procedure : Init Faceme poly structures
Input : Nothing
Output : Nothing
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
void InitFmPoly( void )
{
int i;
FirstFmPolyUsed = (uint16) -1;
FirstFmPolyFree = 0;
for( i=0;i<MAXNUMOF2DPOLYS;i++)
{
memset( &FmPolys[i], 0, sizeof( FMPOLY ) );
FmPolys[i].xsize = ( 16.0F * GLOBAL_SCALE );
FmPolys[i].ysize = ( 16.0F * GLOBAL_SCALE );
FmPolys[i].R = 255;
FmPolys[i].G = 255;
FmPolys[i].B = 255;
#if ACTUAL_TRANS
FmPolys[i].Trans = 128;
#else
FmPolys[i].Trans = 255;
#endif
FmPolys[i].DirVector.x = 0.0F;
FmPolys[i].DirVector.y = 0.0F;
FmPolys[i].DirVector.z = 1.0F;
FmPolys[i].UpVector.x = 0.0F;
FmPolys[i].UpVector.y = 1.0F;
FmPolys[i].UpVector.z = 0.0F;
FmPolys[i].NextInTPage = (uint16) -1;
FmPolys[i].PrevInTPage = (uint16) -1;
FmPolys[i].Next = i + 1;
FmPolys[i].Prev = (uint16) -1;
}
FmPolys[MAXNUMOF2DPOLYS-1].Next = (uint16) -1;
InitFmPolyTPages();
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Procedure : Find a free FmPoly and move it from the free list to
the used list
Input : Nothing
Output : uint16 Number of the free FmPoly
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
uint16 FindFreeFmPoly( void )
{
uint16 i;
i = FirstFmPolyFree;
if( i == (uint16) -1 ) return i;
FmPolys[i].Prev = FirstFmPolyUsed;
if ( FirstFmPolyUsed != (uint16) -1)
{
FmPolys[FirstFmPolyUsed].Next = i;
}
FirstFmPolyUsed = i;
FirstFmPolyFree = FmPolys[i].Next;
TotalFmPolysInUse++;
return i ;
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Procedure : Kill a used FmPoly and move it from the used list to
the free list
Input : uint16 Number of FmPoly to free....
Output : Nothing
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
void KillUsedFmPoly( uint16 i )
{
uint16 its_prev;
uint16 its_next;
its_prev = FmPolys[i].Prev;
its_next = FmPolys[i].Next;
if ( i == FirstFmPolyUsed )
FirstFmPolyUsed = FmPolys[i].Prev;
if( its_prev != (uint16) -1)
FmPolys[its_prev].Next = its_next;
if( its_next != (uint16) -1)
FmPolys[its_next].Prev = its_prev;
TotalFmPolysInUse--;
RemoveFmPolyFromTPage( i, GetTPage( *FmPolys[i].Frm_Info, 0 ) );
FmPolys[i].Prev = (uint16) -1;
FmPolys[i].Next = FirstFmPolyFree;
FmPolys[i].LifeCount = 0.0F;
FmPolys[i].xsize = ( 16.0F * GLOBAL_SCALE );
FmPolys[i].ysize = ( 16.0F * GLOBAL_SCALE );
FmPolys[i].Rot = 0.0F;
FmPolys[i].RotSpeed = 0.0F;
FmPolys[i].R = 255;
FmPolys[i].G = 255;
FmPolys[i].B = 255;
FmPolys[i].Trans = 255;
FmPolys[i].Flags = 0;
FmPolys[i].Frame = 0.0F;
FmPolys[i].SeqNum = 0;
FmPolys[i].Dir.x = 0.0F;
FmPolys[i].Dir.y = 0.0F;
FmPolys[i].Dir.z = 0.0F;
FmPolys[i].DirVector.x = 0.0F;
FmPolys[i].DirVector.y = 0.0F;
FmPolys[i].DirVector.z = 1.0F;
FmPolys[i].UpVector.x = 0.0F;
FmPolys[i].UpVector.y = 1.0F;
FmPolys[i].UpVector.z = 0.0F;
FmPolys[i].Speed = 0.0F;
FmPolys[i].Frm_Info = NULL;
FirstFmPolyFree = i;
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Procedure : Process FmPoly's
Input : Nothing
Output : Nothing
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
#if 0
#define NMEGEN_START ( 5.0F * ANIM_SECOND )
#define NMEGEN_STAGE1 ( 2.0F * ANIM_SECOND )
#define NMEGEN_STAGE2 ( 1.0F * ANIM_SECOND )
#define NMEGEN_END ( 0.0F * ANIM_SECOND )
#define NMEGEN_STAGE0_LEN ( NMEGEN_START - NMEGEN_STAGE1 )
#define NMEGEN_STAGE1_LEN ( NMEGEN_STAGE1 - NMEGEN_STAGE2 )
#define NMEGEN_STAGE2_LEN ( NMEGEN_STAGE2 - NMEGEN_END )
#else
#define NMEGEN_START ( 2.0F * ANIM_SECOND )
#define NMEGEN_STAGE1 ( 0.8F * ANIM_SECOND )
#define NMEGEN_STAGE2 ( 0.4F * ANIM_SECOND )
#define NMEGEN_END ( 0.0F * ANIM_SECOND )
#define NMEGEN_STAGE0_LEN ( NMEGEN_START - NMEGEN_STAGE1 )
#define NMEGEN_STAGE1_LEN ( NMEGEN_STAGE1 - NMEGEN_STAGE2 )
#define NMEGEN_STAGE2_LEN ( NMEGEN_STAGE2 - NMEGEN_END )
#endif
static int16 GlobCount;
static uint8 ShadeTable[ 16 ] = { 255, 200, 128, 104, 96, 92, 80, 77, 74, 72, 69, 66, 64, 64, 64, 64 };
static uint8 SmokeRingShadeTable[ 5 ] = { 255, 200, 150, 100, 50 };
void FmPolyProcess( void )
{
uint16 i;
uint16 nextprim;
float Speed;
float R, G, B, T, FadeDec;
VECTOR Rotation;
float OldSize;
float Damage;
VECTOR TempDir, TempVector;
VECTOR Int_Point;
NORMAL Int_Normal;
MATRIX UpMatrix;
MATRIX InvUpMatrix;
QUAT TempQuat;
VECTOR OldPos;
GlobCount += (int16) framelag; // Use Timer!!!
i = FirstFmPolyUsed;
while( i != (uint16) -1 )
{
nextprim = FmPolys[i].Prev;
FmPolys[i].LifeCount -= framelag;
if( FmPolys[i].LifeCount < 0.0F ) FmPolys[i].LifeCount = 0.0F;
switch( FmPolys[i].SeqNum )
{
case FM_ANIMSPEED: // Anim using animspeed
FmPolys[i].Frame += ( framelag / FmPolys[i].AnimSpeed );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
KillUsedFmPoly( i );
}
break;
case FM_ANIM: // Explosion?
FmPolys[i].Trans = ( 248 - ( (int16) ( FmPolys[i].Frame * 8.0F ) ) );
FmPolys[i].Frame += ( framelag / 3.0F );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
KillUsedFmPoly( i );
}
break;
case FM_ANIM2: // Ship Explosion?
FmPolys[i].Trans = ( 248 - ( (int16) ( FmPolys[i].Frame * 8.0F ) ) );
FmPolys[i].Frame += ( framelag / 4.0F );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
KillUsedFmPoly( i );
}
break;
case FM_SMOKE_TRAIL: // Smoke Trail?
Speed = ( FmPolys[i].Speed * framelag );
FmPolys[i].Trans = ( 248 - ( (int16) ( FmPolys[i].Frame * 8.0F ) ) );
FmPolys[i].R = ShadeTable[ (int16) FmPolys[i].Frame ];
FmPolys[i].G = ShadeTable[ (int16) FmPolys[i].Frame ];
FmPolys[i].B = ShadeTable[ (int16) FmPolys[i].Frame ];
FmPolys[i].Pos.x += ( FmPolys[i].Dir.x * Speed );
FmPolys[i].Pos.y += ( FmPolys[i].Dir.y * Speed );
FmPolys[i].Pos.z += ( FmPolys[i].Dir.z * Speed );
if( FmPolys[i].Speed > 0.0F )
{
FmPolys[i].Speed -= 4.0F;
if( FmPolys[i].Speed < 0.0F ) FmPolys[i].Speed = 0.0F;
}
FmPolys[i].Frame += ( framelag / 2.0F );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
KillUsedFmPoly( i );
}
break;
case FM_TROJAX_EXP: // Explosion?
FadeDec = ( 8.0F * framelag );
R = ( ( (float) FmPolys[i].R ) - FadeDec );
G = ( ( (float) FmPolys[i].G ) - FadeDec );
B = ( ( (float) FmPolys[i].B ) - FadeDec );
T = ( ( (float) FmPolys[i].Trans ) - FadeDec );
if( R < 0.0F ) R = 0.0F;
if( G < 0.0F ) G = 0.0F;
if( B < 0.0F ) B = 0.0F;
if( T < 0.0F ) T = 0.0F;
FmPolys[i].R = (uint8) R;
FmPolys[i].G = (uint8) G;
FmPolys[i].B = (uint8) B;
FmPolys[i].Trans = (uint8) T;
FmPolys[i].xsize += ( TROJAX_EXPINC * framelag );
FmPolys[i].ysize += ( TROJAX_EXPINC * framelag );
if( FmPolys[i].xsize >= TROJAX_EXPMAXSIZE )
{
KillUsedFmPoly( i );
}
break;
case FM_TROJAX: // Trojax bullet
FmPolys[ i ].Rot += ( FmPolys[i].RotSpeed * framelag );
if( FmPolys[ i ].Rot > 360.0F ) FmPolys[ i ].Rot -= 360.0F;
else if( FmPolys[ i ].Rot < 0.0F ) FmPolys[ i ].Rot += 360.0F;
Rotation.x = (float) sin( D2R( FmPolys[ i ].Rot ) );
Rotation.y = (float) cos( D2R( FmPolys[ i ].Rot ) );
Rotation.z = 0.0F;
ApplyMatrix( &FmPolys[ i ].Mat, &Rotation, &FmPolys[ i ].UpVector );
break;
case FM_PULSAR_EXP: // Pulsar Explosion?
FmPolys[i].Frame += ( framelag / 4.0F );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
KillUsedFmPoly( i );
}
break;
case FM_PULSAR:
break;
case FM_NMEBULLET1:
FmPolys[i].Frame += ( framelag / 3.0F );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
FmPolys[i].Frame -= ( ( FmPolys[i].Frame / (*FmPolys[i].Frm_Info)->Num_Frames )
* (*FmPolys[i].Frm_Info)->Num_Frames );
}
break;
case FM_SHRAPNEL_EXP: // Shrapnel Explosion?
if( FmPolys[i].LifeCount < 995.0F )
{
if( FmPolys[i].Frm_Info != &Shrapnel_Header )
{
RemoveFmPolyFromTPage( i, GetTPage( *FmPolys[i].Frm_Info, (int16) FmPolys[i].Frame ) );
FmPolys[i].Frm_Info = &Shrapnel_Header;
AddFmPolyToTPage( i, GetTPage( *FmPolys[i].Frm_Info, 0 ) );
FmPolys[i].Frame = 0.0F;
FmPolys[i].xsize = SUSSGUN_EXPSIZE;
FmPolys[i].ysize = SUSSGUN_EXPSIZE;
FmPolys[i].R = 128;
FmPolys[i].G = 128;
FmPolys[i].B = 128;
}
else
{
FmPolys[i].Frame += framelag;
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
KillUsedFmPoly( i );
}
}
}
break;
case FM_FLAME: // Flame Thrower?
FmPolys[ i ].Rot += ( FmPolys[i].RotSpeed * framelag );
if( FmPolys[ i ].Rot > 360.0F ) FmPolys[ i ].Rot -= 360.0F;
else if( FmPolys[ i ].Rot < 0.0F ) FmPolys[ i ].Rot += 360.0F;
FmPolys[i].Frame += framelag;
if( FmPolys[i].Frame > 12.0F ) FmPolys[i].Frame = 12.0F;
break;
case FM_STATIC: // Static Obj Don't move/rotate
break;
case FM_ARC: // Arc?
break;
case FM_ARC2: // Arc Glow?
break;
case FM_ARC_SPARK: // Arc Sparks?
FmPolys[i].Frame += ( framelag / 5.0F );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
KillUsedFmPoly( i );
}
else
{
if( FmPolys[i].Speed > 0.0F )
{
FmPolys[i].Speed -= 0.5F;
if( FmPolys[i].Speed < 0.0F ) FmPolys[i].Speed = 0.0F;
}
Speed = ( FmPolys[i].Speed * framelag );
FmPolys[i].Pos.x += ( FmPolys[i].Dir.x * Speed );
FmPolys[i].Pos.y += ( FmPolys[i].Dir.y * Speed );
FmPolys[i].Pos.z += ( FmPolys[i].Dir.z * Speed );
}
break;
case FM_BITS: // Bits?
FmPolys[i].Frame += ( framelag / 6.0F );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
KillUsedFmPoly( i );
}
else
{
Speed = ( FmPolys[i].Speed * framelag );
FmPolys[i].Pos.x += ( FmPolys[i].Dir.x * Speed );
FmPolys[i].Pos.y += ( FmPolys[i].Dir.y * Speed );
FmPolys[i].Pos.z += ( FmPolys[i].Dir.z * Speed );
}
break;
case FM_ARC_RING: // Arc Explosion Ring?
FadeDec = ( 8.0F * framelag );
R = ( ( (float) FmPolys[i].R ) - FadeDec );
G = ( ( (float) FmPolys[i].G ) - FadeDec );
B = ( ( (float) FmPolys[i].B ) - FadeDec );
T = ( ( (float) FmPolys[i].Trans ) - FadeDec );
if( R < 0.0F ) R = 0.0F;
if( G < 0.0F ) G = 0.0F;
if( B < 0.0F ) B = 0.0F;
if( T < 0.0F ) T = 0.0F;
FmPolys[i].R = (uint8) R;
FmPolys[i].G = (uint8) G;
FmPolys[i].B = (uint8) B;
FmPolys[i].Trans = (uint8) T;
FmPolys[i].xsize += ( TRANSPULSE_EXP_INC * framelag );
FmPolys[i].ysize += ( TRANSPULSE_EXP_INC * framelag );
if( FmPolys[i].xsize >= TRANSPULSE_EXP_MAXSIZE )
{
KillUsedFmPoly( i );
}
break;
case FM_FLARE: // Arc Explosion Flare?
if( FmPolys[i].LifeCount == 0.0F )
{
KillUsedFmPoly( i );
}
break;
case FM_GRAVGON_TRAIL: // Gravgon Smoke Trail?
Speed = ( FmPolys[i].Speed * framelag );
FmPolys[i].Trans = ( 248 - ( (int16) ( ( FmPolys[i].Frame * 5.0F ) * 8.0F ) ) );
FmPolys[i].R = ShadeTable[ (int16) ( FmPolys[i].Frame * 5.0F )];
FmPolys[i].G = ShadeTable[ (int16) ( FmPolys[i].Frame * 5.0F )];
FmPolys[i].B = ShadeTable[ (int16) ( FmPolys[i].Frame * 5.0F )];
FmPolys[i].Pos.x += ( FmPolys[i].Dir.x * Speed );
FmPolys[i].Pos.y += ( FmPolys[i].Dir.y * Speed );
FmPolys[i].Pos.z += ( FmPolys[i].Dir.z * Speed );
FmPolys[i].xsize += ( GRAVGON_TRAIL_INC * framelag );
FmPolys[i].ysize += ( GRAVGON_TRAIL_INC * framelag );
if( FmPolys[i].Speed > 0.0F )
{
FmPolys[i].Speed -= ( 2.0F * framelag );
if( FmPolys[i].Speed < 0.0F ) FmPolys[i].Speed = 0.0F;
}
FmPolys[i].Frame += ( 0.1F * framelag );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames ) KillUsedFmPoly( i );
break;
case FM_SOLARIS_TRAIL: // Solaris Smoke Trail?
Speed = ( FmPolys[i].Speed * framelag );
FmPolys[i].Trans = ( 248 - ( (int16) ( ( FmPolys[i].Frame * 3.0F ) * 8.0F ) ) );
FmPolys[i].R = ShadeTable[ (int16) ( FmPolys[i].Frame * 3.0F )];
FmPolys[i].G = ShadeTable[ (int16) ( FmPolys[i].Frame * 3.0F )];
FmPolys[i].B = ShadeTable[ (int16) ( FmPolys[i].Frame * 3.0F )];
FmPolys[i].Pos.x += ( FmPolys[i].Dir.x * Speed );
FmPolys[i].Pos.y += ( FmPolys[i].Dir.y * Speed );
FmPolys[i].Pos.z += ( FmPolys[i].Dir.z * Speed );
if( FmPolys[i].Speed > 0.0F )
{
FmPolys[i].Speed -= ( 2.0F * framelag );
if( FmPolys[i].Speed < 0.0F ) FmPolys[i].Speed = 0.0F;
}
FmPolys[i].Frame += ( 0.166F * framelag );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames ) KillUsedFmPoly( i );
break;
case FM_NEW_TRAIL: // New Smoke Trail?
Speed = ( FmPolys[i].Speed * framelag );
FmPolys[i].Trans = ( 248 - ( (int16) ( ( FmPolys[i].Frame * 3.0F ) * 8.0F ) ) );
FmPolys[i].R = ShadeTable[ (int16) ( FmPolys[i].Frame * 3.0F )];
FmPolys[i].G = ShadeTable[ (int16) ( FmPolys[i].Frame * 3.0F )];
FmPolys[i].B = ShadeTable[ (int16) ( FmPolys[i].Frame * 3.0F )];
FmPolys[i].Pos.x += ( FmPolys[i].Dir.x * Speed );
FmPolys[i].Pos.y += ( FmPolys[i].Dir.y * Speed );
FmPolys[i].Pos.z += ( FmPolys[i].Dir.z * Speed );
if( FmPolys[i].Speed > 0.0F )
{
FmPolys[i].Speed -= ( 2.0F * framelag );
if( FmPolys[i].Speed < 0.0F ) FmPolys[i].Speed = 0.0F;
}
FmPolys[i].Frame += ( 0.166F * framelag );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames ) KillUsedFmPoly( i );
break;
case FM_PICKUP_REGEN: // Regenerating Pickup?
FmPolys[i].Frame += ( framelag / 6.0F );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
KillUsedFmPoly( i );
}
break;
case FM_BLOOD: // Blood?
FmPolys[i].Frame += ( framelag / 8.0F );
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
KillUsedFmPoly( i );
}
else
{
Speed = ( FmPolys[i].Speed * framelag );
FmPolys[i].Pos.x += ( FmPolys[i].Dir.x * Speed );
FmPolys[i].Pos.y += ( FmPolys[i].Dir.y * Speed );
FmPolys[i].Pos.z += ( FmPolys[i].Dir.z * Speed );
}
break;
case FM_BLOODSPLAT: // Blood Splat?
FmPolys[i].Frame += ( framelag / 8.0F ); //6.0F;
if( FmPolys[i].Frame >= (*FmPolys[i].Frm_Info)->Num_Frames )
{
KillUsedFmPoly( i );
}
else
{
FadeDec = ( 255.0F / ( (*FmPolys[i].Frm_Info)->Num_Frames * 8.0F ) ) * framelag;
R = ( ( (float) FmPolys[i].R ) - FadeDec );
G = ( ( (float) FmPolys[i].G ) - FadeDec );
B = ( ( (float) FmPolys[i].B ) - FadeDec );
T = ( ( (float) FmPolys[i].Trans ) - FadeDec );
if( R < 0.0F ) R = 0.0F;
if( G < 0.0F ) G = 0.0F;
if( B < 0.0F ) B = 0.0F;
if( T < 0.0F ) T = 0.0F;
FmPolys[i].R = (uint8) R;
FmPolys[i].G = (uint8) G;
FmPolys[i].B = (uint8) B;