1 /* $Id: vclip.c,v 1.6 2004-08-28 23:17:45 schaffner 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.
27 static char rcsid[] = "$Id: vclip.c,v 1.6 2004-08-28 23:17:45 schaffner Exp $";
39 //----------------- Variables for video clips -------------------
41 vclip Vclip[VCLIP_MAXNUM]; // General purpose vclips.
43 //draw an object which renders as a vclip
44 void draw_vclip_object(object *obj,fix timeleft,int lighted, int vclip_num)
48 nf = Vclip[vclip_num].num_frames;
50 bitmapnum = (nf - f2i(fixdiv( (nf-1)*timeleft,Vclip[vclip_num].play_time))) - 1;
52 if (bitmapnum >= Vclip[vclip_num].num_frames)
53 bitmapnum=Vclip[vclip_num].num_frames-1;
55 if (bitmapnum >= 0 ) {
57 if (Vclip[vclip_num].flags & VF_ROD)
58 draw_object_tmap_rod(obj, Vclip[vclip_num].frames[bitmapnum],lighted);
60 Assert(lighted==0); //blob cannot now be lighted
62 draw_object_blob(obj, Vclip[vclip_num].frames[bitmapnum] );
69 void draw_weapon_vclip(object *obj)
72 fix modtime,play_time;
74 //mprintf( 0, "[Drawing obj %d type %d fireball size %x]\n", obj-Objects, Weapon_info[obj->id].weapon_vclip, obj->size );
76 Assert(obj->type == OBJ_WEAPON);
78 vclip_num = Weapon_info[obj->id].weapon_vclip;
80 modtime = obj->lifeleft;
81 play_time = Vclip[vclip_num].play_time;
83 // Special values for modtime were causing enormous slowdown for omega blobs.
84 if (modtime == IMMORTAL_TIME)
87 // Should cause Omega blobs (which live for one frame) to not always be the same.
88 if (modtime == ONE_FRAME_TIME)
91 if (obj->id == PROXIMITY_ID) { //make prox bombs spin out of sync
92 int objnum = obj-Objects;
94 modtime += (modtime * (objnum&7)) / 16; //add variance to spin rate
96 while (modtime > play_time)
99 if ((objnum&1) ^ ((objnum>>1)&1)) //make some spin other way
100 modtime = play_time - modtime;
104 while (modtime > play_time)
105 modtime -= play_time;
108 draw_vclip_object(obj, modtime, 0, vclip_num);
114 * reads n vclip structs from a CFILE
116 int vclip_read_n(vclip *vc, int n, CFILE *fp)
120 for (i = 0; i < n; i++) {
121 vc[i].play_time = cfile_read_fix(fp);
122 vc[i].num_frames = cfile_read_int(fp);
123 vc[i].frame_time = cfile_read_fix(fp);
124 vc[i].flags = cfile_read_int(fp);
125 vc[i].sound_num = cfile_read_short(fp);
126 for (j = 0; j < VCLIP_MAX_FRAMES; j++)
127 vc[i].frames[j].index = cfile_read_short(fp);
128 vc[i].light_value = cfile_read_fix(fp);