]> icculus.org git repositories - btb/d2x.git/blob - main/vclip.c
changed args_find to FindArg, added -grabmouse option
[btb/d2x.git] / main / vclip.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14
15 #ifdef RCS
16 static char rcsid[] = "$Id: vclip.c,v 1.1.1.1 2001-01-19 03:29:59 bradleyb Exp $";
17 #endif
18
19 #include <conf.h>
20
21 #include <stdlib.h>
22
23 #include "error.h"
24
25 #include "inferno.h"
26 #include "vclip.h"
27 #include "weapon.h"
28 #include "laser.h"
29
30 //----------------- Variables for video clips -------------------
31 int                                     Num_vclips = 0;
32 vclip                           Vclip[VCLIP_MAXNUM];            // General purpose vclips.
33
34 //draw an object which renders as a vclip
35 void draw_vclip_object(object *obj,fix timeleft,int lighted, int vclip_num)
36 {
37         int nf,bitmapnum;
38
39         nf = Vclip[vclip_num].num_frames;
40
41         bitmapnum =  (nf - f2i(fixdiv( (nf-1)*timeleft,Vclip[vclip_num].play_time))) - 1;
42
43         if (bitmapnum >= Vclip[vclip_num].num_frames)
44                 bitmapnum=Vclip[vclip_num].num_frames-1;
45
46         if (bitmapnum >= 0 )    {
47
48                 if (Vclip[vclip_num].flags & VF_ROD)
49                         draw_object_tmap_rod(obj, Vclip[vclip_num].frames[bitmapnum],lighted);
50                 else {
51                         Assert(lighted==0);             //blob cannot now be lighted
52
53                         draw_object_blob(obj, Vclip[vclip_num].frames[bitmapnum] );
54                 }
55         }
56
57 }
58
59
60 void draw_weapon_vclip(object *obj)
61 {
62         int     vclip_num;
63         fix     modtime,play_time;
64
65         //mprintf( 0, "[Drawing obj %d type %d fireball size %x]\n", obj-Objects, Weapon_info[obj->id].weapon_vclip, obj->size );
66
67         Assert(obj->type == OBJ_WEAPON);
68
69         vclip_num = Weapon_info[obj->id].weapon_vclip;
70
71         modtime = obj->lifeleft;
72         play_time = Vclip[vclip_num].play_time;
73
74         //      Special values for modtime were causing enormous slowdown for omega blobs.
75         if (modtime == IMMORTAL_TIME)
76                 modtime = play_time;
77
78         //      Should cause Omega blobs (which live for one frame) to not always be the same.
79         if (modtime == ONE_FRAME_TIME)
80                 modtime = d_rand();
81
82         if (obj->id == PROXIMITY_ID) {          //make prox bombs spin out of sync
83                 int objnum = obj-Objects;
84
85                 modtime += (modtime * (objnum&7)) / 16; //add variance to spin rate
86
87                 while (modtime > play_time)
88                         modtime -= play_time;
89
90                 if ((objnum&1) ^ ((objnum>>1)&1))                       //make some spin other way
91                         modtime = play_time - modtime;
92
93         }
94         else {
95                 while (modtime > play_time)
96                         modtime -= play_time;
97         }
98
99         draw_vclip_object(obj, modtime, 0, vclip_num);
100
101 }
102