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.
16 * Routines for paging in/out textures.
24 //#define PSX_BUILD_TOOLS
59 void paging_touch_vclip( vclip * vc )
63 for (i=0; i<vc->num_frames; i++ ) {
64 PIGGY_PAGE_IN( vc->frames[i] );
69 void paging_touch_wall_effects( int tmap_num )
73 for (i=0;i<Num_effects;i++) {
74 if ( Effects[i].changing_wall_texture == tmap_num ) {
75 paging_touch_vclip( &Effects[i].vc );
77 if (Effects[i].dest_bm_num > -1)
78 PIGGY_PAGE_IN( Textures[Effects[i].dest_bm_num] ); //use this bitmap when monitor destroyed
79 if ( Effects[i].dest_vclip > -1 )
80 paging_touch_vclip( &Vclip[Effects[i].dest_vclip] ); //what vclip to play when exploding
82 if ( Effects[i].dest_eclip > -1 )
83 paging_touch_vclip( &Effects[Effects[i].dest_eclip].vc ); //what eclip to play when exploding
85 if ( Effects[i].crit_clip > -1 )
86 paging_touch_vclip( &Effects[Effects[i].crit_clip].vc ); //what eclip to play when mine critical
92 void paging_touch_object_effects( int tmap_num )
96 for (i=0;i<Num_effects;i++) {
97 if ( Effects[i].changing_object_texture == tmap_num ) {
98 paging_touch_vclip( &Effects[i].vc );
104 void paging_touch_model( int modelnum )
107 polymodel *pm = &Polygon_models[modelnum];
109 for (i=0;i<pm->n_textures;i++) {
110 PIGGY_PAGE_IN( ObjBitmaps[ObjBitmapPtrs[pm->first_texture+i]] );
111 paging_touch_object_effects( ObjBitmapPtrs[pm->first_texture+i] );
112 #ifdef PSX_BUILD_TOOLS
114 paging_touch_object_effects( pm->first_texture+i );
119 void paging_touch_weapon( int weapon_type )
121 // Page in the robot's weapons.
123 if ( (weapon_type < 0) || (weapon_type > N_weapon_types) ) return;
125 if ( Weapon_info[weapon_type].picture.index ) {
126 PIGGY_PAGE_IN( Weapon_info[weapon_type].picture );
129 if ( Weapon_info[weapon_type].flash_vclip > -1 )
130 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].flash_vclip]);
131 if ( Weapon_info[weapon_type].wall_hit_vclip > -1 )
132 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].wall_hit_vclip]);
133 if ( Weapon_info[weapon_type].damage_radius ) {
134 // Robot_hit_vclips are actually badass_vclips
135 if ( Weapon_info[weapon_type].robot_hit_vclip > -1 )
136 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].robot_hit_vclip]);
139 switch( Weapon_info[weapon_type].render_type ) {
140 case WEAPON_RENDER_VCLIP:
141 if ( Weapon_info[weapon_type].weapon_vclip > -1 )
142 paging_touch_vclip( &Vclip[Weapon_info[weapon_type].weapon_vclip] );
144 case WEAPON_RENDER_NONE:
146 case WEAPON_RENDER_POLYMODEL:
147 paging_touch_model( Weapon_info[weapon_type].model_num );
149 case WEAPON_RENDER_BLOB:
150 PIGGY_PAGE_IN( Weapon_info[weapon_type].bitmap );
157 sbyte super_boss_gate_type_list[13] = {0, 1, 8, 9, 10, 11, 12, 15, 16, 18, 19, 20, 22 };
159 void paging_touch_robot( int robot_index )
163 //mprintf((0, "Robot %d loading...", robot_index));
165 // Page in robot_index
166 paging_touch_model(Robot_info[robot_index].model_num);
167 if ( Robot_info[robot_index].exp1_vclip_num>-1 )
168 paging_touch_vclip(&Vclip[Robot_info[robot_index].exp1_vclip_num]);
169 if ( Robot_info[robot_index].exp2_vclip_num>-1 )
170 paging_touch_vclip(&Vclip[Robot_info[robot_index].exp2_vclip_num]);
172 // Page in his weapons
173 paging_touch_weapon( Robot_info[robot_index].weapon_type );
175 // A super-boss can gate in robots...
176 if ( Robot_info[robot_index].boss_flag==2 ) {
177 for (i=0; i<13; i++ )
178 paging_touch_robot(super_boss_gate_type_list[i]);
180 paging_touch_vclip( &Vclip[VCLIP_MORPHING_ROBOT] );
185 void paging_touch_object( object * obj )
189 switch (obj->render_type) {
191 case RT_NONE: break; //doesn't render, like the player
194 if ( obj->rtype.pobj_info.tmap_override != -1 )
195 PIGGY_PAGE_IN( Textures[obj->rtype.pobj_info.tmap_override] );
197 paging_touch_model(obj->rtype.pobj_info.model_num);
201 if ( obj->rtype.vclip_info.vclip_num > -1 ) {
202 paging_touch_vclip(&Vclip[obj->rtype.vclip_info.vclip_num]);
206 case RT_MORPH: break;
208 case RT_FIREBALL: break;
210 case RT_WEAPON_VCLIP: break;
213 paging_touch_vclip(&Vclip[obj->rtype.vclip_info.vclip_num]);
216 case RT_LASER: break;
221 v = get_explosion_vclip(obj, 0);
223 paging_touch_vclip(&Vclip[v]);
226 paging_touch_robot( obj->id );
229 paging_touch_weapon( CONTROLCEN_WEAPON_NUM );
230 if (Dead_modelnums[obj->rtype.pobj_info.model_num] != -1) {
231 paging_touch_model( Dead_modelnums[obj->rtype.pobj_info.model_num] );
239 void paging_touch_side( segment * segp, int sidenum )
243 if (!(WALL_IS_DOORWAY(segp,sidenum) & WID_RENDER_FLAG))
246 tmap1 = segp->sides[sidenum].tmap_num;
247 paging_touch_wall_effects(tmap1);
248 tmap2 = segp->sides[sidenum].tmap_num2;
250 texmerge_get_cached_bitmap( tmap1, tmap2 );
251 paging_touch_wall_effects( tmap2 & 0x3FFF );
253 PIGGY_PAGE_IN( Textures[tmap1] );
257 #ifdef PSX_BUILD_TOOLS
258 // If there is water on the level, then force the water splash into memory
259 if(!(TmapInfo[tmap1].flags & TMI_VOLATILE) && (TmapInfo[tmap1].flags & TMI_WATER)) {
262 PIGGY_PAGE_IN(Splash);
264 PIGGY_PAGE_IN(Splash);
266 PIGGY_PAGE_IN(Splash);
268 PIGGY_PAGE_IN(Splash);
270 PIGGY_PAGE_IN(Splash);
276 void paging_touch_robot_maker( segment * segp )
278 segment2 *seg2p = s2s2(segp);
280 if ( seg2p->special == SEGMENT_IS_ROBOTMAKER ) {
281 paging_touch_vclip(&Vclip[VCLIP_MORPHING_ROBOT]);
282 if (RobotCenters[seg2p->matcen_num].robot_flags != 0) {
289 flags = RobotCenters[seg2p->matcen_num].robot_flags[i];
292 // Page in robot_index
293 paging_touch_robot( robot_index );
304 void paging_touch_segment(segment * segp)
308 segment2 *seg2p = s2s2(segp);
310 if ( seg2p->special == SEGMENT_IS_ROBOTMAKER )
311 paging_touch_robot_maker(segp);
313 // paging_draw_orb();
314 for (sn=0;sn<MAX_SIDES_PER_SEGMENT;sn++) {
315 // paging_draw_orb();
316 paging_touch_side( segp, sn );
319 for (objnum=segp->objects;objnum!=-1;objnum=Objects[objnum].next) {
320 // paging_draw_orb();
321 paging_touch_object( &Objects[objnum] );
327 void paging_touch_walls()
332 for (i=0;i<Num_walls;i++) {
333 // paging_draw_orb();
334 if ( Walls[i].clip_num > -1 ) {
335 anim = &WallAnims[Walls[i].clip_num];
336 for (j=0; j < anim->num_frames; j++ ) {
337 PIGGY_PAGE_IN( Textures[anim->frames[j]] );
343 void paging_touch_all()
350 black_screen = gr_palette_faded_out;
352 if ( gr_palette_faded_out ) {
353 gr_clear_canvas( BM_XRGB(0,0,0) );
354 gr_palette_load( gr_palette );
357 //@@ show_boxed_message(TXT_LOADING);
359 mprintf(( 0, "Loading all textures in mine..." ));
360 for (s=0; s<=Highest_segment_index; s++) {
361 paging_touch_segment( &Segments[s] );
363 paging_touch_walls();
365 for ( s=0; s < N_powerup_types; s++ ) {
366 if ( Powerup_info[s].vclip_num > -1 )
367 paging_touch_vclip(&Vclip[Powerup_info[s].vclip_num]);
370 for ( s=0; s<N_weapon_types; s++ ) {
371 paging_touch_weapon(s);
374 for ( s=0; s < N_powerup_types; s++ ) {
375 if ( Powerup_info[s].vclip_num > -1 )
376 paging_touch_vclip(&Vclip[Powerup_info[s].vclip_num]);
380 for (s=0; s<MAX_GAUGE_BMS; s++ ) {
381 if ( Gauges[s].index ) {
382 PIGGY_PAGE_IN( Gauges[s] );
385 paging_touch_vclip( &Vclip[VCLIP_PLAYER_APPEARANCE] );
386 paging_touch_vclip( &Vclip[VCLIP_POWERUP_DISAPPEARANCE] );
389 #ifdef PSX_BUILD_TOOLS
392 paging_touch_walls();
393 for(s=0; s<=Highest_object_index; s++) {
394 paging_touch_object(&Objects[s]);
400 extern int Current_level_num;
401 extern ushort GameBitmapXlat[MAX_BITMAP_FILES];
402 short Used[MAX_BITMAP_FILES];
407 if (Current_level_num<0) //secret level
408 strcpy( fname, Secret_level_names[-Current_level_num-1] );
410 strcpy( fname, Level_names[Current_level_num-1] );
411 p = strchr( fname, '.' );
413 strcat( fname, ".pag" );
415 fp = fopen( fname, "wt" );
416 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
419 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
420 Used[GameBitmapXlat[i]]++;
423 //cmp added so that .damage bitmaps are included for paged-in lights of the current level
424 for (i=0; i<MAX_TEXTURES;i++) {
425 if(Textures[i].index > 0 && Textures[i].index < MAX_BITMAP_FILES &&
426 Used[Textures[i].index] > 0 &&
427 TmapInfo[i].destroyed > 0 && TmapInfo[i].destroyed < MAX_BITMAP_FILES) {
428 Used[Textures[TmapInfo[i].destroyed].index] += 1;
429 mprintf((0, "HERE %d ", Textures[TmapInfo[i].destroyed].index));
431 PIGGY_PAGE_IN(Textures[TmapInfo[i].destroyed]);
436 // Force cockpit to be paged in.
443 // Force in the frames for markers
447 PIGGY_PAGE_IN(bonk2);
449 PIGGY_PAGE_IN(bonk2);
451 PIGGY_PAGE_IN(bonk2);
453 PIGGY_PAGE_IN(bonk2);
455 PIGGY_PAGE_IN(bonk2);
458 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
461 //piggy_get_bitmap_name(i,fname);
463 if (GameBitmaps[i].bm_flags & BM_FLAG_PAGED_OUT )
466 // if (GameBitmapXlat[i]!=i)
471 if ( (i==47) || (i==48) ) // Mark red mplayer ship textures as paged in.
475 fprintf( fp, "0,\t// Bitmap %d (%s)\n", i, "test\0"); // cmp debug fname );
477 fprintf( fp, "1,\t// Bitmap %d (%s)\n", i, "test\0"); // cmp debug fname );
484 mprintf(( 0, "done\n" ));
486 //@@ clear_boxed_message();
488 if ( black_screen ) {
490 gr_clear_canvas( BM_XRGB(0,0,0) );
493 reset_cockpit(); //force cockpit redraw next time