1 #ifndef _chnkload_h_ 2 #define _chnkload_h_ 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 #include "system.h" 9 #include "equates.h" 10 #include "platform.h" 11 #include "shape.h" 12 #include "prototyp.h" 13 #include "module.h" 14 15 extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock; 16 17 #define GLS_NOTINLIST (-1) 18 19 /////////////////// 20 // RIF Loading, etc 21 /////////////////// 22 23 typedef struct _RifHandle * RIFFHANDLE; 24 #define INVALID_RIFFHANDLE 0 25 26 // flags - project specific ones start at lsb 27 // - generic ones to start from msb 28 29 #define CCF_NOMORPH 0x80000000 30 31 typedef enum UVCoordType 32 { 33 UVC_SPRITE_U, 34 UVC_SPRITE_V, 35 UVC_POLY_U, 36 UVC_POLY_V, 37 38 } UVCOORDTYPE; 39 40 // Note: for aesthetic reasons, macros enable one to have all one's fuctions in lower case or captialized, to suit one's style! 41 42 // For clarity, functions which are to be defined in project specific files 43 // are here declared with extern 44 45 ///////////////////////////////////////// 46 // Functions which operate on RIFFHANDLEs 47 ///////////////////////////////////////// 48 49 // load a rif file into memory 50 RIFFHANDLE load_rif (const char * fname); 51 RIFFHANDLE load_rif_non_env (const char * fname); 52 #define LoadRIF(s) load_rif(s) 53 54 // deallocate the shapes, unload the rif, close the handle 55 void undo_rif_load (RIFFHANDLE); 56 #define UndoRIFLoad(h) undo_rif_load(h) 57 58 // deallocate the shapes copied from the rif 59 void deallocate_loaded_shapes (RIFFHANDLE); 60 #define DeallocateLoadedShapes(h) deallocate_loaded_shapes(h) 61 62 // unloads the rif but keeps the handle and associated copied shapes 63 void unload_rif (RIFFHANDLE); 64 #define UnloadRIF(h) unload_rif(h); 65 66 // close the handle - performs tidying up and memory deallocation 67 void close_rif_handle (RIFFHANDLE); 68 #define CloseRIFHandle(h) close_rif_handle(h) 69 70 // load textures for environment 71 BOOL load_rif_bitmaps (RIFFHANDLE, int flags); 72 #define LoadRIFBitmaps(h,f) load_rif_bitmaps(h,f) 73 74 // set the quantization event depending on CL_RIFFImage::game_mode 75 BOOL set_quantization_event(RIFFHANDLE, int flags); 76 #define SetQuantizationEvent(h,f) set_quantization_event(h,f) 77 78 // copy palette 79 BOOL copy_rif_palette (RIFFHANDLE, int flags); 80 #define CopyRIFPalette(h,f) copy_rif_palette(h,f) 81 82 // copy texture lighting table 83 BOOL copy_rif_tlt (RIFFHANDLE, int flags); 84 #define CopyRIFTLT(h,f) copy_rif_tlt(h,f) 85 86 // copy palette remap table (15-bit) - post_process_shape may use it 87 BOOL get_rif_palette_remap_table (RIFFHANDLE, int flags); 88 #define GetRIFPaletteRemapTable(h,f) get_rif_palette_remap_table(h,f) 89 90 // copy one named shape or sprite; does not put in main shape list, needs deallocating 91 SHAPEHEADER * CopyNamedShapePtr (RIFFHANDLE, char const * shapename); 92 #define copy_named_shape_ptr(h,s) CopyNamedShapePtr(h,s) 93 94 // copy one named shape or sprite; put it in the main shape list 95 int CopyNamedShapeMSL (RIFFHANDLE, char const * shapename); 96 #define copy_named_shape_msl(h,s) CopyNamedShapeMSL(h,s) 97 98 //////////////////////////////////////////////////////////////////////// 99 // Functions which do not operate on RIFFHANDLEs and may become obsolete 100 //////////////////////////////////////////////////////////////////////// 101 102 // these functions work on the current rif; they only remain for historical reasons 103 extern RIFFHANDLE current_rif_handle; 104 // returns NULL on fail; does not put it in the mainshapelist 105 SHAPEHEADER * CopyNamedShape (char const * shapename); 106 107 ///////////////////////////////////////////// 108 // Functions for handling the main shape list 109 ///////////////////////////////////////////// 110 111 // reserves the next avaialbe position in the main shape list and returns it 112 extern int GetMSLPos(void); 113 #define get_msl_pos() GetMSLPos() 114 115 // frees a position in the main shape list 116 extern void FreeMSLPos(int); 117 #define free_msl_pos(i) FreeMSLPos(i) 118 119 //////////////////////////////////////////////// 120 // Functions retrieving data about loaded shapes 121 //////////////////////////////////////////////// 122 123 // gets the main shape list position of a shape loaded into the msl 124 int GetLoadedShapeMSL(char const * shapename); 125 #define get_loaded_shape_msl(s) GetLoadedShapeMSL(s) 126 // ditto, but returns a pointer; the shape need not be in the msl 127 SHAPEHEADER * GetLoadedShapePtr(char const * shapename); 128 #define get_loaded_shape_ptr(s) GetLoadedShapePtr(s) 129 130 // gets name of shape from msl pos 131 char const * GetMSLLoadedShapeName(int listpos); 132 #define get_msl_loaded_shape_name(i) GetMSLLoadedShapeName(i) 133 // gets name of shape from pointer; the shape need not be in msl 134 char const * GetPtrLoadedShapeName(SHAPEHEADER *); 135 #define get_ptr_loaded_shape_name(p) GetPtrLoadedShapeName(p) 136 137 // free a reference to a named shape if it exists - not necessary since these are all tidied up 138 void FreeShapeNameReference(SHAPEHEADER * shptr); 139 #define free_shape_name_reference(p) FreeShapeNameReference(p) 140 141 ////////////////////////////////////////////////////////////////////////////// 142 // Initializing, deallocating of shapes, mainly hooks for project specific fns 143 ////////////////////////////////////////////////////////////////////////////// 144 145 // perform initial post processing on shape just after loading 146 // note that the copy named shape functions will not call this 147 extern void post_process_shape (SHAPEHEADER *); 148 #define PostProcessShape(p) post_process_shape(p) 149 150 // hook to perhaps scale the uv coordinates - should return new value 151 extern int ProcessUVCoord(RIFFHANDLE,UVCOORDTYPE,int uv_value,int image_num); 152 #define process_uv_coord(h,t,u,i) ProcessUVCoord(h,t,u,i) 153 154 // delete a shape by the shapeheader 155 void DeallocateLoadedShapePtr(SHAPEHEADER *); 156 #define deallocate_loaded_shape_ptr(h,p) DeallocateLoadedShapePtr(h,p) 157 158 // delete a shape by the shape list number 159 void DeallocateLoadedShapeMSL(RIFFHANDLE, int); 160 #define deallocate_loaded_shape_msl(h,i) DeallocateLoadedShapeMSL(h,i) 161 162 // your function could perform any extra tidying up you need 163 extern void DeallocateLoadedShapeheader(SHAPEHEADER *); 164 #define deallocate_loaded_shapeheader(p) DeallocateLoadedShapeHeader(p) 165 166 // your function should call this function which undoes the allocation done when copied from rif data 167 void DeallocateRifLoadedShapeheader(SHAPEHEADER *); 168 #define deallocate_rif_loaded_shapeheader(p) DeallocateRifLoadedShapeHeader(p) 169 170 /////// 171 // Misc 172 /////// 173 174 // return TRUE if the poly item type corresponds to a textured polygon 175 BOOL is_textured(int); 176 #define IsTextured(i) is_textured(i) 177 178 ///////////////////// 179 // Rif loader globals 180 ///////////////////// 181 182 extern unsigned char const * PaletteMapTable; 183 184 ///////////////// 185 // Engine globals 186 ///////////////// 187 188 extern int start_of_loaded_shapes; 189 190 extern unsigned char *TextureLightingTable; 191 192 extern SHAPEHEADER ** mainshapelist; 193 194 extern MAPHEADER Map[]; 195 196 extern MAPBLOCK8 Player_and_Camera_Type8[]; 197 extern MAPBLOCK6 Empty_Landscape_Type6; 198 extern MAPBLOCK6 Empty_Object_Type6; 199 extern MAPBLOCK6 Term_Type6; 200 201 extern unsigned char TestPalette[]; 202 203 extern unsigned char LPTestPalette[]; /* to cast to lp*/ 204 205 #if 0 206 extern int NumImages; /* # current images */ 207 extern IMAGEHEADER *ImageHeaderPtrs[]; /* Ptrs to Image Header Blocks */ 208 extern IMAGEHEADER ImageHeaderArray[]; /* Array of Image Headers */ 209 extern IMAGEHEADER *NextFreeImageHeaderPtr; 210 #endif 211 212 #if SupportModules 213 214 extern SCENEMODULE MainScene; 215 extern MODULE Empty_Module; 216 extern MODULE Term_Module; 217 218 extern MODULEMAPBLOCK Empty_Module_Map; 219 220 #endif 221 222 #ifdef __cplusplus 223 224 } 225 226 #endif 227 228 #endif 229