2006-03-20 16:43:15 +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 16:43:15 +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
|
2013-02-24 02:39:48 +00:00
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
2013-03-03 01:03:33 +00:00
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
2006-03-20 16:43:15 +00:00
|
|
|
*/
|
2008-04-06 20:23:28 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
/*
|
|
|
|
*
|
2008-04-06 20:23:28 +00:00
|
|
|
* Routines for paging in/out textures.
|
2006-03-20 16:43:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#include "pstypes.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "inferno.h"
|
|
|
|
#include "segment.h"
|
|
|
|
#include "textures.h"
|
|
|
|
#include "wall.h"
|
|
|
|
#include "object.h"
|
|
|
|
#include "gamemine.h"
|
2012-07-07 18:35:06 +00:00
|
|
|
#include "dxxerror.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "gameseg.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "piggy.h"
|
|
|
|
#include "texmerge.h"
|
2012-11-11 22:12:51 +00:00
|
|
|
#include "paging.h"
|
2013-10-08 02:06:35 +00:00
|
|
|
#include "laser.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "polyobj.h"
|
|
|
|
#include "vclip.h"
|
|
|
|
#include "effects.h"
|
|
|
|
#include "fireball.h"
|
|
|
|
#include "weapon.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "cntrlcen.h"
|
|
|
|
#include "gauges.h"
|
|
|
|
#include "powerup.h"
|
|
|
|
#include "fuelcen.h"
|
2013-03-03 01:03:33 +00:00
|
|
|
#include "mission.h"
|
|
|
|
|
2014-04-27 23:12:34 +00:00
|
|
|
#include "compiler-range_for.h"
|
|
|
|
#include "partial_range.h"
|
2014-08-02 16:57:51 +00:00
|
|
|
#include "segiter.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void paging_touch_vclip( vclip * vc )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<vc->num_frames; i++ ) {
|
|
|
|
PIGGY_PAGE_IN( vc->frames[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void paging_touch_wall_effects( int tmap_num )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0;i<Num_effects;i++) {
|
|
|
|
if ( Effects[i].changing_wall_texture == tmap_num ) {
|
|
|
|
paging_touch_vclip( &Effects[i].vc );
|
|
|
|
|
|
|
|
if (Effects[i].dest_bm_num > -1)
|
|
|
|
PIGGY_PAGE_IN( Textures[Effects[i].dest_bm_num] ); //use this bitmap when monitor destroyed
|
|
|
|
if ( Effects[i].dest_vclip > -1 )
|
|
|
|
paging_touch_vclip( &Vclip[Effects[i].dest_vclip] ); //what vclip to play when exploding
|
|
|
|
|
|
|
|
if ( Effects[i].dest_eclip > -1 )
|
|
|
|
paging_touch_vclip( &Effects[Effects[i].dest_eclip].vc ); //what eclip to play when exploding
|
|
|
|
|
|
|
|
if ( Effects[i].crit_clip > -1 )
|
|
|
|
paging_touch_vclip( &Effects[Effects[i].crit_clip].vc ); //what eclip to play when mine critical
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void paging_touch_object_effects( int tmap_num )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0;i<Num_effects;i++) {
|
|
|
|
if ( Effects[i].changing_object_texture == tmap_num ) {
|
|
|
|
paging_touch_vclip( &Effects[i].vc );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void paging_touch_model( int modelnum )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
polymodel *pm = &Polygon_models[modelnum];
|
|
|
|
|
|
|
|
for (i=0;i<pm->n_textures;i++) {
|
|
|
|
PIGGY_PAGE_IN( ObjBitmaps[ObjBitmapPtrs[pm->first_texture+i]] );
|
|
|
|
paging_touch_object_effects( ObjBitmapPtrs[pm->first_texture+i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void paging_touch_weapon( int weapon_type )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
// Page in the robot's weapons.
|
|
|
|
|
|
|
|
if ( (weapon_type < 0) || (weapon_type > N_weapon_types) ) return;
|
|
|
|
|
|
|
|
if ( Weapon_info[weapon_type].picture.index ) {
|
|
|
|
PIGGY_PAGE_IN( Weapon_info[weapon_type].picture );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( Weapon_info[weapon_type].flash_vclip > -1 )
|
|
|
|
paging_touch_vclip(&Vclip[Weapon_info[weapon_type].flash_vclip]);
|
|
|
|
if ( Weapon_info[weapon_type].wall_hit_vclip > -1 )
|
|
|
|
paging_touch_vclip(&Vclip[Weapon_info[weapon_type].wall_hit_vclip]);
|
|
|
|
if ( Weapon_info[weapon_type].damage_radius ) {
|
|
|
|
// Robot_hit_vclips are actually badass_vclips
|
|
|
|
if ( Weapon_info[weapon_type].robot_hit_vclip > -1 )
|
|
|
|
paging_touch_vclip(&Vclip[Weapon_info[weapon_type].robot_hit_vclip]);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( Weapon_info[weapon_type].render_type ) {
|
|
|
|
case WEAPON_RENDER_VCLIP:
|
|
|
|
if ( Weapon_info[weapon_type].weapon_vclip > -1 )
|
|
|
|
paging_touch_vclip( &Vclip[Weapon_info[weapon_type].weapon_vclip] );
|
|
|
|
break;
|
|
|
|
case WEAPON_RENDER_NONE:
|
|
|
|
break;
|
|
|
|
case WEAPON_RENDER_POLYMODEL:
|
|
|
|
paging_touch_model( Weapon_info[weapon_type].model_num );
|
|
|
|
break;
|
|
|
|
case WEAPON_RENDER_BLOB:
|
|
|
|
PIGGY_PAGE_IN( Weapon_info[weapon_type].bitmap );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-28 00:23:45 +00:00
|
|
|
static const sbyte super_boss_gate_type_list[13] = {0, 1, 8, 9, 10, 11, 12, 15, 16, 18, 19, 20, 22 };
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void paging_touch_robot( int robot_index )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
2013-03-03 01:03:33 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
// Page in robot_index
|
|
|
|
paging_touch_model(Robot_info[robot_index].model_num);
|
|
|
|
if ( Robot_info[robot_index].exp1_vclip_num>-1 )
|
|
|
|
paging_touch_vclip(&Vclip[Robot_info[robot_index].exp1_vclip_num]);
|
|
|
|
if ( Robot_info[robot_index].exp2_vclip_num>-1 )
|
|
|
|
paging_touch_vclip(&Vclip[Robot_info[robot_index].exp2_vclip_num]);
|
|
|
|
|
|
|
|
// Page in his weapons
|
|
|
|
paging_touch_weapon( Robot_info[robot_index].weapon_type );
|
|
|
|
|
|
|
|
// A super-boss can gate in robots...
|
|
|
|
if ( Robot_info[robot_index].boss_flag==2 ) {
|
|
|
|
for (i=0; i<13; i++ )
|
|
|
|
paging_touch_robot(super_boss_gate_type_list[i]);
|
|
|
|
|
|
|
|
paging_touch_vclip( &Vclip[VCLIP_MORPHING_ROBOT] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void paging_touch_object( object * obj )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
int v;
|
|
|
|
|
|
|
|
switch (obj->render_type) {
|
|
|
|
|
|
|
|
case RT_NONE: break; //doesn't render, like the player
|
|
|
|
|
|
|
|
case RT_POLYOBJ:
|
2008-10-04 11:56:03 +00:00
|
|
|
if ( obj->rtype.pobj_info.tmap_override != -1 )
|
|
|
|
PIGGY_PAGE_IN( Textures[obj->rtype.pobj_info.tmap_override] );
|
|
|
|
else
|
|
|
|
paging_touch_model(obj->rtype.pobj_info.model_num);
|
2006-03-20 16:43:15 +00:00
|
|
|
break;
|
2013-02-21 00:20:26 +00:00
|
|
|
|
|
|
|
case RT_POWERUP:
|
2013-03-03 01:03:33 +00:00
|
|
|
if ( obj->rtype.vclip_info.vclip_num > -1 ) {
|
2006-03-20 16:43:15 +00:00
|
|
|
paging_touch_vclip(&Vclip[obj->rtype.vclip_info.vclip_num]);
|
2013-03-03 01:03:33 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RT_MORPH: break;
|
|
|
|
|
|
|
|
case RT_FIREBALL: break;
|
|
|
|
|
|
|
|
case RT_WEAPON_VCLIP: break;
|
|
|
|
|
2013-02-21 00:20:26 +00:00
|
|
|
case RT_HOSTAGE:
|
2006-03-20 16:43:15 +00:00
|
|
|
paging_touch_vclip(&Vclip[obj->rtype.vclip_info.vclip_num]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RT_LASER: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (obj->type) {
|
|
|
|
case OBJ_PLAYER:
|
|
|
|
v = get_explosion_vclip(obj, 0);
|
|
|
|
if ( v > -1 )
|
|
|
|
paging_touch_vclip(&Vclip[v]);
|
|
|
|
break;
|
|
|
|
case OBJ_ROBOT:
|
2013-10-07 23:52:33 +00:00
|
|
|
paging_touch_robot( get_robot_id(obj) );
|
2006-03-20 16:43:15 +00:00
|
|
|
break;
|
|
|
|
case OBJ_CNTRLCEN:
|
|
|
|
paging_touch_weapon( CONTROLCEN_WEAPON_NUM );
|
|
|
|
if (Dead_modelnums[obj->rtype.pobj_info.model_num] != -1) {
|
|
|
|
paging_touch_model( Dead_modelnums[obj->rtype.pobj_info.model_num] );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void paging_touch_side( segment * segp, int sidenum )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
int tmap1, tmap2;
|
|
|
|
|
|
|
|
if (!(WALL_IS_DOORWAY(segp,sidenum) & WID_RENDER_FLAG))
|
|
|
|
return;
|
|
|
|
|
|
|
|
tmap1 = segp->sides[sidenum].tmap_num;
|
|
|
|
paging_touch_wall_effects(tmap1);
|
|
|
|
tmap2 = segp->sides[sidenum].tmap_num2;
|
|
|
|
if (tmap2 != 0) {
|
|
|
|
texmerge_get_cached_bitmap( tmap1, tmap2 );
|
|
|
|
paging_touch_wall_effects( tmap2 & 0x3FFF );
|
|
|
|
} else {
|
|
|
|
PIGGY_PAGE_IN( Textures[tmap1] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void paging_touch_robot_maker( segment * segp )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
if ( segp->special == SEGMENT_IS_ROBOTMAKER ) {
|
|
|
|
paging_touch_vclip(&Vclip[VCLIP_MORPHING_ROBOT]);
|
|
|
|
uint flags;
|
|
|
|
int robot_index;
|
|
|
|
|
2013-07-14 23:26:29 +00:00
|
|
|
for (unsigned i=0;i<sizeof(RobotCenters[0].robot_flags)/sizeof(RobotCenters[0].robot_flags[0]);i++) {
|
2013-03-03 01:03:33 +00:00
|
|
|
robot_index = i*32;
|
|
|
|
flags = RobotCenters[segp->matcen_num].robot_flags[i];
|
2013-02-21 00:20:26 +00:00
|
|
|
while (flags) {
|
|
|
|
if (flags & 1) {
|
|
|
|
// Page in robot_index
|
|
|
|
paging_touch_robot( robot_index );
|
|
|
|
}
|
|
|
|
flags >>= 1;
|
|
|
|
robot_index++;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2013-03-03 01:03:33 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void paging_touch_segment(segment * segp)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
int sn;
|
2013-03-03 01:03:33 +00:00
|
|
|
if ( segp->special == SEGMENT_IS_ROBOTMAKER )
|
2006-03-20 16:43:15 +00:00
|
|
|
paging_touch_robot_maker(segp);
|
|
|
|
|
|
|
|
// paging_draw_orb();
|
|
|
|
for (sn=0;sn<MAX_SIDES_PER_SEGMENT;sn++) {
|
|
|
|
// paging_draw_orb();
|
|
|
|
paging_touch_side( segp, sn );
|
|
|
|
}
|
|
|
|
|
2014-08-02 16:57:51 +00:00
|
|
|
range_for (auto objp, objects_in(*segp))
|
|
|
|
paging_touch_object(objp);
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void paging_touch_walls()
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2014-04-27 23:12:34 +00:00
|
|
|
int j;
|
2006-03-20 16:43:15 +00:00
|
|
|
wclip *anim;
|
|
|
|
|
2014-04-27 23:12:34 +00:00
|
|
|
range_for (auto &w, partial_range(Walls, Num_walls))
|
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
// paging_draw_orb();
|
2014-04-27 23:12:34 +00:00
|
|
|
if ( w.clip_num > -1 ) {
|
|
|
|
anim = &WallAnims[w.clip_num];
|
2006-03-20 16:43:15 +00:00
|
|
|
for (j=0; j < anim->num_frames; j++ ) {
|
|
|
|
PIGGY_PAGE_IN( Textures[anim->frames[j]] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void paging_touch_all()
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
stop_time();
|
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2008-02-24 14:41:27 +00:00
|
|
|
show_boxed_message(TXT_LOADING, 0);
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
for (s=0; s<=Highest_segment_index; s++) {
|
|
|
|
paging_touch_segment( &Segments[s] );
|
|
|
|
}
|
|
|
|
paging_touch_walls();
|
|
|
|
|
|
|
|
for ( s=0; s < N_powerup_types; s++ ) {
|
|
|
|
if ( Powerup_info[s].vclip_num > -1 )
|
|
|
|
paging_touch_vclip(&Vclip[Powerup_info[s].vclip_num]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( s=0; s<N_weapon_types; s++ ) {
|
|
|
|
paging_touch_weapon(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( s=0; s < N_powerup_types; s++ ) {
|
|
|
|
if ( Powerup_info[s].vclip_num > -1 )
|
|
|
|
paging_touch_vclip(&Vclip[Powerup_info[s].vclip_num]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (s=0; s<MAX_GAUGE_BMS; s++ ) {
|
|
|
|
if ( Gauges[s].index ) {
|
|
|
|
PIGGY_PAGE_IN( Gauges[s] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
paging_touch_vclip( &Vclip[VCLIP_PLAYER_APPEARANCE] );
|
|
|
|
paging_touch_vclip( &Vclip[VCLIP_POWERUP_DISAPPEARANCE] );
|
|
|
|
|
|
|
|
start_time();
|
|
|
|
reset_cockpit(); //force cockpit redraw next time
|
|
|
|
}
|
2013-03-03 01:03:33 +00:00
|
|
|
|