1 /* $Id: paging.c,v 1.4 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 paging in/out textures.
25 //#define PSX_BUILD_TOOLS
28 static char rcsid[] = "$Id: paging.c,v 1.4 2004-08-28 23:17:45 schaffner Exp $";
69 void paging_touch_vclip_w( vclip * vc )
73 for (i=0; i<vc->num_frames; i++ ) {
74 if ( GameBitmaps[(vc->frames[i]).index].bm_flags & BM_FLAG_PAGED_OUT)
75 piggy_bitmap_page_in_w( vc->frames[i],1 );
81 void paging_touch_vclip( vclip * vc )
85 for (i=0; i<vc->num_frames; i++ ) {
86 PIGGY_PAGE_IN( vc->frames[i] );
91 void paging_touch_wall_effects( int tmap_num )
95 for (i=0;i<Num_effects;i++) {
96 if ( Effects[i].changing_wall_texture == tmap_num ) {
97 paging_touch_vclip( &Effects[i].vc );
99 if (Effects[i].dest_bm_num > -1)
100 PIGGY_PAGE_IN( Textures[Effects[i].dest_bm_num] ); //use this bitmap when monitor destroyed
101 if ( Effects[i].dest_vclip > -1 )
102 paging_touch_vclip( &Vclip[Effects[i].dest_vclip] ); //what vclip to play when exploding
104 if ( Effects[i].dest_eclip > -1 )
105 paging_touch_vclip( &Effects[Effects[i].dest_eclip].vc ); //what eclip to play when exploding
107 if ( Effects[i].crit_clip > -1 )
108 paging_touch_vclip( &Effects[Effects[i].crit_clip].vc ); //what eclip to play when mine critical
114 void paging_touch_object_effects( int tmap_num )
118 for (i=0;i<Num_effects;i++) {
119 if ( Effects[i].changing_object_texture == tmap_num ) {
120 paging_touch_vclip( &Effects[i].vc );
126 void paging_touch_model( int modelnum )
129 polymodel *pm = &Polygon_models[modelnum];
131 for (i=0;i<pm->n_textures;i++) {
132 PIGGY_PAGE_IN( ObjBitmaps[ObjBitmapPtrs[pm->first_texture+i]] );
133 paging_touch_object_effects( ObjBitmapPtrs[pm->first_texture+i] );
134 #ifdef PSX_BUILD_TOOLS
136 paging_touch_object_effects( pm->first_texture+i );
141 void paging_touch_weapon( int weapon_type )
143 // Page in the robot's weapons.
145 if ( (weapon_type < 0) || (weapon_type > N_weapon_types) ) return;
147 if ( Weapon_info[weapon_type].picture.index ) {
148 PIGGY_PAGE_IN( Weapon_info[weapon_type].picture );
151 if ( Weapon_info[weapon_type].flash_vclip > -1 )
152 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].flash_vclip]);
153 if ( Weapon_info[weapon_type].wall_hit_vclip > -1 )
154 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].wall_hit_vclip]);
155 if ( Weapon_info[weapon_type].damage_radius ) {
156 // Robot_hit_vclips are actually badass_vclips
157 if ( Weapon_info[weapon_type].robot_hit_vclip > -1 )
158 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].robot_hit_vclip]);
161 switch( Weapon_info[weapon_type].render_type ) {
162 case WEAPON_RENDER_VCLIP:
163 if ( Weapon_info[weapon_type].weapon_vclip > -1 )
164 paging_touch_vclip( &Vclip[Weapon_info[weapon_type].weapon_vclip] );
166 case WEAPON_RENDER_NONE:
168 case WEAPON_RENDER_POLYMODEL:
169 paging_touch_model( Weapon_info[weapon_type].model_num );
171 case WEAPON_RENDER_BLOB:
172 PIGGY_PAGE_IN( Weapon_info[weapon_type].bitmap );
179 sbyte super_boss_gate_type_list[13] = {0, 1, 8, 9, 10, 11, 12, 15, 16, 18, 19, 20, 22 };
181 void paging_touch_robot( int robot_index )
185 //mprintf((0, "Robot %d loading...", robot_index));
187 // Page in robot_index
188 paging_touch_model(Robot_info[robot_index].model_num);
189 if ( Robot_info[robot_index].exp1_vclip_num>-1 )
190 paging_touch_vclip(&Vclip[Robot_info[robot_index].exp1_vclip_num]);
191 if ( Robot_info[robot_index].exp2_vclip_num>-1 )
192 paging_touch_vclip(&Vclip[Robot_info[robot_index].exp2_vclip_num]);
194 // Page in his weapons
195 paging_touch_weapon( Robot_info[robot_index].weapon_type );
197 // A super-boss can gate in robots...
198 if ( Robot_info[robot_index].boss_flag==2 ) {
199 for (i=0; i<13; i++ )
200 paging_touch_robot(super_boss_gate_type_list[i]);
202 paging_touch_vclip( &Vclip[VCLIP_MORPHING_ROBOT] );
207 void paging_touch_object( object * obj )
211 switch (obj->render_type) {
213 case RT_NONE: break; //doesn't render, like the player
216 if ( obj->rtype.pobj_info.tmap_override != -1 )
217 PIGGY_PAGE_IN( Textures[obj->rtype.pobj_info.tmap_override] );
219 paging_touch_model(obj->rtype.pobj_info.model_num);
223 if ( obj->rtype.vclip_info.vclip_num > -1 ) {
225 //@@ paging_touch_vclip_w(&Vclip[obj->rtype.vclip_info.vclip_num]);
227 paging_touch_vclip(&Vclip[obj->rtype.vclip_info.vclip_num]);
232 case RT_MORPH: break;
234 case RT_FIREBALL: break;
236 case RT_WEAPON_VCLIP: break;
239 paging_touch_vclip(&Vclip[obj->rtype.vclip_info.vclip_num]);
242 case RT_LASER: break;
247 v = get_explosion_vclip(obj, 0);
249 paging_touch_vclip(&Vclip[v]);
252 paging_touch_robot( obj->id );
255 paging_touch_weapon( CONTROLCEN_WEAPON_NUM );
256 if (Dead_modelnums[obj->rtype.pobj_info.model_num] != -1) {
257 paging_touch_model( Dead_modelnums[obj->rtype.pobj_info.model_num] );
265 void paging_touch_side( segment * segp, int sidenum )
269 if (!(WALL_IS_DOORWAY(segp,sidenum) & WID_RENDER_FLAG))
272 tmap1 = segp->sides[sidenum].tmap_num;
273 paging_touch_wall_effects(tmap1);
274 tmap2 = segp->sides[sidenum].tmap_num2;
276 texmerge_get_cached_bitmap( tmap1, tmap2 );
277 paging_touch_wall_effects( tmap2 & 0x3FFF );
279 PIGGY_PAGE_IN( Textures[tmap1] );
283 #ifdef PSX_BUILD_TOOLS
284 // If there is water on the level, then force the water splash into memory
285 if(!(TmapInfo[tmap1].flags & TMI_VOLATILE) && (TmapInfo[tmap1].flags & TMI_WATER)) {
288 PIGGY_PAGE_IN(Splash);
290 PIGGY_PAGE_IN(Splash);
292 PIGGY_PAGE_IN(Splash);
294 PIGGY_PAGE_IN(Splash);
296 PIGGY_PAGE_IN(Splash);
302 void paging_touch_robot_maker( segment * segp )
304 segment2 *seg2p = &Segment2s[segp-Segments];
306 if ( seg2p->special == SEGMENT_IS_ROBOTMAKER ) {
307 paging_touch_vclip(&Vclip[VCLIP_MORPHING_ROBOT]);
308 if (RobotCenters[seg2p->matcen_num].robot_flags != 0) {
315 flags = RobotCenters[seg2p->matcen_num].robot_flags[i];
318 // Page in robot_index
319 paging_touch_robot( robot_index );
330 void paging_touch_segment(segment * segp)
334 segment2 *seg2p = &Segment2s[segp-Segments];
336 if ( seg2p->special == SEGMENT_IS_ROBOTMAKER )
337 paging_touch_robot_maker(segp);
339 // paging_draw_orb();
340 for (sn=0;sn<MAX_SIDES_PER_SEGMENT;sn++) {
341 // paging_draw_orb();
342 paging_touch_side( segp, sn );
345 for (objnum=segp->objects;objnum!=-1;objnum=Objects[objnum].next) {
346 // paging_draw_orb();
347 paging_touch_object( &Objects[objnum] );
353 void paging_touch_walls()
358 for (i=0;i<Num_walls;i++) {
359 // paging_draw_orb();
360 if ( Walls[i].clip_num > -1 ) {
361 anim = &WallAnims[Walls[i].clip_num];
362 for (j=0; j < anim->num_frames; j++ ) {
363 PIGGY_PAGE_IN( Textures[anim->frames[j]] );
369 void paging_touch_all()
376 black_screen = gr_palette_faded_out;
378 if ( gr_palette_faded_out ) {
379 gr_clear_canvas( BM_XRGB(0,0,0) );
380 gr_palette_load( gr_palette );
383 //@@ show_boxed_message(TXT_LOADING);
385 mprintf(( 0, "Loading all textures in mine..." ));
386 for (s=0; s<=Highest_segment_index; s++) {
387 paging_touch_segment( &Segments[s] );
389 paging_touch_walls();
391 for ( s=0; s < N_powerup_types; s++ ) {
392 if ( Powerup_info[s].vclip_num > -1 )
393 paging_touch_vclip(&Vclip[Powerup_info[s].vclip_num]);
396 for ( s=0; s<N_weapon_types; s++ ) {
397 paging_touch_weapon(s);
400 for ( s=0; s < N_powerup_types; s++ ) {
401 if ( Powerup_info[s].vclip_num > -1 )
402 paging_touch_vclip(&Vclip[Powerup_info[s].vclip_num]);
406 for (s=0; s<MAX_GAUGE_BMS; s++ ) {
407 if ( Gauges[s].index ) {
408 PIGGY_PAGE_IN( Gauges[s] );
411 paging_touch_vclip( &Vclip[VCLIP_PLAYER_APPEARANCE] );
412 paging_touch_vclip( &Vclip[VCLIP_POWERUP_DISAPPEARANCE] );
415 #ifdef PSX_BUILD_TOOLS
418 paging_touch_walls();
419 for(s=0; s<=Highest_object_index; s++) {
420 paging_touch_object(&Objects[s]);
426 extern int Current_level_num;
427 extern ushort GameBitmapXlat[MAX_BITMAP_FILES];
428 short Used[MAX_BITMAP_FILES];
433 if (Current_level_num<0) //secret level
434 strcpy( fname, Secret_level_names[-Current_level_num-1] );
436 strcpy( fname, Level_names[Current_level_num-1] );
437 p = strchr( fname, '.' );
439 strcat( fname, ".pag" );
441 fp = fopen( fname, "wt" );
442 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
445 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
446 Used[GameBitmapXlat[i]]++;
449 //cmp added so that .damage bitmaps are included for paged-in lights of the current level
450 for (i=0; i<MAX_TEXTURES;i++) {
451 if(Textures[i].index > 0 && Textures[i].index < MAX_BITMAP_FILES &&
452 Used[Textures[i].index] > 0 &&
453 TmapInfo[i].destroyed > 0 && TmapInfo[i].destroyed < MAX_BITMAP_FILES) {
454 Used[Textures[TmapInfo[i].destroyed].index] += 1;
455 mprintf((0, "HERE %d ", Textures[TmapInfo[i].destroyed].index));
457 PIGGY_PAGE_IN(Textures[TmapInfo[i].destroyed]);
462 // Force cockpit to be paged in.
469 // Force in the frames for markers
473 PIGGY_PAGE_IN(bonk2);
475 PIGGY_PAGE_IN(bonk2);
477 PIGGY_PAGE_IN(bonk2);
479 PIGGY_PAGE_IN(bonk2);
481 PIGGY_PAGE_IN(bonk2);
484 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
487 //piggy_get_bitmap_name(i,fname);
489 if (GameBitmaps[i].bm_flags & BM_FLAG_PAGED_OUT )
492 // if (GameBitmapXlat[i]!=i)
497 if ( (i==47) || (i==48) ) // Mark red mplayer ship textures as paged in.
501 fprintf( fp, "0,\t// Bitmap %d (%s)\n", i, "test\0"); // cmp debug fname );
503 fprintf( fp, "1,\t// Bitmap %d (%s)\n", i, "test\0"); // cmp debug fname );
510 mprintf(( 0, "done\n" ));
512 //@@ clear_boxed_message();
514 if ( black_screen ) {
516 gr_clear_canvas( BM_XRGB(0,0,0) );
519 reset_cockpit(); //force cockpit redraw next time