2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Routines for vclips.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2012-07-07 18:35:06 +00:00
|
|
|
#include "dxxerror.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "inferno.h"
|
|
|
|
#include "vclip.h"
|
2014-01-12 23:00:43 +00:00
|
|
|
#include "physfs-serial.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "weapon.h"
|
2014-01-11 22:40:54 +00:00
|
|
|
#include "object.h"
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "laser.h"
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-01-18 18:02:02 +00:00
|
|
|
#include "compiler-range_for.h"
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
//----------------- Variables for video clips -------------------
|
2015-12-22 04:18:50 +00:00
|
|
|
namespace dcx {
|
|
|
|
unsigned Num_vclips;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace dsx {
|
2014-01-18 18:02:02 +00:00
|
|
|
array<vclip, VCLIP_MAXNUM> Vclip; // General purpose vclips.
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//draw an object which renders as a vclip
|
2017-03-11 19:56:25 +00:00
|
|
|
void draw_vclip_object(grs_canvas &canvas, const vcobjptridx_t obj, const fix timeleft, const int lighted, const vclip &vc)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2017-03-11 19:56:25 +00:00
|
|
|
const auto nf = vc.num_frames;
|
|
|
|
int bitmapnum = (nf - f2i(fixdiv((nf - 1) * timeleft, vc.play_time))) - 1;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2017-03-11 19:56:25 +00:00
|
|
|
if (bitmapnum >= vc.num_frames)
|
|
|
|
bitmapnum = vc.num_frames - 1;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
if (bitmapnum >= 0 ) {
|
2017-03-11 19:56:25 +00:00
|
|
|
if (vc.flags & VF_ROD)
|
|
|
|
draw_object_tmap_rod(canvas, obj, vc.frames[bitmapnum], lighted);
|
2006-03-20 17:12:09 +00:00
|
|
|
else {
|
|
|
|
Assert(lighted==0); //blob cannot now be lighted
|
2017-03-11 19:56:25 +00:00
|
|
|
draw_object_blob(canvas, obj, vc.frames[bitmapnum]);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-11 19:56:25 +00:00
|
|
|
void draw_weapon_vclip(grs_canvas &canvas, const vcobjptridx_t obj)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
Assert(obj->type == OBJ_WEAPON);
|
|
|
|
|
2017-03-11 19:56:25 +00:00
|
|
|
const auto lifeleft = obj->lifeleft;
|
|
|
|
const auto vclip_num = Weapon_info[get_weapon_id(obj)].weapon_vclip;
|
|
|
|
const auto play_time = Vclip[vclip_num].play_time;
|
|
|
|
fix modtime = lifeleft % play_time;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2017-03-11 19:56:26 +00:00
|
|
|
if (is_proximity_bomb_or_smart_mine_or_placed_mine(get_weapon_id(obj)))
|
|
|
|
{ //make prox bombs spin out of sync
|
2014-01-11 22:42:44 +00:00
|
|
|
int objnum = obj;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2017-03-11 19:56:25 +00:00
|
|
|
modtime += (lifeleft * (objnum & 7)) / 16; //add variance to spin rate
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2017-03-11 19:56:25 +00:00
|
|
|
if (modtime > play_time)
|
2017-12-02 04:31:26 +00:00
|
|
|
modtime %= play_time;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
if ((objnum&1) ^ ((objnum>>1)&1)) //make some spin other way
|
|
|
|
modtime = play_time - modtime;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-03-11 19:56:25 +00:00
|
|
|
draw_vclip_object(canvas, obj, modtime, 0, Vclip[vclip_num]);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2015-12-22 04:18:50 +00:00
|
|
|
}
|
|
|
|
|
2014-01-12 23:00:43 +00:00
|
|
|
DEFINE_VCLIP_SERIAL_UDT();
|
|
|
|
|
2015-12-22 04:18:50 +00:00
|
|
|
namespace dcx {
|
2016-01-09 16:38:14 +00:00
|
|
|
void vclip_read(PHYSFS_File *fp, vclip &vc)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2014-01-12 23:00:43 +00:00
|
|
|
PHYSFSX_serialize_read(fp, vc);
|
|
|
|
}
|
|
|
|
|
2015-12-04 03:36:31 +00:00
|
|
|
#if 0
|
2016-01-09 16:38:14 +00:00
|
|
|
void vclip_write(PHYSFS_File *fp, const vclip &vc)
|
2014-01-12 23:00:43 +00:00
|
|
|
{
|
|
|
|
PHYSFSX_serialize_write(fp, vc);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
2015-12-04 03:36:31 +00:00
|
|
|
#endif
|
2015-12-22 04:18:50 +00:00
|
|
|
}
|