]> icculus.org git repositories - btb/d2x.git/blob - main/bm.c
portability
[btb/d2x.git] / main / bm.c
1 /* $ Id: $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Bitmap and palette loading functions.
18  *
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <conf.h>
24 #endif
25
26 #include <stdio.h>
27 #include <stdlib.h>
28
29 #include "pstypes.h"
30 #include "inferno.h"
31 #include "gr.h"
32 #include "bm.h"
33 #include "u_mem.h"
34 #include "mono.h"
35 #include "error.h"
36 #include "object.h"
37 #include "vclip.h"
38 #include "effects.h"
39 #include "polyobj.h"
40 #include "wall.h"
41 #include "textures.h"
42 #include "game.h"
43 #ifdef NETWORK
44 #include "multi.h"
45 #endif
46 #include "iff.h"
47 #include "cfile.h"
48 #include "powerup.h"
49 #include "sounds.h"
50 #include "piggy.h"
51 #include "aistruct.h"
52 #include "robot.h"
53 #include "weapon.h"
54 #include "gauges.h"
55 #include "player.h"
56 #include "endlevel.h"
57 #include "cntrlcen.h"
58 #include "byteswap.h"
59 #include "makesig.h"
60
61 ubyte Sounds[MAX_SOUNDS];
62 ubyte AltSounds[MAX_SOUNDS];
63
64 #ifdef EDITOR
65 int Num_total_object_types;
66 byte    ObjType[MAX_OBJTYPE];
67 byte    ObjId[MAX_OBJTYPE];
68 fix     ObjStrength[MAX_OBJTYPE];
69 #endif
70
71 //for each model, a model number for dying & dead variants, or -1 if none
72 int Dying_modelnums[MAX_POLYGON_MODELS];
73 int Dead_modelnums[MAX_POLYGON_MODELS];
74
75 //the polygon model number to use for the marker
76 int     Marker_model_num = -1;
77
78 //right now there's only one player ship, but we can have another by 
79 //adding an array and setting the pointer to the active ship.
80 player_ship only_player_ship,*Player_ship=&only_player_ship;
81
82 //----------------- Miscellaneous bitmap pointers ---------------
83 int                                     Num_cockpits = 0;
84 bitmap_index            cockpit_bitmap[N_COCKPIT_BITMAPS];
85
86 //---------------- Variables for wall textures ------------------
87 int                                     Num_tmaps;
88 tmap_info                       TmapInfo[MAX_TEXTURES];
89
90 //---------------- Variables for object textures ----------------
91
92 int                                     First_multi_bitmap_num=-1;
93
94 bitmap_index            ObjBitmaps[MAX_OBJ_BITMAPS];
95 ushort                          ObjBitmapPtrs[MAX_OBJ_BITMAPS];         // These point back into ObjBitmaps, since some are used twice.
96
97 /*
98  * reads a tmap_info structure from a CFILE
99  */
100 void tmap_info_read(tmap_info *ti, CFILE *fp)
101 {
102         ti->flags = cfile_read_byte(fp);
103         ti->pad[0] = cfile_read_byte(fp);
104         ti->pad[1] = cfile_read_byte(fp);
105         ti->pad[2] = cfile_read_byte(fp);
106         ti->lighting = cfile_read_fix(fp);
107         ti->damage = cfile_read_fix(fp);
108         ti->eclip_num = cfile_read_short(fp);
109         ti->destroyed = cfile_read_short(fp);
110         ti->slide_u = cfile_read_short(fp);
111         ti->slide_v = cfile_read_short(fp);
112 }
113
114 #ifdef MACINTOSH
115
116 #ifdef SHAREWARE
117 extern int exit_modelnum,destroyed_exit_modelnum, Num_bitmap_files;
118 int N_ObjBitmaps, extra_bitmap_num;
119
120 bitmap_index exitmodel_bm_load_sub( char * filename )
121 {
122         bitmap_index bitmap_num;
123         grs_bitmap * new;
124         ubyte newpal[256*3];
125         int i, iff_error;               //reference parm to avoid warning message
126
127         bitmap_num.index = 0;
128
129         MALLOC( new, grs_bitmap, 1 );
130         iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
131         new->bm_handle=0;
132         if (iff_error != IFF_NO_ERROR)          {
133                 Error("Error loading exit model bitmap <%s> - IFF error: %s",filename,iff_errormsg(iff_error));
134         }
135         
136         if ( iff_has_transparency )
137                 gr_remap_bitmap_good( new, newpal, iff_transparent_color, 254 );
138         else
139                 gr_remap_bitmap_good( new, newpal, -1, 254 );
140
141         new->avg_color = 0;     //compute_average_pixel(new);
142
143         bitmap_num.index = extra_bitmap_num;
144
145         GameBitmaps[extra_bitmap_num++] = *new;
146         
147         d_free( new );
148         return bitmap_num;
149 }
150
151 grs_bitmap *load_exit_model_bitmap(char *name)
152 {
153         Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
154
155         {
156                 ObjBitmaps[N_ObjBitmaps] = exitmodel_bm_load_sub(name);
157                 if (GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_w!=64 || GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_h!=64)
158                         Error("Bitmap <%s> is not 64x64",name);
159                 ObjBitmapPtrs[N_ObjBitmaps] = N_ObjBitmaps;
160                 N_ObjBitmaps++;
161                 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
162                 return &GameBitmaps[ObjBitmaps[N_ObjBitmaps-1].index];
163         }
164 }
165
166 void load_exit_models()
167 {
168         CFILE *exit_hamfile;
169         int i, j;
170         ubyte pal[768];
171         int start_num;
172
173         start_num = N_ObjBitmaps;
174         extra_bitmap_num = Num_bitmap_files;
175         load_exit_model_bitmap("steel1.bbm");
176         load_exit_model_bitmap("rbot061.bbm");
177         load_exit_model_bitmap("rbot062.bbm");
178
179         load_exit_model_bitmap("steel1.bbm");
180         load_exit_model_bitmap("rbot061.bbm");
181         load_exit_model_bitmap("rbot063.bbm");
182
183         exit_hamfile = cfopen(":Data:exit.ham","rb");
184
185         exit_modelnum = N_polygon_models++;
186         destroyed_exit_modelnum = N_polygon_models++;
187
188 #ifndef MACINTOSH
189         cfread( &Polygon_models[exit_modelnum], sizeof(polymodel), 1, exit_hamfile );
190         cfread( &Polygon_models[destroyed_exit_modelnum], sizeof(polymodel), 1, exit_hamfile );
191 #else
192         for (i = exit_modelnum; i <= destroyed_exit_modelnum; i++) {
193                 Polygon_models[i].n_models = cfile_read_int(exit_hamfile);
194                 Polygon_models[i].model_data_size = cfile_read_int(exit_hamfile);
195                 Polygon_models[i].model_data = (ubyte *)read_int_swap(exit_hamfile);
196                 for (j = 0; j < MAX_SUBMODELS; j++)
197                         Polygon_models[i].submodel_ptrs[j] = cfile_read_int(exit_hamfile);
198                 for (j = 0; j < MAX_SUBMODELS; j++)
199                         cfile_read_vector(&(Polygon_models[i].submodel_offsets), exit_hamfile);
200                 for (j = 0; j < MAX_SUBMODELS; j++)
201                         cfile_read_vector(&(Polygon_models[i].submodel_norms), exit_hamfile);
202                 for (j = 0; j < MAX_SUBMODELS; j++)
203                         cfile_read_vector(&(Polygon_models[i].submodel_pnts), exit_hamfile);
204                 for (j = 0; j < MAX_SUBMODELS; j++)
205                         Polygon_models[i].submodel_rads[j] = cfile_read_fix(exit_hamfile);
206                 for (j = 0; j < MAX_SUBMODELS; j++)
207                         Polygon_models[i].submodel_parents[j] = cfile_read_byte(exit_hamfile);
208                 for (j = 0; j < MAX_SUBMODELS; j++)
209                         cfile_read_vector(&(Polygon_models[i].submodel_mins), exit_hamfile);
210                 for (j = 0; j < MAX_SUBMODELS; j++)
211                         cfile_read_vector(&(Polygon_models[i].submodel_maxs), exit_hamfile);
212                 cfile_read_vector(&(Polygon_models[i].mins), exit_hamfile);
213                 cfile_read_vector(&(Polygon_models[i].maxs), exit_hamfile);
214                 Polygon_models[i].rad = cfile_read_fix(exit_hamfile);           
215                 Polygon_models[i].n_textures = cfile_read_byte(exit_hamfile);
216                 Polygon_models[i].first_texture = cfile_read_short(exit_hamfile);
217                 Polygon_models[i].simpler_model = cfile_read_byte(exit_hamfile);
218         }
219         Polygon_models[exit_modelnum].first_texture = start_num;
220         Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3;
221 #endif
222
223         Polygon_models[exit_modelnum].model_data = d_malloc(Polygon_models[exit_modelnum].model_data_size);
224         Assert( Polygon_models[exit_modelnum].model_data != NULL );
225         cfread( Polygon_models[exit_modelnum].model_data, sizeof(ubyte), Polygon_models[exit_modelnum].model_data_size, exit_hamfile );
226         #ifdef MACINTOSH
227         swap_polygon_model_data(Polygon_models[exit_modelnum].model_data);
228         #endif
229         g3_init_polygon_model(Polygon_models[exit_modelnum].model_data);
230
231         Polygon_models[destroyed_exit_modelnum].model_data = d_malloc(Polygon_models[destroyed_exit_modelnum].model_data_size);
232         Assert( Polygon_models[destroyed_exit_modelnum].model_data != NULL );
233         cfread( Polygon_models[destroyed_exit_modelnum].model_data, sizeof(ubyte), Polygon_models[destroyed_exit_modelnum].model_data_size, exit_hamfile );
234         #ifdef MACINTOSH
235         swap_polygon_model_data(Polygon_models[destroyed_exit_modelnum].model_data);
236         #endif
237         g3_init_polygon_model(Polygon_models[destroyed_exit_modelnum].model_data);
238
239         cfclose(exit_hamfile);
240
241 }
242 #endif          // SHAREWARE
243
244 #endif          // MACINTOSH
245
246 //-----------------------------------------------------------------
247 // Read data from piggy.
248 // This is called when the editor is OUT.  
249 // If editor is in, bm_init_use_table() is called.
250 int bm_init()
251 {
252         init_polygon_models();
253         if (! piggy_init())                             // This calls bm_read_all
254                 Error("Cannot open pig and/or ham file");
255
256         piggy_read_sounds();
257
258         #ifdef SHAREWARE
259         init_endlevel();                //this is in bm_init_use_tbl(), so I gues it goes here
260         #endif
261
262         return 0;
263 }
264
265 void bm_read_all(CFILE * fp)
266 {
267         int i,t;
268
269         NumTextures = cfile_read_int(fp);
270         for (i = 0; i < NumTextures; i++)
271                 bitmap_index_read(&Textures[i], fp);
272         for (i = 0; i < NumTextures; i++)
273                 tmap_info_read(&TmapInfo[i], fp);
274
275         t = cfile_read_int(fp); 
276         cfread( Sounds, sizeof(ubyte), t, fp );
277         cfread( AltSounds, sizeof(ubyte), t, fp );
278
279         Num_vclips = cfile_read_int(fp);
280         for (i = 0; i < Num_vclips; i++)
281                 vclip_read(&Vclip[i], fp);
282
283         Num_effects = cfile_read_int(fp);
284         for (i = 0; i < Num_effects; i++)
285                 eclip_read(&Effects[i], fp);
286
287         Num_wall_anims = cfile_read_int(fp);
288         for (i = 0; i < Num_wall_anims; i++)
289                 wclip_read(&WallAnims[i], fp);
290
291         N_robot_types = cfile_read_int(fp);
292         for (i = 0; i < N_robot_types; i++)
293                 robot_info_read(&Robot_info[i], fp);
294
295         N_robot_joints = cfile_read_int(fp);
296         for (i = 0; i < N_robot_joints; i++)
297                 jointpos_read(&Robot_joints[i], fp);
298
299         N_weapon_types = cfile_read_int(fp);
300         for (i = 0; i < N_weapon_types; i++)
301                 weapon_info_read(&Weapon_info[i], fp);
302
303         N_powerup_types = cfile_read_int(fp);
304         for (i = 0; i < N_powerup_types; i++)
305                 powerup_type_info_read(&Powerup_info[i], fp);
306         
307         N_polygon_models = cfile_read_int(fp);
308         for (i = 0; i < N_polygon_models; i++)
309                 polymodel_read(&Polygon_models[i], fp);
310
311         for (i=0; i<N_polygon_models; i++ )     {
312                 Polygon_models[i].model_data = d_malloc(Polygon_models[i].model_data_size);
313                 Assert( Polygon_models[i].model_data != NULL );
314                 cfread( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
315 #ifdef WORDS_BIGENDIAN
316                 swap_polygon_model_data(Polygon_models[i].model_data);
317 #endif
318                 g3_init_polygon_model(Polygon_models[i].model_data);
319         }
320
321         for (i = 0; i < N_polygon_models; i++)
322                 Dying_modelnums[i] = cfile_read_int(fp);
323         for (i = 0; i < N_polygon_models; i++)
324                 Dead_modelnums[i] = cfile_read_int(fp);
325
326         t = cfile_read_int(fp);
327         for (i = 0; i < t; i++)
328                 bitmap_index_read(&Gauges[i], fp);
329         for (i = 0; i < t; i++)
330                 bitmap_index_read(&Gauges_hires[i], fp);
331
332         t = cfile_read_int(fp);
333         for (i = 0; i < t; i++)
334                 bitmap_index_read(&ObjBitmaps[i], fp);
335         for (i = 0; i < t; i++)
336                 ObjBitmapPtrs[i] = cfile_read_short(fp);
337
338 #ifdef SHAREWARE
339         N_ObjBitmaps = t;
340 #endif
341
342         player_ship_read(&only_player_ship, fp);
343
344         Num_cockpits = cfile_read_int(fp);
345         for (i = 0; i < Num_cockpits; i++)
346                 bitmap_index_read(&cockpit_bitmap[i], fp);
347
348 //@@    cfread( &Num_total_object_types, sizeof(int), 1, fp );
349 //@@    cfread( ObjType, sizeof(byte), Num_total_object_types, fp );
350 //@@    cfread( ObjId, sizeof(byte), Num_total_object_types, fp );
351 //@@    cfread( ObjStrength, sizeof(fix), Num_total_object_types, fp );
352
353         First_multi_bitmap_num = cfile_read_int(fp);
354
355         Num_reactors = cfile_read_int(fp);
356         for (i = 0; i < Num_reactors; i++)
357                 reactor_read(&Reactors[i], fp);
358
359         Marker_model_num = cfile_read_int(fp);
360
361         //@@cfread( &N_controlcen_guns, sizeof(int), 1, fp );
362         //@@cfread( controlcen_gun_points, sizeof(vms_vector), N_controlcen_guns, fp );
363         //@@cfread( controlcen_gun_dirs, sizeof(vms_vector), N_controlcen_guns, fp );
364
365         #ifdef SHAREWARE
366         exit_modelnum = cfile_read_int(fp);
367         destroyed_exit_modelnum = cfile_read_int(fp);
368         #endif
369
370 }
371
372
373 //these values are the number of each item in the release of d2
374 //extra items added after the release get written in an additional hamfile
375 #define N_D2_ROBOT_TYPES                66
376 #define N_D2_ROBOT_JOINTS               1145
377 #define N_D2_POLYGON_MODELS             166
378 #define N_D2_OBJBITMAPS                 422
379 #define N_D2_OBJBITMAPPTRS              502
380 #define N_D2_WEAPON_TYPES               62
381
382 //type==1 means 1.1, type==2 means 1.2 (with weaons)
383 void bm_read_extra_robots(char *fname,int type)
384 {
385         CFILE *fp;
386         int t,i;
387         int version;
388         
389         #ifdef MACINTOSH
390                 ulong varSave = 0;
391         #endif
392
393         fp = cfopen(fname,"rb");
394
395         if (type == 2) {
396                 int sig;
397
398                 sig = cfile_read_int(fp);
399                 if (sig != MAKE_SIG('X','H','A','M'))
400                         return;
401                 version = cfile_read_int(fp);
402         }
403         else
404                 version = 0;
405
406         //read extra weapons
407
408         t = cfile_read_int(fp);
409         N_weapon_types = N_D2_WEAPON_TYPES+t;
410         if (N_weapon_types >= MAX_WEAPON_TYPES)
411                 Error("Too many weapons (%d) in <%s>.  Max is %d.",t,fname,MAX_WEAPON_TYPES-N_D2_WEAPON_TYPES);
412         for (i = N_D2_WEAPON_TYPES; i < t + N_D2_WEAPON_TYPES; i++)
413                 weapon_info_read(&Weapon_info[i], fp);
414
415         //now read robot info
416
417         t = cfile_read_int(fp);
418         N_robot_types = N_D2_ROBOT_TYPES+t;
419         if (N_robot_types >= MAX_ROBOT_TYPES)
420                 Error("Too many robots (%d) in <%s>.  Max is %d.",t,fname,MAX_ROBOT_TYPES-N_D2_ROBOT_TYPES);
421         for (i = N_D2_ROBOT_TYPES; i < t + N_D2_ROBOT_TYPES; i++)
422                 robot_info_read(&Robot_info[i], fp);
423         
424         t = cfile_read_int(fp);
425         N_robot_joints = N_D2_ROBOT_JOINTS+t;
426         if (N_robot_joints >= MAX_ROBOT_JOINTS)
427                 Error("Too many robot joints (%d) in <%s>.  Max is %d.",t,fname,MAX_ROBOT_JOINTS-N_D2_ROBOT_JOINTS);
428         for (i = N_D2_ROBOT_JOINTS; i < t + N_D2_ROBOT_JOINTS; i++)
429                 jointpos_read(&Robot_joints[i], fp);
430         
431         t = cfile_read_int(fp);
432         N_polygon_models = N_D2_POLYGON_MODELS+t;
433         if (N_polygon_models >= MAX_POLYGON_MODELS)
434                 Error("Too many polygon models (%d) in <%s>.  Max is %d.",t,fname,MAX_POLYGON_MODELS-N_D2_POLYGON_MODELS);
435         for (i = N_D2_POLYGON_MODELS; i < t + N_D2_POLYGON_MODELS; i++)
436                 polymodel_read(&Polygon_models[i], fp);
437
438         for (i=N_D2_POLYGON_MODELS; i<N_polygon_models; i++ )
439         {
440                 Polygon_models[i].model_data = d_malloc(Polygon_models[i].model_data_size);
441                 Assert( Polygon_models[i].model_data != NULL );
442                 cfread( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
443                 
444 #ifdef WORDS_BIGENDIAN
445                 swap_polygon_model_data(Polygon_models[i].model_data);
446 #endif
447                 
448                 g3_init_polygon_model(Polygon_models[i].model_data);
449         }
450
451         for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
452                 Dying_modelnums[i] = cfile_read_int(fp);
453         for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
454                 Dead_modelnums[i] = cfile_read_int(fp);
455
456         t = cfile_read_int(fp);
457         if (N_D2_OBJBITMAPS+t >= MAX_OBJ_BITMAPS)
458                 Error("Too many object bitmaps (%d) in <%s>.  Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPS);
459         for (i = N_D2_OBJBITMAPS; i < (N_D2_OBJBITMAPS + t); i++)
460                 bitmap_index_read(&ObjBitmaps[i], fp);
461
462         t = cfile_read_int(fp);
463         if (N_D2_OBJBITMAPPTRS+t >= MAX_OBJ_BITMAPS)
464                 Error("Too many object bitmap pointers (%d) in <%s>.  Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPPTRS);
465         for (i = N_D2_OBJBITMAPPTRS; i < (N_D2_OBJBITMAPPTRS + t); i++)
466                 ObjBitmapPtrs[i] = cfile_read_short(fp);
467
468         cfclose(fp);
469 }
470
471 extern void change_filename_extension( char *dest, char *src, char *new_ext );
472
473 int Robot_replacements_loaded = 0;
474
475 void load_robot_replacements(char *level_name)
476 {
477         CFILE *fp;
478         int t,i,j;
479         char ifile_name[FILENAME_LEN];
480
481         change_filename_extension(ifile_name, level_name, ".HXM" );
482         
483         fp = cfopen(ifile_name,"rb");
484
485         if (!fp)                //no robot replacement file
486                 return;
487
488         t = cfile_read_int(fp);                 //read id "HXM!"
489         if (t!= 0x21584d48) 
490                 Error("ID of HXM! file incorrect");
491
492         t = cfile_read_int(fp);                 //read version
493         if (t<1)
494                 Error("HXM! version too old (%d)",t); 
495
496         t = cfile_read_int(fp);                 //read number of robots
497         for (j=0;j<t;j++) {
498                 i = cfile_read_int(fp);         //read robot number
499                 if (i<0 || i>=N_robot_types)
500                         Error("Robots number (%d) out of range in (%s).  Range = [0..%d].",i,level_name,N_robot_types-1);
501                 robot_info_read(&Robot_info[i], fp);
502         }
503
504         t = cfile_read_int(fp);                 //read number of joints
505         for (j=0;j<t;j++) {
506                 i = cfile_read_int(fp);         //read joint number
507                 if (i<0 || i>=N_robot_joints)
508                         Error("Robots joint (%d) out of range in (%s).  Range = [0..%d].",i,level_name,N_robot_joints-1);
509                 jointpos_read(&Robot_joints[i], fp);
510         }
511
512         t = cfile_read_int(fp);                 //read number of polygon models
513         for (j=0;j<t;j++)
514         {
515                 i = cfile_read_int(fp);         //read model number
516                 if (i<0 || i>=N_polygon_models)
517                         Error("Polygon model (%d) out of range in (%s).  Range = [0..%d].",i,level_name,N_polygon_models-1);
518                 polymodel_read(&Polygon_models[i], fp);
519         
520                 d_free(Polygon_models[i].model_data);
521                 Polygon_models[i].model_data = d_malloc(Polygon_models[i].model_data_size);
522                 Assert( Polygon_models[i].model_data != NULL );
523
524                 cfread( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
525 #ifdef WORDS_BIGENDIAN
526                 swap_polygon_model_data(Polygon_models[i].model_data);
527 #endif
528                 g3_init_polygon_model(Polygon_models[i].model_data);
529
530                 Dying_modelnums[i] = cfile_read_int(fp);
531                 Dead_modelnums[i] = cfile_read_int(fp);
532         }
533
534         t = cfile_read_int(fp);                 //read number of objbitmaps
535         for (j=0;j<t;j++) {
536                 i = cfile_read_int(fp);         //read objbitmap number
537                 if (i<0 || i>=MAX_OBJ_BITMAPS)
538                         Error("Object bitmap number (%d) out of range in (%s).  Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
539                 bitmap_index_read(&ObjBitmaps[i], fp);
540         }
541
542         t = cfile_read_int(fp);                 //read number of objbitmapptrs
543         for (j=0;j<t;j++) {
544                 i = cfile_read_int(fp);         //read objbitmapptr number
545                 if (i<0 || i>=MAX_OBJ_BITMAPS)
546                         Error("Object bitmap pointer (%d) out of range in (%s).  Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
547                 ObjBitmapPtrs[i] = cfile_read_short(fp);
548         }
549
550         cfclose(fp);
551 }