1 #ifndef PROTOTYP_INCLUDED 2 #define PROTOTYP_INCLUDED 3 4 /* 5 6 Global Functions, Structures and Variables are prototyped here 7 8 */ 9 10 11 #include "shpanim.h" 12 13 #ifdef __cplusplus 14 15 extern "C" { 16 17 #endif 18 19 20 21 #include "mem3dc.h" 22 23 24 25 26 /* 27 28 Structures, Unions & Enums 29 30 */ 31 32 extern const int sine[4096]; 33 extern const int cosine[4096]; 34 35 36 typedef struct vectorch { 37 38 int vx; 39 int vy; 40 int vz; 41 42 } VECTORCH; 43 44 typedef struct quat { 45 46 int quatw; 47 int quatx; 48 int quaty; 49 int quatz; 50 51 } QUAT; 52 53 typedef struct vectorchf { 54 55 float vx; 56 float vy; 57 float vz; 58 59 } VECTORCHF; 60 61 void FNormalise(VECTORCHF *n); 62 63 typedef struct vector2d { 64 65 int vx; 66 int vy; 67 68 } VECTOR2D; 69 70 typedef struct vector2df { 71 72 float vx; 73 float vy; 74 75 } VECTOR2DF; 76 77 void FNormalise2d(VECTOR2DF *n); 78 79 typedef struct line { 80 81 VECTORCH v0; 82 VECTORCH v1; 83 84 } LINE; 85 86 87 88 typedef struct euler { 89 90 int EulerX; 91 int EulerY; 92 int EulerZ; 93 94 } EULER; 95 96 97 typedef struct angularvelocity { 98 99 EULER AngV; 100 101 int PitchCount; 102 int YawCount; 103 int RollCount; 104 105 } ANGULARVELOCITY; 106 107 108 typedef struct matrixch { 109 110 int mat11; 111 int mat12; 112 int mat13; 113 114 int mat21; 115 int mat22; 116 int mat23; 117 118 int mat31; 119 int mat32; 120 int mat33; 121 122 } MATRIXCH; 123 124 typedef struct matrixchf { 125 126 float mat11; 127 float mat12; 128 float mat13; 129 130 float mat21; 131 float mat22; 132 float mat23; 133 134 float mat31; 135 float mat32; 136 float mat33; 137 138 } MATRIXCHF; 139 140 /* Sorry about this... */ 141 142 //#include "hmodel.h" 143 144 struct hmodelcontroller; 145 146 147 /* 148 149 This structure is used by map function "MapSetVDB()" to pass parameters 150 to the "SetVDB()" function. 151 152 */ 153 154 typedef struct mapsetvdb { 155 156 int SVDB_Flags; 157 int SVDB_ViewType; 158 159 int SVDB_Depth; 160 161 int SVDB_CentreX; 162 int SVDB_CentreY; 163 164 int SVDB_ProjX; 165 int SVDB_ProjY; 166 int SVDB_MaxProj; 167 168 int SVDB_ClipLeft; 169 int SVDB_ClipRight; 170 int SVDB_ClipUp; 171 int SVDB_ClipDown; 172 173 int SVDB_H1; 174 int SVDB_H2; 175 int SVDB_HInterval; 176 int SVDB_HColour; 177 int SVDB_Ambience; 178 179 int SVDB_ObViewState; 180 int SVDB_ObViewDistance; 181 int SVDB_ObPanX; 182 int SVDB_ObPanY; 183 184 185 } MAPSETVDB; 186 187 188 /* 189 190 Simplified Shapes 191 192 The array of shapes MUST be terminated by "-1" 193 194 */ 195 196 typedef struct simshapelist { 197 198 int SSL_Threshold; /* 1st trans. for proj. r */ 199 int *SSL_Shapes; /* ptr to array of shapes */ 200 201 } SIMSHAPELIST; 202 203 204 /* 205 206 Map Structures 207 208 Each map is made up of a collection of arrays of these different block 209 types. Access to them is provided by the header block (see below). 210 211 Map TYPES are defined in the project specific file "equates.h" 212 213 */ 214 215 216 217 typedef struct mapblock1 { 218 219 int MapType; 220 221 #if LoadingMapsShapesAndTexturesEtc 222 223 int MapFNameIndex; 224 char **MapFNameArray; 225 SHAPEHEADER **MapShapeDataArray; 226 227 #endif 228 229 } MAPBLOCK1; 230 231 232 typedef struct mapblock2 { 233 234 int MapType; 235 int MapShape; 236 237 #if LoadingMapsShapesAndTexturesEtc 238 239 int MapFNameIndex; 240 char **MapFNameArray; 241 SHAPEHEADER **MapShapeDataArray; 242 243 #endif 244 245 } MAPBLOCK2; 246 247 248 typedef struct mapblock3 { 249 250 int MapType; 251 int MapShape; 252 253 #if LoadingMapsShapesAndTexturesEtc 254 255 int MapFNameIndex; 256 char **MapFNameArray; 257 SHAPEHEADER **MapShapeDataArray; 258 259 #endif 260 261 VECTORCH MapWorld; 262 263 } MAPBLOCK3; 264 265 266 typedef struct mapblock4 { 267 268 int MapType; 269 int MapShape; 270 271 #if LoadingMapsShapesAndTexturesEtc 272 273 int MapFNameIndex; 274 char **MapFNameArray; 275 SHAPEHEADER **MapShapeDataArray; 276 277 #endif 278 279 VECTORCH MapWorld; 280 281 EULER MapEuler; 282 283 } MAPBLOCK4; 284 285 286 typedef struct mapblock5 { 287 288 int MapType; 289 int MapShape; 290 291 #if LoadingMapsShapesAndTexturesEtc 292 293 int MapFNameIndex; 294 char **MapFNameArray; 295 SHAPEHEADER **MapShapeDataArray; 296 297 #endif 298 299 VECTORCH MapWorld; 300 301 EULER MapEuler; 302 303 int MapFlags; 304 305 306 } MAPBLOCK5; 307 308 309 typedef struct mapblock6 { 310 311 int MapType; 312 int MapShape; 313 314 #if LoadingMapsShapesAndTexturesEtc 315 316 int MapFNameIndex; 317 char **MapFNameArray; 318 SHAPEHEADER **MapShapeDataArray; 319 320 #endif 321 322 VECTORCH MapWorld; 323 324 EULER MapEuler; 325 326 int MapFlags; 327 328 329 MAPSETVDB *MapVDBData; 330 331 int MapInteriorType; 332 333 } MAPBLOCK6; 334 335 336 typedef struct mapblock7 { 337 338 int MapType; 339 int MapShape; 340 341 #if LoadingMapsShapesAndTexturesEtc 342 343 int MapFNameIndex; 344 char **MapFNameArray; 345 SHAPEHEADER **MapShapeDataArray; 346 347 #endif 348 349 VECTORCH MapWorld; 350 351 EULER MapEuler; 352 353 int MapFlags; 354 int MapFlags2; 355 int MapFlags3; 356 357 358 MAPSETVDB *MapVDBData; 359 360 int MapInteriorType; 361 362 int MapLightType; /* See LIGHTTYPES */ 363 364 365 VECTORCH MapOrigin; /* Origin of Rotation */ 366 367 SIMSHAPELIST *MapSimShapes; 368 369 int MapViewType; /* See "VDB_ViewType" */ 370 371 372 } MAPBLOCK7; 373 374 375 typedef struct mapblock8 { 376 377 int MapType; 378 int MapShape; 379 380 VECTORCH MapWorld; 381 382 EULER MapEuler; 383 384 int MapFlags; 385 int MapFlags2; 386 int MapFlags3; 387 388 MAPSETVDB *MapVDBData; 389 390 int MapInteriorType; 391 392 int MapLightType; /* See LIGHTTYPES */ 393 394 395 VECTORCH MapOrigin; /* Origin of Rotation */ 396 397 SIMSHAPELIST *MapSimShapes; 398 399 int MapViewType; /* See "VDB_ViewType" */ 400 401 struct displayblock **MapMPtr; /* Write our dptr here as mother */ 402 struct displayblock **MapDPtr; /* Read our dptr here as daughter */ 403 404 VECTORCH MapMOffset; /* Offset from mother */ 405 406 } MAPBLOCK8; 407 408 409 /* 410 411 Map Header Block 412 413 */ 414 415 typedef struct mapheader { 416 417 MAPBLOCK1 *MapType1Objects; 418 MAPBLOCK2 *MapType2Objects; 419 MAPBLOCK3 *MapType3Objects; 420 MAPBLOCK4 *MapType4Objects; 421 MAPBLOCK5 *MapType5Objects; 422 MAPBLOCK6 *MapType6Objects; 423 MAPBLOCK7 *MapType7Objects; 424 MAPBLOCK8 *MapType8Objects; 425 426 } MAPHEADER; 427 428 429 430 /* 431 432 Physical Screen Descriptor Block 433 434 Only one of these exists and it is filled out by the Video Mode Set 435 function. 436 437 Functions use these parameters in conjunction with those in the 438 View Descriptor Block to calculate Screen and View scaling factors. 439 440 */ 441 442 typedef struct screendescriptorblock { 443 444 int SDB_Width; 445 int SDB_Height; 446 int SDB_Depth; 447 int SDB_ScreenDepth; 448 int SDB_Size; 449 450 int SDB_DiagonalWidth; 451 452 int SDB_CentreX; 453 int SDB_CentreY; 454 455 int SDB_ProjX; 456 int SDB_ProjY; 457 int SDB_MaxProj; 458 459 int SDB_ClipLeft; 460 int SDB_ClipRight; 461 int SDB_ClipUp; 462 int SDB_ClipDown; 463 464 int SDB_Flags; 465 466 int SDB_ViewAngle; 467 int SDB_ViewAngleCos; 468 469 unsigned int TLTSize; 470 unsigned int TLTShift; 471 472 } SCREENDESCRIPTORBLOCK; 473 474 475 /* 476 477 Screen Descriptor Block Flags 478 479 Set these BEFORE setting the video mode 480 481 */ 482 483 #define SDB_Flag_222 0x00000001 /* 8-bit mode 222 texture palette */ 484 #define SDB_Flag_Raw256 0x00000002 /* 8-bit mode, no texture remap */ 485 486 #define SDB_Flag_MIP 0x00000004 /* Create MIP maps for images */ 487 488 #define SDB_Flag_SuperSample2x2 0x00000008 /* 8T and 24 only */ 489 490 #define SDB_Flag_DrawFrontToBack 0x00000010 /* Useful if Z-Buffering */ 491 492 #define SDB_Flag_TLTPalette 0x00000020 /* 8Raw only, Images may have ih_flag_tlt and the tlt maps colours from an abstract palette to the screen palette */ 493 #define SDB_Flag_TLTSize 0x00000040 /* The TLTSize member is valid, o/w TLTSize is 256 */ 494 #define SDB_Flag_TLTShift 0x00000080 /* The TLTShift member is valid because the TLTSize is a power of two */ 495 496 497 498 /* 499 500 Clip Plane Block 501 502 */ 503 504 typedef struct clipplaneblock { 505 506 VECTORCH CPB_Normal; 507 VECTORCH CPB_POP; 508 509 } CLIPPLANEBLOCK; 510 511 512 /* 513 514 Clip Plane Points 515 516 */ 517 518 typedef struct clipplanepoints { 519 520 VECTORCH cpp1; 521 VECTORCH cpp2; 522 VECTORCH cpp3; 523 524 } CLIPPLANEPOINTS; 525 526 /* 527 528 View Descriptor Block 529 530 View location and orientation will come from the currently designated view 531 object. A pointer to an object block will not be essential, which is why I 532 have added a location to the viewport block. The matrix exists in the 533 viewport block because it is not the same matrix that appears in the object 534 block. The object block has a matrix that takes it from local space to world 535 space. I need the transpose of this matrix to create a world space to view 536 space transformation. 537 538 See "3dc\docs\c*.doc" for more information. 539 540 */ 541 542 typedef struct viewdescriptorblock { 543 544 struct viewdescriptorblock *VDB_HigherP; 545 struct viewdescriptorblock *VDB_LowerP; 546 547 int VDB_ViewType; /* To match ObViewType, used by image backdrops */ 548 549 int VDB_Priority; /* Determines draw order */ 550 551 int VDB_Flags; 552 553 int VDB_ViewAngle; 554 int VDB_ViewAngleCos; 555 556 int VDB_Width; 557 int VDB_Height; 558 int VDB_Depth; 559 int VDB_ScreenDepth; 560 561 int VDB_CentreX; 562 int VDB_CentreY; 563 564 int VDB_ProjX; 565 int VDB_ProjY; 566 int VDB_MaxProj; 567 568 int VDB_ClipZ; 569 int VDB_ClipLeft; 570 int VDB_ClipRight; 571 int VDB_ClipUp; 572 int VDB_ClipDown; 573 574 CLIPPLANEBLOCK VDB_ClipZPlane; 575 CLIPPLANEBLOCK VDB_ClipLeftPlane; 576 CLIPPLANEBLOCK VDB_ClipRightPlane; 577 CLIPPLANEBLOCK VDB_ClipUpPlane; 578 CLIPPLANEBLOCK VDB_ClipDownPlane; 579 580 struct displayblock *VDB_ViewObject; 581 582 VECTORCH VDB_World; 583 584 MATRIXCH VDB_Mat; 585 MATRIXCH VDB_HorizonMat; 586 MATRIXCH VDB_SpriteMat; 587 588 EULER VDB_MatrixEuler; 589 590 591 int VDB_H1; 592 int VDB_H2; 593 int VDB_HInterval; 594 595 int VDB_HColour; /* "Sky" */ 596 int VDB_HColour8; /* For 8-bit colour indirected modes */ 597 598 int VDB_HGColour; /* "Ground" */ 599 int VDB_HGColour8; /* For 8-bit colour indirected modes */ 600 601 int VDB_Ambience; 602 603 #if pc_backdrops 604 BACKDROPTYPE VDB_BackdropType; 605 unsigned short VDB_ProjectorXOffsets[MaxScreenWidth]; 606 #endif 607 608 #if ProjectSpecificVDBs 609 void* VDB_ProjectSpecificHook; 610 #endif 611 612 } VIEWDESCRIPTORBLOCK; 613 614 615 /* Flags */ 616 617 #define ViewDB_Flag_SingleBuffer 0x00000001 618 #define ViewDB_Flag_DoubleBuffer 0x00000002 619 #define ViewDB_Flag_FullSize 0x00000004 /* Use fast screen clear */ 620 #define ViewDB_Flag_NoBackdrop 0x00000008 621 622 #define ViewDB_Flag_LTrunc 0x00000010 /* Informs the VDB creator */ 623 #define ViewDB_Flag_RTrunc 0x00000020 /* that a physical screen */ 624 #define ViewDB_Flag_UTrunc 0x00000040 /* violation has forced a */ 625 #define ViewDB_Flag_DTrunc 0x00000080 /* truncation of the viewport */ 626 627 #define ViewDB_Flag_Hazing 0x00000100 628 #define ViewDB_Flag_DontDraw 0x00000200 629 #define ViewDB_Flag_AdjustScale 0x00000400 /* Scale 320x200 definition up to equivalent size for the mode */ 630 #define ViewDB_Flag_AddSubject 0x00000800 /* For MapSetVDB, telling it to add dptr_last to the dptr */ 631 632 #define ViewDB_Flag_NeedToFlushZ 0x00001000 /* Cleared by flush function */ 633 634 635 #define ViewDB_Flag_ImageBackdrop 0x00004000 /* This requires a backdrop 636 image array, accessed through 637 "Global_SceneBackdropPtr" */ 638 639 #define ViewDB_Flag_Horizon 0x00008000 /* Draw a "traditional" 640 Sky/Ground horizon - before 641 the backdrop is drawn */ 642 643 #define ViewDB_Flag_UseBackdropImageColoursForHorizon 0x00010000 644 645 #define ViewDB_Flag_NoScreenClear 0x00020000 646 647 #define ViewDB_Flag_NoModules 0x00040000 648 649 650 /* 651 652 A VDB global "iflag_drawtx3das2d" that forces all 3d textures to be drawn as 2d 653 according to the "iflag_drawtx3das2d" pipeline. 654 655 WARNING! 656 657 Only use this when drawing per object or per vdb as it uses the global vdb pointer 658 659 */ 660 661 #define ViewDB_Flag_drawtx3das2d 0x00080000 662 663 664 /* test the flags with "& VDB_Trunc" to see if any truncation occurred */ 665 666 #define VDB_Trunc (ViewDB_Flag_LTrunc | ViewDB_Flag_RTrunc | ViewDB_Flag_UTrunc | ViewDB_Flag_DTrunc) 667 668 669 670 /* 671 672 Light Source Data Structures 673 674 */ 675 676 677 /* 678 679 Light Types 680 681 */ 682 683 typedef enum { 684 685 LightType_Infinite, /* Default */ 686 LightType_PerObject, 687 LightType_PerVertex 688 689 } LIGHTTYPES; 690 691 692 typedef struct lightblock { 693 694 int LightFlags; 695 int LightType; 696 697 VECTORCH LightWorld; /* World space light position */ 698 699 VECTORCH LocalLP; /* Light position in object local space */ 700 701 int LightBright; /* 0->1 Fixed Point */ 702 int LightRange; 703 704 int BrightnessOverRange; 705 706 /* these RGB components take values 0-65536 */ 707 int RedScale; 708 int GreenScale; 709 int BlueScale; 710 711 int LightBrightStore; 712 713 } LIGHTBLOCK; 714 715 /* 716 717 Light Flags 718 719 */ 720 721 #define LFlag_CosAtten 0x00000001 /* Cosine attenuation */ 722 #define LFlag_CosSpreadAtten 0x00000002 /* Cosine spread attenuation */ 723 #define LFlag_Omni 0x00000004 /* Omnidirectional */ 724 #define LFlag_Deallocate 0x00000008 /* Deallocate at frame end */ 725 #define LFlag_NoShadows 0x00000010 /* Prelighting - No Shadows */ 726 #define LFlag_Off 0x00000020 /* Prelighting - Light OFF */ 727 728 #define LFlag_PreLitSource 0x00000040 /* WARNING: Not obj. specific */ 729 730 #define LFlag_WasNotAllocated 0x00000080 /* Supplied by another */ 731 732 #define LFlag_AbsPos 0x00000100 /* Pos. not rel. to parent */ 733 #define LFlag_AbsOff 0x00000200 /* Offset not rel. to parent */ 734 735 #define LFlag_AbsLightDir 0x00000400 /* Light dir. not rel. to p. */ 736 737 #define LFlag_NoSpecular 0x00000800 738 739 #define LFlag_Electrical 0x00001000 740 #define LFlag_Thermal 0x00002000 741 742 /* KJL 16:17:42 01/10/98 - used to specify no specular component to the light; 743 avoids unnecessary texture wash-out. */ 744 745 #if SupportMorphing 746 747 748 /* 749 750 Morph Frame 751 752 */ 753 754 typedef struct morphframe { 755 756 int mf_shape1; 757 int mf_shape2; 758 759 } MORPHFRAME; 760 761 762 /* 763 764 Morph Header 765 766 */ 767 768 typedef struct morphheader { 769 770 int mph_numframes; 771 int mph_maxframes; 772 MORPHFRAME *mph_frames; 773 774 } MORPHHEADER; 775 776 777 /* 778 779 Display Pipeline Structure 780 781 */ 782 783 typedef struct morphdisplay { 784 785 int md_lerp; 786 int md_one_minus_lerp; 787 int md_shape1; 788 int md_shape2; 789 SHAPEHEADER *md_sptr1; 790 SHAPEHEADER *md_sptr2; 791 792 } MORPHDISPLAY; 793 794 795 /* 796 797 Morph Control Structure 798 799 */ 800 801 typedef struct morphctrl { 802 803 int ObMorphCurrFrame; 804 int ObMorphFlags; 805 int ObMorphSpeed; 806 MORPHHEADER *ObMorphHeader; 807 808 } MORPHCTRL; 809 810 811 #endif /* SupportMorphing */ 812 813 814 815 /* 816 817 Object Display Block 818 819 */ 820 821 typedef struct displayblock 822 { 823 int ObShape; 824 825 struct sfxblock *SfxPtr; 826 827 SHAPEHEADER* ObShapeData; 828 829 char * name; 830 831 #if (SupportMorphing && LazyEvaluationForMorphing) 832 VECTORCH *ObMorphedPts; 833 #endif 834 835 VECTORCH ObWorld; /* World Space Location */ 836 EULER ObEuler; /* Euler Orientation */ 837 MATRIXCH ObMat; /* Local -> World Orientation Matrix */ 838 839 int ObFlags; 840 int ObFlags2; 841 int ObFlags3; 842 843 /* Lights */ 844 int ObNumLights; 845 LIGHTBLOCK *ObLights[MaxObjectLights]; 846 847 #if SupportModules 848 struct module *ObMyModule; /* This is our module */ 849 struct module *ObModule; /* We are in this module */ 850 #endif 851 852 VECTORCH ObView; /* View Space Location */ 853 854 struct viewdescriptorblock *ObVDBPtr; 855 856 /* Lights */ 857 int ObLightType; /* See LIGHTTYPES above */ 858 859 /* Extent */ 860 int ObRadius; /* max(sqr(x^2+y^2+z^2)) */ 861 int ObMaxX; 862 int ObMinX; 863 int ObMaxY; 864 int ObMinY; 865 int ObMaxZ; 866 int ObMinZ; 867 868 struct txactrlblk *ObTxAnimCtrlBlks; 869 870 EXTRAITEMDATA *ObEIDPtr; /* Overrides shape EID pointer */ 871 872 #if SupportMorphing 873 MORPHCTRL *ObMorphCtrl; /* Structure provided by project */ 874 #endif 875 876 /* The Strategy Block Pointer */ 877 struct strategyblock *ObStrategyBlock; /* Defined in stratdef.h */ 878 879 SHAPEANIMATIONCONTROLLER * ShapeAnimControlBlock; 880 881 struct hmodelcontroller * HModelControlBlock; 882 883 unsigned int SpecialFXFlags; 884 885 } DISPLAYBLOCK; 886 887 888 /* 889 890 Flags 891 892 */ 893 894 #define ObFlag_InRange 0x00000001 895 #define ObFlag_OnScreen 0x00000002 896 #define ObFlag_NotVis 0x00000004 897 898 899 900 901 #define ObFlag_VertexHazing 0x00000020 /* For I_Gouraud, interpolate hue 902 across the polygon */ 903 904 905 #define ObFlag_TypeZ 0x00000080 /* Shape uses Z Sort */ 906 907 908 909 910 #define ObFlag_SortFarZ 0x00008000 /* Z + Radius */ 911 912 #define ObFlag_ArbRot 0x00010000 /* Internal use ONLY */ 913 914 #define ObFlag_MultLSrc 0x00020000 /* Use Multiple Light Sources */ 915 #define ObFlag_NoInfLSrc 0x00040000 /* Ignore Infinite Light Sources */ 916 #define ObFlag_OnlyInfLSrc 0x00080000 /* Only Infinite Light Sources */ 917 918 919 920 921 922 923 #define ObFlag_ZBuffer 0x08000000 /* Request item z-buffering */ 924 925 #define ObFlag_BFCRO 0x10000000 /* Back Face Cull Rot. Optimise */ 926 #define ObFlag_RSP 0x20000000 /* Radius Space Partitioning - 927 requires RFC data in shape */ 928 929 930 #define ObFlag_ParrallelBFC 0x80000000 /* Roxby's scu dsp flag */ 931 932 933 /* 934 935 Flags 2 936 937 */ 938 939 #define ObFlag2_Deallocate 0x00000001 /* Deallocate block at frame end */ 940 #define ObFlag2_ObjLevelHaze 0x00000002 /* Hazing at object level */ 941 942 943 #define ObFlag2_AugZ 0x00000008 /* Augmented Z-Sort */ 944 945 946 947 948 #define ObFlag2_NoBFC 0x00000400 /* Disables Back Face Cull */ 949 950 951 952 953 #define ObFlag2_NotYetPos 0x00080000 /* Internal, for sub-objects */ 954 955 956 #define ObFlag2_NoSubObjectUpdate 0x00200000 /* If you are using your own 957 functions to position and 958 orient sub-objects, set this 959 flag and the sub-object in 960 question will be ignored by 961 the update function */ 962 963 964 965 966 967 968 #define ObFlag2_SortNearZ 0x20000000 /* Z - Radius */ 969 970 971 972 973 #define ObFlag2_SortD 0x80000000 /* Use distance rather than Z */ 974 975 976 977 /* 978 979 Flags 3 980 981 */ 982 983 #define ObFlag3_DynamicModuleObject 0x00000001 /* Allocate module objects 984 around this object as if 985 it were a camera */ 986 987 #define ObFlag3_ObjectSortedItems 0x00000002 /* Used by the Global Sort */ 988 989 #define ObFlag3_NoLightDot 0x00000004 /* Surface/Point is lit the 990 same from all angles */ 991 992 993 #define ObFlag3_Teleport 0x00000040 /* No motion vector! */ 994 995 #define ObFlag3_SurfaceAlignDeluxe 0x00000080 /* Better but slower */ 996 997 #define ObFlag3_PreLit 0x00000100 /* Not source specific */ 998 999 #define ObFlag3_JustCreated 0x00000200 /* Teleport status for just 1000 one frame */ 1001 1002 #define ObFlag3_DontDrawIfOurModuleIsNotVis 0x00000400 /* If the module we 1003 visible, don't 1004 draw us */ 1005 #define ObFlag3_AlwaysDynamic 0x00000800 /* Overrides auto-detect */ 1006 1007 1008 1009 1010 #if SupportMorphing 1011 1012 /* 1013 1014 Morphing Flags 1015 1016 */ 1017 1018 #define mph_flag_play 0x00000001 1019 #define mph_flag_reverse 0x00000002 1020 #define mph_flag_noloop 0x00000004 1021 1022 /* 1023 1024 These four are set so that functions can be informed as to the state of 1025 a sequence. They must be acknowledged and cleared for them to be of any 1026 lasting use. The "start" and "end" flags are always set when the sequence 1027 wraps. Depending on whether the sequence is looping or not, the "looped" or 1028 "finished" flags will be set respectively. 1029 1030 */ 1031 1032 #define mph_flag_start 0x00000008 1033 #define mph_flag_end 0x00000010 1034 #define mph_flag_finished 0x00000020 1035 #define mph_flag_looped 0x00000040 1036 1037 #endif 1038 1039 1040 1041 /* 1042 1043 Standard Points 1044 1045 */ 1046 1047 typedef struct p2d { 1048 1049 VECTOR2D point2d; 1050 1051 } P2D; 1052 1053 typedef struct p3d { 1054 1055 VECTORCH point3d; 1056 1057 } P3D; 1058 1059 /* 1060 1061 Gouraud Points 1062 1063 */ 1064 1065 typedef struct p2d_gouraud { 1066 1067 VECTOR2D point2d; 1068 int i2d; 1069 1070 } P2D_GOURAUD; 1071 1072 typedef struct p3d_gouraud { 1073 1074 VECTORCH point3d; 1075 int i3d; 1076 1077 } P3D_GOURAUD; 1078 1079 /* 1080 1081 Phong Points 1082 1083 */ 1084 1085 typedef struct p2d_phong { 1086 1087 VECTOR2D point2d; 1088 VECTORCH phong_normal2d; 1089 1090 } P2D_PHONG; 1091 1092 1093 typedef struct p3d_phong { 1094 1095 VECTORCH point3d; 1096 VECTORCH phong_normal3d; 1097 1098 } P3D_PHONG; 1099 1100 1101 /* 1102 1103 Texture 2d Points 1104 1105 */ 1106 1107 typedef struct p2d_texture2d { 1108 1109 VECTOR2D point2d; 1110 int u2d_2d; 1111 int v2d_2d; 1112 1113 } P2D_TEXTURE2D; 1114 1115 1116 typedef struct p3d_texture2d { 1117 1118 VECTORCH point3d; 1119 int u3d_2d; 1120 int v3d_2d; 1121 1122 } P3D_TEXTURE2D; 1123 1124 1125 /* 1126 1127 Texture 2d Points - Z-Buffered 1128 1129 */ 1130 1131 #if SupportZBuffering 1132 1133 typedef struct p2d_texture2d_zb { 1134 1135 VECTOR2D point2d; 1136 int u2d_2d; 1137 int v2d_2d; 1138 float z2d_2d; 1139 1140 } P2D_TEXTURE2D_ZB; 1141 1142 1143 typedef struct p3d_texture2d_zb { 1144 1145 VECTORCH point3d; 1146 int u3d_2d; 1147 int v3d_2d; 1148 float z3d_2d; 1149 1150 } P3D_TEXTURE2D_ZB; 1151 1152 #endif 1153 1154 1155 /* 1156 1157 Texture 3d Points 1158 1159 */ 1160 1161 #if support3dtextures 1162 1163 #if int3dtextures 1164 1165 typedef struct p2d_texture3d { 1166 1167 VECTOR2D point2d; 1168 int u2d_tx3d; 1169 int v2d_tx3d; 1170 int z2d_tx3d; 1171 1172 } P2D_TEXTURE3D; 1173 1174 1175 typedef struct p3d_texture3d { 1176 1177 VECTORCH point3d; 1178 int u3d_tx3d; 1179 int v3d_tx3d; 1180 1181 } P3D_TEXTURE3D; 1182 1183 #else 1184 1185 typedef struct p2d_texture3d { 1186 1187 VECTOR2D point2d; 1188 float u2d_tx3d; 1189 float v2d_tx3d; 1190 float z2d_tx3d; 1191 1192 } P2D_TEXTURE3D; 1193 1194 1195 typedef struct p3d_texture3d { 1196 1197 VECTORCH point3d; 1198 int u3d_tx3d; 1199 int v3d_tx3d; 1200 1201 } P3D_TEXTURE3D; 1202 1203 #endif 1204 1205 #endif 1206 1207 /* 1208 1209 Gouraud Texture 2d Points 1210 1211 */ 1212 1213 typedef struct p2d_gouraudtexture2d { 1214 1215 VECTOR2D point2d; 1216 int u2d_2d; 1217 int v2d_2d; 1218 int i2d_2d; 1219 1220 } P2D_GOURAUDTEXTURE2D; 1221 1222 1223 typedef struct p3d_gouraudtexture2d { 1224 1225 VECTORCH point3d; 1226 int u3d_2d; 1227 int v3d_2d; 1228 int i3d_2d; 1229 1230 } P3D_GOURAUDTEXTURE2D; 1231 1232 1233 /* 1234 1235 Gouraud Texture 2d Points - Z-Buffered 1236 1237 */ 1238 1239 #if SupportZBuffering 1240 1241 typedef struct p2d_gouraudtexture2d_zb { 1242 1243 VECTOR2D point2d; 1244 int u2d_gtx2d; 1245 int v2d_gtx2d; 1246 int i2d_gtx2d; 1247 float z2d_gtx2d; 1248 1249 } P2D_GOURAUDTEXTURE2D_ZB; 1250 1251 1252 typedef struct p3d_gouraudtexture2d_zb { 1253 1254 VECTORCH point3d; 1255 int u3d_gtx2d; 1256 int v3d_gtx2d; 1257 int i3d_gtx2d; 1258 float z3d_gtx2d; 1259 1260 } P3D_GOURAUDTEXTURE2D_ZB; 1261 1262 #endif 1263 1264 1265 #if SupportGouraud3dTextures 1266 1267 /* 1268 1269 Gouraud Texture 3d Points 1270 1271 */ 1272 1273 typedef struct p2d_gouraudtexture3d { 1274 1275 VECTOR2D point2d; 1276 float u2d_gtx3d; 1277 float v2d_gtx3d; 1278 float z2d_gtx3d; 1279 int i2d_gtx3d; 1280 1281 } P2D_GOURAUDTEXTURE3D; 1282 1283 1284 typedef struct p3d_gouraudtexture3d { 1285 1286 VECTORCH point3d; 1287 int u3d_gtx3d; 1288 int v3d_gtx3d; 1289 int i3d_gtx3d; 1290 1291 } P3D_GOURAUDTEXTURE3D; 1292 1293 #endif /* SupportGouraud3dTextures */ 1294 1295 1296 1297 /* 1298 1299 Polygon Points. 1300 1301 These are the points as they appear to a Scan Convertor. Item pointers are 1302 cast as these structs by the SC to make their life easier. 1303 1304 */ 1305 1306 1307 /* 1308 1309 I_Polygon 1310 1311 */ 1312 1313 typedef struct i_polygon_pt { 1314 1315 int i_x; 1316 int i_y; 1317 1318 } I_POLYGON_PT; 1319 1320 1321 /* 1322 1323 I_Polygon_ZBuffer 1324 1325 */ 1326 1327 #if ZBufferTest 1328 1329 typedef struct i_polygon_zbuffer_pt { 1330 1331 int i_x; 1332 int i_y; 1333 int i_z; 1334 1335 } I_POLYGON_ZBUFFER_PT; 1336 1337 #endif 1338 1339 #if SupportZBuffering 1340 1341 typedef struct i_polygon_zbuffer_pt { 1342 1343 int i_x; 1344 int i_y; 1345 float i_z; 1346 1347 } I_POLYGON_ZBUFFER_PT; 1348 1349 #endif 1350 1351 1352 /* 1353 1354 I_GouraudPolygon 1355 1356 */ 1357 1358 typedef struct i_gouraudpolygon_pt { 1359 1360 int i_x; 1361 int i_y; 1362 int i_int; 1363 1364 } I_GOURAUDPOLYGON_PT; 1365 1366 1367 /* 1368 1369 I_GouraudPolygon_ZBuffer 1370 1371 */ 1372 1373 #if ZBufferTest 1374 1375 typedef struct i_gouraudpolygon_zbuffer_pt { 1376 1377 int i_x; 1378 int i_y; 1379 int i_int; 1380 int i_gz; 1381 1382 } I_GOURAUDPOLYGON_ZBUFFER_PT; 1383 1384 #endif 1385 1386 #if SupportZBuffering 1387 1388 typedef struct i_gouraudpolygon_zbuffer_pt { 1389 1390 int i_x; 1391 int i_y; 1392 int i_int; 1393 float i_gz; 1394 1395 } I_GOURAUDPOLYGON_ZBUFFER_PT; 1396 1397 #endif 1398 1399 1400 /* 1401 1402 I_PhongPolygon 1403 1404 */ 1405 1406 typedef struct i_phongpolygon_pt { 1407 1408 int i_x; 1409 int i_y; 1410 1411 VECTORCH i_n; 1412 1413 } I_PHONGPOLYGON_PT; 1414 1415 #if SupportZBuffering 1416 1417 typedef struct i_phongpolygon_zbuffer_pt { 1418 1419 int i_x; 1420 int i_y; 1421 1422 VECTORCH i_n; 1423 1424 float i_pz; 1425 1426 } I_PHONGPOLYGON_ZBUFFER_PT; 1427 1428 #endif 1429 1430 1431 /* 1432 1433 I_2dTexturePolygon 1434 1435 */ 1436 1437 typedef struct i_2dtexturepolygon_pt { 1438 1439 int i_x; 1440 int i_y; 1441 1442 int i_u; 1443 int i_v; 1444 1445 } I_2DTEXTUREPOLYGON_PT; 1446 1447 #if SupportZBuffering 1448 1449 typedef struct i_2dtexturepolygon_zbuffer_pt { 1450 1451 int i_x; 1452 int i_y; 1453 1454 int i_u; 1455 int i_v; 1456 1457 float i_tx2dz; 1458 1459 } I_2DTEXTUREPOLYGON_ZBUFFER_PT; 1460 1461 #endif 1462 1463 1464 /* 1465 1466 I_3dTexturePolygon 1467 1468 */ 1469 1470 #if support3dtextures 1471 1472 #if int3dtextures 1473 1474 typedef struct i_3dtexturepolygon_pt { 1475 1476 int i_x; 1477 int i_y; 1478 1479 int i_tx3d_u; 1480 int i_tx3d_v; 1481 int i_tx3d_z; 1482 1483 } I_3DTEXTUREPOLYGON_PT; 1484 1485 #else 1486 1487 typedef struct i_3dtexturepolygon_pt { 1488 1489 int i_x; 1490 int i_y; 1491 1492 float i_tx3d_u; 1493 float i_tx3d_v; 1494 float i_tx3d_z; 1495 1496 } I_3DTEXTUREPOLYGON_PT; 1497 1498 #endif 1499 1500 #if SupportZBuffering 1501 1502 typedef struct i_3dtexturepolygon_zbuffer_pt { 1503 1504 int i_x; 1505 int i_y; 1506 1507 float i_tx3d_u; 1508 float i_tx3d_v; 1509 float i_tx3d_z; 1510 1511 } I_3DTEXTUREPOLYGON_ZBUFFER_PT; 1512 1513 #endif 1514 1515 #endif 1516 1517 1518 /* 1519 1520 I_Gouraud2dTexturePolygon 1521 1522 */ 1523 1524 typedef struct i_gouraud2dtexturepolygon_pt { 1525 1526 int i_x; 1527 int i_y; 1528 1529 int i_u; 1530 int i_v; 1531 1532 int i_i; 1533 1534 } I_GOURAUD2DTEXTUREPOLYGON_PT; 1535 1536 1537 #if SupportZBuffering 1538 1539 typedef struct i_gouraud2dtexturepolygon_zbuffer_pt { 1540 1541 int i_x; 1542 int i_y; 1543 1544 int i_u; 1545 int i_v; 1546 1547 int i_i; 1548 1549 float i_gtx2dz; 1550 1551 } I_GOURAUD2DTEXTUREPOLYGON_ZBUFFER_PT; 1552 1553 #endif 1554 1555 1556 #if SupportGouraud3dTextures 1557 1558 /* 1559 1560 I_Gouraud3dTexturePolygon 1561 1562 */ 1563 1564 typedef struct i_gouraud3dtexturepolygon_pt { 1565 1566 int i_x; 1567 int i_y; 1568 1569 float i_gtx3d_u; 1570 float i_gtx3d_v; 1571 float i_gtx3d_z; 1572 1573 int i_gtx3d_i; 1574 1575 } I_GOURAUD3DTEXTUREPOLYGON_PT; 1576 1577 #endif /* SupportGouraud3dTextures */ 1578 1579 1580 /* 1581 1582 Clip Point Structure. 1583 1584 Points P, S, F and I use this structure. 1585 1586 */ 1587 1588 typedef struct clip_point { 1589 1590 VECTORCH ClipPoint; 1591 VECTORCH ClipNormal; 1592 TEXEL ClipTexel; 1593 int ClipInt; 1594 int ClipZBuffer; 1595 1596 } CLIP_POINT; 1597 1598 1599 #if support3dtextures 1600 1601 #if int3dtextures 1602 1603 typedef struct clip_point_f { 1604 1605 VECTORCH ClipPointF; 1606 VECTORCH ClipNormalF; 1607 TEXELF ClipTexelF; 1608 int ClipIntF; 1609 int ClipZBufferF; 1610 1611 } CLIP_POINT_F; 1612 1613 #else 1614 1615 typedef struct clip_point_f { 1616 1617 VECTORCH ClipPointF; 1618 VECTORCH ClipNormalF; 1619 TEXELF ClipTexelF; 1620 int ClipIntF; 1621 float ClipZBufferF; 1622 1623 } CLIP_POINT_F; 1624 1625 #endif 1626 1627 #endif 1628 1629 1630 #if SupportGouraud3dTextures 1631 1632 typedef struct clip_point_gtx3d { 1633 1634 VECTORCH ClipPointF; 1635 VECTORCH ClipNormalF; 1636 TEXELGTX3D ClipTexelF; 1637 int ClipIntF; 1638 float ClipZBufferF; 1639 1640 } CLIP_POINT_GTX3D; 1641 1642 #endif 1643 1644 1645 1646 1647 /* 1648 1649 Scan Data Blocks. 1650 1651 These are the structures in ScanData[] that the SC outputs. Memory is 1652 allocated from ScanData[] as int* but is cast to the following structures 1653 by the SC for ease of use. 1654 1655 */ 1656 1657 typedef struct i_polygon_scan { 1658 1659 int ips_colour; 1660 int ips_x1; 1661 int ips_x2; 1662 int ips_y; 1663 1664 } I_POLYGON_SCAN; 1665 1666 #if ZBufferTest 1667 1668 typedef struct i_polygon_zbuffer_scan { 1669 1670 int ips_colour; 1671 int ips_x1; 1672 int ips_x2; 1673 int ips_y; 1674 int ips_z1; 1675 int ips_z2; 1676 1677 } I_POLYGON_ZBUFFER_SCAN; 1678 1679 #endif 1680 1681 #if SupportZBuffering 1682 1683 typedef struct i_polygon_zbuffer_scan { 1684 1685 int ips_colour; 1686 int ips_x1; 1687 int ips_x2; 1688 int ips_y; 1689 float ips_z1; 1690 float ips_z2; 1691 1692 } I_POLYGON_ZBUFFER_SCAN; 1693 1694 #endif 1695 1696 1697 typedef struct i_gouraudpolygon_scan { 1698 1699 int igs_c1; 1700 int igs_c2; 1701 1702 int igs_x1; 1703 int igs_x2; 1704 1705 int igs_y; 1706 1707 } I_GOURAUDPOLYGON_SCAN; 1708 1709 #if ZBufferTest 1710 1711 typedef struct i_gouraudpolygon_zbuffer_scan { 1712 1713 int igs_c1; 1714 int igs_c2; 1715 1716 int igs_x1; 1717 int igs_x2; 1718 1719 int igs_y; 1720 1721 int igs_z1; 1722 int igs_z2; 1723 1724 } I_GOURAUDPOLYGON_ZBUFFER_SCAN; 1725 1726 #endif 1727 1728 #if SupportZBuffering 1729 1730 typedef struct i_gouraudpolygon_zbuffer_scan { 1731 1732 int igs_c1; 1733 int igs_c2; 1734 1735 int igs_x1; 1736 int igs_x2; 1737 1738 int igs_y; 1739 1740 float igs_z1; 1741 float igs_z2; 1742 1743 } I_GOURAUDPOLYGON_ZBUFFER_SCAN; 1744 1745 #endif 1746 1747 1748 typedef struct i_phongpolygon_scan { 1749 1750 VECTORCH ips_n1; 1751 VECTORCH ips_n2; 1752 1753 int ips_x1; 1754 int ips_x2; 1755 1756 int ips_y; 1757 1758 } I_PHONGPOLYGON_SCAN; 1759 1760 #if SupportZBuffering 1761 1762 typedef struct i_phongpolygon_zbuffer_scan { 1763 1764 VECTORCH ips_n1; 1765 VECTORCH ips_n2; 1766 1767 int ips_x1; 1768 int ips_x2; 1769 1770 int ips_y; 1771 1772 float ips_z1; 1773 float ips_z2; 1774 1775 } I_PHONGPOLYGON_ZBUFFER_SCAN; 1776 1777 #endif 1778 1779 1780 typedef struct i_2dtexturepolygon_scan { 1781 1782 int i2s_u1; 1783 int i2s_v1; 1784 1785 int i2s_u2; 1786 int i2s_v2; 1787 1788 int i2s_x1; 1789 int i2s_x2; 1790 1791 int i2s_y; 1792 1793 } I_2DTEXTUREPOLYGON_SCAN; 1794 1795 #if SupportZBuffering 1796 1797 typedef struct i_2dtexturepolygon_zbuffer_scan { 1798 1799 int i2s_u1; 1800 int i2s_v1; 1801 1802 int i2s_u2; 1803 int i2s_v2; 1804 1805 int i2s_x1; 1806 int i2s_x2; 1807 1808 int i2s_y; 1809 1810 float i2s_z1; 1811 float i2s_z2; 1812 1813 } I_2DTEXTUREPOLYGON_ZBUFFER_SCAN; 1814 1815 #endif 1816 1817 1818 #if support3dtextures 1819 1820 #if int3dtextures 1821 1822 typedef struct i_3dtexturepolygon_scan { 1823 1824 int i3s_u1; 1825 int i3s_v1; 1826 int i3s_z1; 1827 1828 int i3s_u2; 1829 int i3s_v2; 1830 int i3s_z2; 1831 1832 int i3s_x1; 1833 int i3s_x2; 1834 1835 int i3s_y; 1836 1837 } I_3DTEXTUREPOLYGON_SCAN; 1838 1839 #else 1840 1841 typedef struct i_3dtexturepolygon_scan { 1842 1843 float i3s_u1; 1844 float i3s_v1; 1845 float i3s_z1; 1846 1847 float i3s_u2; 1848 float i3s_v2; 1849 float i3s_z2; 1850 1851 int i3s_x1; 1852 int i3s_x2; 1853 1854 int i3s_y; 1855 1856 } I_3DTEXTUREPOLYGON_SCAN; 1857 1858 #endif 1859 1860 #if SupportZBuffering 1861 1862 typedef struct i_3dtexturepolygon_zbuffer_scan { 1863 1864 float i3s_u1; 1865 float i3s_v1; 1866 float i3s_z1; 1867 1868 float i3s_u2; 1869 float i3s_v2; 1870 float i3s_z2; 1871 1872 int i3s_x1; 1873 int i3s_x2; 1874 1875 int i3s_y; 1876 1877 } I_3DTEXTUREPOLYGON_ZBUFFER_SCAN; 1878 1879 #endif 1880 1881 #endif 1882 1883 1884 typedef struct i_gouraud2dtexturepolygon_scan { 1885 1886 int ig2s_u1; 1887 int ig2s_v1; 1888 int ig2s_c1; 1889 1890 int ig2s_u2; 1891 int ig2s_v2; 1892 int ig2s_c2; 1893 1894 int ig2s_x1; 1895 int ig2s_x2; 1896 1897 int ig2s_y; 1898 1899 } I_GOURAUD2DTEXTUREPOLYGON_SCAN; 1900 1901 #if SupportZBuffering 1902 1903 typedef struct i_gouraud2dtexturepolygon_zbuffer_scan { 1904 1905 int ig2s_u1; 1906 int ig2s_v1; 1907 int ig2s_c1; 1908 1909 int ig2s_u2; 1910 int ig2s_v2; 1911 int ig2s_c2; 1912 1913 int ig2s_x1; 1914 int ig2s_x2; 1915 1916 int ig2s_y; 1917 1918 float ig2s_z1; 1919 float ig2s_z2; 1920 1921 } I_GOURAUD2DTEXTUREPOLYGON_ZBUFFER_SCAN; 1922 1923 #endif 1924 1925 1926 #if SupportGouraud3dTextures 1927 1928 typedef struct i_gouraud3dtexturepolygon_scan { 1929 1930 float ig3s_u1; 1931 float ig3s_v1; 1932 float ig3s_z1; 1933 int ig3s_c1; 1934 1935 float ig3s_u2; 1936 float ig3s_v2; 1937 float ig3s_z2; 1938 int ig3s_c2; 1939 1940 int ig3s_x1; 1941 int ig3s_x2; 1942 1943 int ig3s_y; 1944 1945 } I_GOURAUD3DTEXTUREPOLYGON_SCAN; 1946 1947 #endif /* SupportGouraud3dTextures */ 1948 1949 1950 1951 1952 /* 1953 1954 Functions 1955 1956 */ 1957 1958 void ClearScreen(SCREENDESCRIPTORBLOCK *sdb, int Colour); 1959 1960 1961 void PlatformSpecificShowViewEntry(VIEWDESCRIPTORBLOCK *vdb, SCREENDESCRIPTORBLOCK *sdb); 1962 void PlatformSpecificShowViewExit(VIEWDESCRIPTORBLOCK *vdb, SCREENDESCRIPTORBLOCK *sdb); 1963 void AddShape(DISPLAYBLOCK *dblockptr, VIEWDESCRIPTORBLOCK *VDB_Ptr); 1964 void PrepareVDBForShowView(VIEWDESCRIPTORBLOCK *VDB_Ptr); 1965 1966 1967 void SetupLight( 1968 LIGHTBLOCK *lptr, 1969 int sl_flags, 1970 int sl_type, 1971 VECTORCH *sl_world, 1972 VECTORCH *sl_dir, 1973 int sl_panx, 1974 int sl_pany, 1975 int sl_bright, 1976 int sl_spread, 1977 int sl_range 1978 ); 1979 1980 void UpdateObjectLights(DISPLAYBLOCK *dptr); 1981 1982 DISPLAYBLOCK* ReadMap(MAPHEADER *mapptr); 1983 1984 void MapPostProcessing(DISPLAYBLOCK *dptr); 1985 void ObjectQuatAndMat(DISPLAYBLOCK *dblockptr); 1986 void MapBlockInit(DISPLAYBLOCK *dblockptr); 1987 void MapSetVDB(DISPLAYBLOCK *dptr, MAPSETVDB *mapvdbdata); 1988 1989 #if ProjectSpecificVDBs 1990 void ProjectSpecificVDBDestroy(VIEWDESCRIPTORBLOCK *vdb); 1991 void ProjectSpecificVDBInit(VIEWDESCRIPTORBLOCK *vdb); 1992 #endif 1993 1994 1995 void UpdateGame(void); 1996 1997 1998 1999 2000 2001 SHAPEHEADER* GetShapeData(int shapenum); 2002 2003 2004 void InitialiseObjectBlocks(void); 2005 2006 DISPLAYBLOCK* AllocateObjectBlock(void); 2007 void DeallocateObjectBlock(DISPLAYBLOCK *dblockptr); 2008 2009 DISPLAYBLOCK* CreateActiveObject(void); 2010 int DestroyActiveObject(DISPLAYBLOCK *dblockptr); 2011 2012 2013 void InitialiseStrategyBlocks(void); 2014 struct strategyblock* AllocateStrategyBlock(void); 2015 void DeallocateStrategyBlock(struct strategyblock *sptr); 2016 2017 struct strategyblock* CreateActiveStrategyBlock(void); 2018 int DestroyActiveStrategyBlock(struct strategyblock*dblockptr); 2019 2020 2021 2022 2023 void InitialiseTxAnimBlocks(void); 2024 TXACTRLBLK* AllocateTxAnimBlock(void); 2025 void DeallocateTxAnimBlock(TXACTRLBLK *TxAnimblockptr); 2026 void AddTxAnimBlock(DISPLAYBLOCK *dptr, TXACTRLBLK *taptr); 2027 TXANIMHEADER* GetTxAnimHeaderFromShape(TXACTRLBLK *taptr, int shape); 2028 void UpdateTxAnim(TXANIMHEADER *txah); 2029 void ChangeSequence(TXANIMHEADER *txah_old, TXANIMHEADER *txah_new); 2030 void ControlTextureAnimation(DISPLAYBLOCK *dptr); 2031 2032 2033 2034 2035 2036 int DisplayAndLightBlockDeallocation(void); 2037 2038 2039 void InitialiseLightBlocks(void); 2040 2041 LIGHTBLOCK* AllocateLightBlock(void); 2042 void DeallocateLightBlock(LIGHTBLOCK *lptr); 2043 2044 LIGHTBLOCK* AddLightBlock(DISPLAYBLOCK *dptr, LIGHTBLOCK *lptr_to_add); 2045 void DeleteLightBlock(LIGHTBLOCK *lptr, DISPLAYBLOCK *dptr); 2046 2047 2048 2049 void VDBClipPlanes(VIEWDESCRIPTORBLOCK *vdb); 2050 2051 void MakeClipPlane( 2052 2053 VIEWDESCRIPTORBLOCK *vdb, 2054 CLIPPLANEBLOCK *cpb, 2055 CLIPPLANEPOINTS *cpp); 2056 2057 void SetVDB(VIEWDESCRIPTORBLOCK *vdb, 2058 2059 int fl, 2060 int ty, 2061 2062 int d, 2063 2064 int cx, 2065 int cy, 2066 2067 int prx, 2068 int pry, 2069 int mxp, 2070 2071 int cl, 2072 int cr, 2073 int cu, 2074 int cd, 2075 2076 int h1, 2077 int h2, 2078 int hcolour, 2079 int ambience 2080 ); 2081 2082 2083 void InitialiseVDBs(void); 2084 2085 VIEWDESCRIPTORBLOCK* AllocateVDB(void); 2086 void DeallocateVDB(VIEWDESCRIPTORBLOCK *dblockptr); 2087 2088 VIEWDESCRIPTORBLOCK* CreateActiveVDB(void); 2089 int DestroyActiveVDB(VIEWDESCRIPTORBLOCK *dblockptr); 2090 2091 void PlatformSpecificVDBInit(VIEWDESCRIPTORBLOCK *vdb); 2092 2093 2094 /* CDF 4/2/98 */ 2095 int GetOneOverSin(int a); 2096 /* CDF 4/2/98 */ 2097 int _DotProduct(VECTORCH *v1, VECTORCH *v2); 2098 2099 int DotProduct2d(VECTOR2D *v1, VECTOR2D *v2); 2100 2101 2102 void MakeNormal( 2103 2104 VECTORCH *v1, 2105 VECTORCH *v2, 2106 VECTORCH *v3, 2107 VECTORCH *v4); 2108 2109 void GetNormalVector(VECTORCH *v1, VECTORCH *v2, VECTORCH *v3); 2110 2111 void Normalise(VECTORCH *nvector); 2112 void MNormalise(MATRIXCH *m); 2113 2114 void Normalise2d(VECTOR2D *nvector); 2115 2116 int LineColinearity(LINE *l0, LINE *l1); 2117 2118 void Renormalise(VECTORCH *nvector); 2119 2120 int Magnitude(VECTORCH *v); 2121 2122 2123 2124 int VectorDistance(VECTORCH *v1, VECTORCH *v2); 2125 int OutcodeVectorDistance(VECTORCH *v1, VECTORCH *v2, int d); 2126 2127 void MatrixFromZVector(VECTORCH *v, MATRIXCH *m); 2128 2129 2130 int PointInPolygon(int *point, int *polygon, int c, int ppsize); 2131 2132 void PolyAveragePoint(POLYHEADER *pheader, int *spts, VECTORCH *apt); 2133 2134 int FindShift32(int value, int limit); 2135 int FindShift64(LONGLONGCH *value, LONGLONGCH *limit); 2136 2137 void MaxLONGLONGCH(LONGLONGCH *llarrayptr, int llarraysize, LONGLONGCH *llmax); 2138 2139 int MaxInt(int *iarray, int iarraysize); 2140 int MinInt(int *iarray, int iarraysize); 2141 2142 2143 2144 2145 /* 2146 2147 Some Maths Functions 2148 2149 */ 2150 2151 void CreateEulerMatrix(EULER *e, MATRIXCH *m1); 2152 void CreateEulerVector(EULER *e, VECTORCH *v); 2153 2154 2155 2156 void MatrixMultiply( 2157 2158 MATRIXCH *m1, 2159 MATRIXCH *m2, 2160 MATRIXCH *m3); 2161 2162 void TransposeMatrixCH(MATRIXCH *m1); 2163 2164 void CopyVector(VECTORCH *v1, VECTORCH *v2); 2165 void CopyLocation(VECTORCH *v1, VECTORCH *v2); 2166 2167 2168 void CopyEuler(EULER *e1, EULER *e2); 2169 void CopyMatrix(MATRIXCH *m1, MATRIXCH *m2); 2170 2171 void MakeVector(VECTORCH *v1, VECTORCH *v2, VECTORCH *v3); 2172 void AddVector(VECTORCH *v1, VECTORCH *v2); 2173 void SubVector(VECTORCH *v1, VECTORCH *v2); 2174 void QuatToMat(QUAT *q,MATRIXCH *m); 2175 2176 2177 void _RotateVector( 2178 2179 VECTORCH *v, 2180 MATRIXCH *m); 2181 2182 2183 void _RotateAndCopyVector( 2184 2185 VECTORCH *v1, 2186 VECTORCH *v2, 2187 MATRIXCH *m); 2188 2189 2190 void MakeVectorLocal(VECTORCH *v1, VECTORCH *v2, VECTORCH *v3, MATRIXCH *m); 2191 2192 2193 2194 2195 2196 void MatrixToEuler(MATRIXCH *m, EULER *e); 2197 void MatrixToEuler2(MATRIXCH *m, EULER *e); 2198 2199 int ArcCos(int); 2200 int ArcSin(int); 2201 int ArcTan(int, int); 2202 2203 int FandVD_Distance_2d(VECTOR2D *v0, VECTOR2D *v1); 2204 int FandVD_Distance_3d(VECTORCH *v0, VECTORCH *v1); 2205 2206 int Distance_2d(VECTOR2D *v0, VECTOR2D *v1); 2207 int Distance_3d(VECTORCH *v0, VECTORCH *v1); 2208 2209 2210 /* 2211 2212 Shape Language Functions 2213 2214 Each function requires a pointer to SHAPEINSTR 2215 2216 */ 2217 2218 void SetupShapeLanguage(SHAPEHEADER *shapeheaderptr); 2219 2220 void ShapePointsInstr(SHAPEINSTR *shapeinstrptr); 2221 2222 2223 void ShapeSpritePointsInstr(SHAPEINSTR *shapeinstrptr); 2224 void ShapeSpriteRPointsInstr(SHAPEINSTR *shapeinstrptr); 2225 2226 2227 void BackFaceCullPointOutcodeFlagging(void); 2228 2229 2230 2231 2232 2233 2234 /* 2235 2236 Platform Specific Functions 2237 2238 */ 2239 2240 void InitialiseSystem(void); 2241 void InitialiseRenderer(void); 2242 void ExitSystem(void); 2243 void InitialVideoMode(void); 2244 void RestartLevel(); 2245 void ResetFrameCounter(void); 2246 void FrameCounterHandler(void); 2247 2248 void DirectWriteD3DLine(VECTOR2D* LineStart, VECTOR2D* LineEnd, int LineColour); 2249 void* LoadImageIntoDirectDrawSurface(char *fname, IMAGEHEADER *iheader, 2250 int ImageLoadMode, BOOL Sysmem); 2251 void* LoadImageIntoD3DImmediateSurface(char *fname, IMAGEHEADER *iheader, 2252 int TextureFileType); 2253 void* LoadImageIntoD3DTexture(char *fname, IMAGEHEADER *iheader, 2254 int TextureFileType); 2255 void ReloadImageIntoD3DImmediateSurface(IMAGEHEADER* iheader); 2256 void* ReloadImageIntoD3DTexture(IMAGEHEADER* iheader); 2257 int GetTextureHandle(IMAGEHEADER *imageHeaderPtr); 2258 2259 void* LoadFontIntoDirectDrawSurface(char *fname, IMAGEHEADER *iheader); 2260 void ClearScreen(SCREENDESCRIPTORBLOCK* sdb, int Colour); 2261 2262 void InitGame(void); 2263 void StartGame(void); 2264 void ExitGame(void); 2265 2266 void InitialiseParallelStrategy(void); 2267 void UpdateParallelStrategy(void); 2268 2269 unsigned char* AllocateScreenBuffer(int sbuffersize); 2270 2271 void SetPalette(unsigned char *palette); 2272 2273 void CreatePaletteRemapTable(unsigned char *palette); 2274 unsigned char GetRemappedPaletteColour(int r, int g, int b, int bitsize); 2275 2276 int NearestColour(int rs, int gs, int bs, unsigned char *palette); 2277 2278 #if LoadingMapsShapesAndTexturesEtc 2279 2280 void InitialiseImageHeaders(void); 2281 int LoadImagesForShapes(SHAPEHEADER **shapelist); 2282 2283 #else 2284 2285 int InitialiseTextures(void); 2286 2287 #endif 2288 2289 void MakeShapeTexturesGlobal(SHAPEHEADER *shptr, int TxIndex, int LTxIndex); 2290 void MakeTxAnimFrameTexturesGlobal(SHAPEHEADER *sptr, 2291 POLYHEADER *pheader, 2292 int LTxIndex, int TxIndex); 2293 2294 void SpriteResizing(SHAPEHEADER *sptr); 2295 2296 void FindImageExtents(IMAGEHEADER *ihdr, int numuvs, int *uvdata, IMAGEEXTENTS *e, IMAGEEXTENTS *e_curr); 2297 2298 2299 int GetMVSIndex(TXANIMHEADER *txah, EULER *e); 2300 2301 2302 IMAGEHEADER* GetImageHeader(void); 2303 2304 void* GetTexture(int texindex); 2305 2306 TEXTURE* GetTextureMemory(int txsize); 2307 void ReturnTextureMemory(TEXTURE *txptr); 2308 2309 2310 /* Backdrops */ 2311 2312 #if pc_backdrops 2313 int UpdateBackdrops(SCENE Scene); 2314 int DeallocateBackdrops(SCENE Scene); 2315 int LoadBackdrop(char *image, IMAGEHEADER *ihdr); 2316 #endif 2317 2318 2319 void GetProjectFilename(char *fname, char *image); 2320 2321 2322 void GetDOSFilename(char *fnameptr); 2323 int CompareFilenameCH(char *string1, char *string2); 2324 2325 TEXTURE* LoadImageCH(char *fname, IMAGEHEADER *iheader); 2326 TEXTURE* LoadBMP(char *fname, IMAGEHEADER *iheader); 2327 TEXTURE* LoadPGM(char *fname, IMAGEHEADER *iheader); 2328 int LoadPGMPalette(char *fname, unsigned char *palette); 2329 int LoadPGMPaletteLightingTable(char *filename, unsigned char *palette); 2330 2331 void Create_MIP_Map(IMAGEHEADER *iheader); 2332 2333 2334 int NextLowPower2(int i); 2335 2336 2337 /* User Input */ 2338 2339 void ReadUserInput(void); 2340 2341 void InitMouse(void); 2342 void ReadMouse(void); 2343 2344 2345 2346 typedef struct mousedata { 2347 2348 short MouseDataX; 2349 short MouseDataY; 2350 unsigned short MouseDataButton; 2351 short MouseDataVelX; 2352 short MouseDataVelY; 2353 2354 } MOUSEDATA; 2355 2356 2357 void ReadKeyboard(void); 2358 2359 2360 void WaitForReturn(void); 2361 2362 void CursorHome(void); 2363 2364 void InitialiseItemLists(void); 2365 2366 void InitialiseItemPointers(void); 2367 void InitialiseItemData(void); 2368 2369 void* AllocateItemData(int itemsize); 2370 2371 2372 int GetZForZBuffer(int z); 2373 void FlushZBuffer(VIEWDESCRIPTORBLOCK *vdb); 2374 2375 2376 /* Draw Item */ 2377 2378 void Draw_Item_GouraudPolygon(int *itemptr); 2379 void Draw_Item_2dTexturePolygon(int *itemptr); 2380 void Draw_Item_Gouraud2dTexturePolygon(int *itemptr); 2381 void Draw_Item_Gouraud3dTexturePolygon(int *itemptr); 2382 2383 void Draw_Item_ZB_GouraudPolygon(int *itemptr); 2384 void Draw_Item_ZB_2dTexturePolygon(int *itemptr); 2385 void Draw_Item_ZB_Gouraud2dTexturePolygon(int *itemptr); 2386 void Draw_Item_ZB_Gouraud3dTexturePolygon(int *itemptr); 2387 2388 2389 /* 2390 2391 Texture Animation 2392 2393 */ 2394 2395 int* GetTxAnimArrayZ(int shape, int item); 2396 TXANIMHEADER* GetTxAnimDataZ(int shape, int item, int sequence); 2397 2398 #if SupportBSP 2399 TXANIMHEADER* GetTxAnimDataBSP(int shape, int node, int item, int sequence); 2400 #endif 2401 2402 2403 int GT_LL(LONGLONGCH *a, LONGLONGCH *b); 2404 int LT_LL(LONGLONGCH *a, LONGLONGCH *b); 2405 2406 2407 void SetFastRandom(void); 2408 int FastRandom(void); 2409 2410 2411 void DrawPalette(int x0, int y0, int x1, int y1); 2412 2413 2414 /* 2415 2416 Equates and Enums 2417 2418 */ 2419 2420 typedef enum { 2421 2422 Boundary_Left, 2423 Boundary_Right, 2424 Boundary_Up, 2425 Boundary_Down, 2426 Boundary_Z 2427 2428 } CLIP2DBOUNDARIES; 2429 2430 2431 2432 #if SupportMorphing 2433 2434 void UpdateMorphing(MORPHCTRL *mcptr); 2435 void UpdateMorphingDptr(DISPLAYBLOCK *dptr); 2436 void GetMorphDisplay(MORPHDISPLAY *md, DISPLAYBLOCK *dptr); 2437 void CopyMorphCtrl(MORPHCTRL *src, MORPHCTRL *dst); 2438 2439 VECTORCH* GetMorphedPts(DISPLAYBLOCK *dptr, MORPHDISPLAY *md); 2440 2441 #if LazyEvaluationForMorphing 2442 void FreeMorphArrays(void); 2443 #endif 2444 2445 #endif 2446 2447 2448 2449 2450 2451 2452 2453 2454 /* KJL 15:07:39 01/08/97 - Returns the magnitude of the 2455 cross product of two vectors a and b. */ 2456 int MagnitudeOfCrossProduct(VECTORCH *a, VECTORCH *b); 2457 2458 /* KJL 15:08:01 01/08/97 - sets the vector c to be the 2459 cross product of the vectors a and b. */ 2460 void CrossProduct(VECTORCH *a, VECTORCH *b, VECTORCH *c); 2461 2462 /* KJL 12:01:08 7/16/97 - returns the magnitude of a vector - max error about 13%, though average error 2463 less than half this. Very fast compared to other approaches. */ 2464 int Approximate3dMagnitude(VECTORCH *v); 2465 2466 2467 2468 2469 2470 2471 2472 2473 #ifdef __cplusplus 2474 2475 }; 2476 2477 #endif 2478 2479 2480 2481 2482 #endif 2483