1 /* $Id: vclip.c,v 1.5 2003-10-10 09:36:35 btb Exp $ */
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.
17 * Routines for vclips.
20 * Revision 1.2 1995/09/14 14:14:31 allender
21 * return void in draw_vclip_object
23 * Revision 1.1 1995/05/16 15:32:00 allender
26 * Revision 2.0 1995/02/27 11:32:41 john
27 * New version 2.0, which has no anonymous unions, builds with
28 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
30 * Revision 1.8 1994/09/25 23:40:52 matt
31 * Changed the object load & save code to read/write the structure fields one
32 * at a time (rather than the whole structure at once). This mean that the
33 * object structure can be changed without breaking the load/save functions.
34 * As a result of this change, the local_object data can be and has been
35 * incorporated into the object array. Also, timeleft is now a property
36 * of all objects, and the object structure has been otherwise cleaned up.
38 * Revision 1.7 1994/09/25 15:45:26 matt
39 * Added OBJ_LIGHT, a type of object that casts light
40 * Added generalized lifeleft, and moved it to local_object
42 * Revision 1.6 1994/09/09 20:05:57 mike
43 * Add vclips for weapons.
45 * Revision 1.5 1994/06/14 21:14:35 matt
46 * Made rod objects draw lighted or not depending on a parameter, so the
47 * materialization effect no longer darkens.
49 * Revision 1.4 1994/06/08 18:16:24 john
50 * Bunch of new stuff that basically takes constants out of the code
51 * and puts them into bitmaps.tbl.
53 * Revision 1.3 1994/06/03 10:47:17 matt
54 * Made vclips (used by explosions) which can be either rods or blobs, as
55 * specified in BITMAPS.TBL. (This is for the materialization center effect).
57 * Revision 1.2 1994/05/11 09:25:25 john
58 * Abandoned new vclip system for now because each wallclip, vclip,
59 * etc, is different and it would be a huge pain to change all of them.
61 * Revision 1.1 1994/05/10 15:21:12 john
73 static char rcsid[] = "$Id: vclip.c,v 1.5 2003-10-10 09:36:35 btb Exp $";
85 //----------------- Variables for video clips -------------------
87 vclip Vclip[VCLIP_MAXNUM]; // General purpose vclips.
89 //draw an object which renders as a vclip
90 void draw_vclip_object(object *obj,fix timeleft,int lighted, int vclip_num)
94 nf = Vclip[vclip_num].num_frames;
96 bitmapnum = (nf - f2i(fixdiv( (nf-1)*timeleft,Vclip[vclip_num].play_time))) - 1;
98 if (bitmapnum >= Vclip[vclip_num].num_frames)
99 bitmapnum=Vclip[vclip_num].num_frames-1;
101 if (bitmapnum >= 0 ) {
103 if (Vclip[vclip_num].flags & VF_ROD)
104 draw_object_tmap_rod(obj, Vclip[vclip_num].frames[bitmapnum],lighted);
106 Assert(lighted==0); //blob cannot now be lighted
108 draw_object_blob(obj, Vclip[vclip_num].frames[bitmapnum] );
115 void draw_weapon_vclip(object *obj)
118 fix modtime,play_time;
120 //mprintf( 0, "[Drawing obj %d type %d fireball size %x]\n", obj-Objects, Weapon_info[obj->id].weapon_vclip, obj->size );
122 Assert(obj->type == OBJ_WEAPON);
124 vclip_num = Weapon_info[obj->id].weapon_vclip;
126 modtime = obj->lifeleft;
127 play_time = Vclip[vclip_num].play_time;
129 // Special values for modtime were causing enormous slowdown for omega blobs.
130 if (modtime == IMMORTAL_TIME)
133 // Should cause Omega blobs (which live for one frame) to not always be the same.
134 if (modtime == ONE_FRAME_TIME)
137 if (obj->id == PROXIMITY_ID) { //make prox bombs spin out of sync
138 int objnum = obj-Objects;
140 modtime += (modtime * (objnum&7)) / 16; //add variance to spin rate
142 while (modtime > play_time)
143 modtime -= play_time;
145 if ((objnum&1) ^ ((objnum>>1)&1)) //make some spin other way
146 modtime = play_time - modtime;
150 while (modtime > play_time)
151 modtime -= play_time;
154 draw_vclip_object(obj, modtime, 0, vclip_num);
160 * reads n vclip structs from a CFILE
162 int vclip_read_n(vclip *vc, int n, CFILE *fp)
166 for (i = 0; i < n; i++) {
167 vc[i].play_time = cfile_read_fix(fp);
168 vc[i].num_frames = cfile_read_int(fp);
169 vc[i].frame_time = cfile_read_fix(fp);
170 vc[i].flags = cfile_read_int(fp);
171 vc[i].sound_num = cfile_read_short(fp);
172 for (j = 0; j < VCLIP_MAX_FRAMES; j++)
173 vc[i].frames[j].index = cfile_read_short(fp);
174 vc[i].light_value = cfile_read_fix(fp);