1 //#define PSX_BUILD_TOOLS
4 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
5 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
6 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
7 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
8 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
9 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
10 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
11 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
12 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
13 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
18 static char rcsid[] = "$Id: paging.c,v 1.1.1.1 2001-01-19 03:29:59 bradleyb Exp $";
61 void paging_touch_vclip_w( vclip * vc )
65 for (i=0; i<vc->num_frames; i++ ) {
66 if ( GameBitmaps[(vc->frames[i]).index].bm_flags & BM_FLAG_PAGED_OUT)
67 piggy_bitmap_page_in_w( vc->frames[i],1 );
73 void paging_touch_vclip( vclip * vc )
77 for (i=0; i<vc->num_frames; i++ ) {
78 PIGGY_PAGE_IN( vc->frames[i] );
83 void paging_touch_wall_effects( int tmap_num )
87 for (i=0;i<Num_effects;i++) {
88 if ( Effects[i].changing_wall_texture == tmap_num ) {
89 paging_touch_vclip( &Effects[i].vc );
91 if (Effects[i].dest_bm_num > -1)
92 PIGGY_PAGE_IN( Textures[Effects[i].dest_bm_num] ); //use this bitmap when monitor destroyed
93 if ( Effects[i].dest_vclip > -1 )
94 paging_touch_vclip( &Vclip[Effects[i].dest_vclip] ); //what vclip to play when exploding
96 if ( Effects[i].dest_eclip > -1 )
97 paging_touch_vclip( &Effects[Effects[i].dest_eclip].vc ); //what eclip to play when exploding
99 if ( Effects[i].crit_clip > -1 )
100 paging_touch_vclip( &Effects[Effects[i].crit_clip].vc ); //what eclip to play when mine critical
106 void paging_touch_object_effects( int tmap_num )
110 for (i=0;i<Num_effects;i++) {
111 if ( Effects[i].changing_object_texture == tmap_num ) {
112 paging_touch_vclip( &Effects[i].vc );
118 void paging_touch_model( int modelnum )
121 polymodel *pm = &Polygon_models[modelnum];
123 for (i=0;i<pm->n_textures;i++) {
124 PIGGY_PAGE_IN( ObjBitmaps[ObjBitmapPtrs[pm->first_texture+i]] );
125 paging_touch_object_effects( ObjBitmapPtrs[pm->first_texture+i] );
126 #ifdef PSX_BUILD_TOOLS
128 paging_touch_object_effects( pm->first_texture+i );
133 void paging_touch_weapon( int weapon_type )
135 // Page in the robot's weapons.
137 if ( (weapon_type < 0) || (weapon_type > N_weapon_types) ) return;
139 if ( Weapon_info[weapon_type].picture.index ) {
140 PIGGY_PAGE_IN( Weapon_info[weapon_type].picture );
143 if ( Weapon_info[weapon_type].flash_vclip > -1 )
144 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].flash_vclip]);
145 if ( Weapon_info[weapon_type].wall_hit_vclip > -1 )
146 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].wall_hit_vclip]);
147 if ( Weapon_info[weapon_type].damage_radius ) {
148 // Robot_hit_vclips are actually badass_vclips
149 if ( Weapon_info[weapon_type].robot_hit_vclip > -1 )
150 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].robot_hit_vclip]);
153 switch( Weapon_info[weapon_type].render_type ) {
154 case WEAPON_RENDER_VCLIP:
155 if ( Weapon_info[weapon_type].weapon_vclip > -1 )
156 paging_touch_vclip( &Vclip[Weapon_info[weapon_type].weapon_vclip] );
158 case WEAPON_RENDER_NONE:
160 case WEAPON_RENDER_POLYMODEL:
161 paging_touch_model( Weapon_info[weapon_type].model_num );
163 case WEAPON_RENDER_BLOB:
164 PIGGY_PAGE_IN( Weapon_info[weapon_type].bitmap );
171 byte super_boss_gate_type_list[13] = {0, 1, 8, 9, 10, 11, 12, 15, 16, 18, 19, 20, 22 };
173 void paging_touch_robot( int robot_index )
177 //mprintf((0, "Robot %d loading...", robot_index));
179 // Page in robot_index
180 paging_touch_model(Robot_info[robot_index].model_num);
181 if ( Robot_info[robot_index].exp1_vclip_num>-1 )
182 paging_touch_vclip(&Vclip[Robot_info[robot_index].exp1_vclip_num]);
183 if ( Robot_info[robot_index].exp2_vclip_num>-1 )
184 paging_touch_vclip(&Vclip[Robot_info[robot_index].exp2_vclip_num]);
186 // Page in his weapons
187 paging_touch_weapon( Robot_info[robot_index].weapon_type );
189 // A super-boss can gate in robots...
190 if ( Robot_info[robot_index].boss_flag==2 ) {
191 for (i=0; i<13; i++ )
192 paging_touch_robot(super_boss_gate_type_list[i]);
194 paging_touch_vclip( &Vclip[VCLIP_MORPHING_ROBOT] );
199 void paging_touch_object( object * obj )
203 switch (obj->render_type) {
205 case RT_NONE: break; //doesn't render, like the player
208 if ( obj->rtype.pobj_info.tmap_override != -1 )
209 PIGGY_PAGE_IN( Textures[obj->rtype.pobj_info.tmap_override] );
211 paging_touch_model(obj->rtype.pobj_info.model_num);
215 if ( obj->rtype.vclip_info.vclip_num > -1 ) {
217 //@@ paging_touch_vclip_w(&Vclip[obj->rtype.vclip_info.vclip_num]);
219 paging_touch_vclip(&Vclip[obj->rtype.vclip_info.vclip_num]);
224 case RT_MORPH: break;
226 case RT_FIREBALL: break;
228 case RT_WEAPON_VCLIP: break;
231 paging_touch_vclip(&Vclip[obj->rtype.vclip_info.vclip_num]);
234 case RT_LASER: break;
239 v = get_explosion_vclip(obj, 0);
241 paging_touch_vclip(&Vclip[v]);
244 paging_touch_robot( obj->id );
247 paging_touch_weapon( CONTROLCEN_WEAPON_NUM );
248 if (Dead_modelnums[obj->rtype.pobj_info.model_num] != -1) {
249 paging_touch_model( Dead_modelnums[obj->rtype.pobj_info.model_num] );
257 void paging_touch_side( segment * segp, int sidenum )
261 if (!(WALL_IS_DOORWAY(segp,sidenum) & WID_RENDER_FLAG))
264 tmap1 = segp->sides[sidenum].tmap_num;
265 paging_touch_wall_effects(tmap1);
266 tmap2 = segp->sides[sidenum].tmap_num2;
268 texmerge_get_cached_bitmap( tmap1, tmap2 );
269 paging_touch_wall_effects( tmap2 & 0x3FFF );
271 PIGGY_PAGE_IN( Textures[tmap1] );
275 #ifdef PSX_BUILD_TOOLS
276 // If there is water on the level, then force the water splash into memory
277 if(!(TmapInfo[tmap1].flags & TMI_VOLATILE) && (TmapInfo[tmap1].flags & TMI_WATER)) {
280 PIGGY_PAGE_IN(Splash);
282 PIGGY_PAGE_IN(Splash);
284 PIGGY_PAGE_IN(Splash);
286 PIGGY_PAGE_IN(Splash);
288 PIGGY_PAGE_IN(Splash);
294 void paging_touch_robot_maker( segment * segp )
296 segment2 *seg2p = &Segment2s[segp-Segments];
298 if ( seg2p->special == SEGMENT_IS_ROBOTMAKER ) {
299 paging_touch_vclip(&Vclip[VCLIP_MORPHING_ROBOT]);
300 if (RobotCenters[seg2p->matcen_num].robot_flags != 0) {
307 flags = RobotCenters[seg2p->matcen_num].robot_flags[i];
310 // Page in robot_index
311 paging_touch_robot( robot_index );
322 void paging_touch_segment(segment * segp)
326 segment2 *seg2p = &Segment2s[segp-Segments];
328 if ( seg2p->special == SEGMENT_IS_ROBOTMAKER )
329 paging_touch_robot_maker(segp);
331 // paging_draw_orb();
332 for (sn=0;sn<MAX_SIDES_PER_SEGMENT;sn++) {
333 // paging_draw_orb();
334 paging_touch_side( segp, sn );
337 for (objnum=segp->objects;objnum!=-1;objnum=Objects[objnum].next) {
338 // paging_draw_orb();
339 paging_touch_object( &Objects[objnum] );
345 void paging_touch_walls()
350 for (i=0;i<Num_walls;i++) {
351 // paging_draw_orb();
352 if ( Walls[i].clip_num > -1 ) {
353 anim = &WallAnims[Walls[i].clip_num];
354 for (j=0; j < anim->num_frames; j++ ) {
355 PIGGY_PAGE_IN( Textures[anim->frames[j]] );
361 void paging_touch_all()
368 black_screen = gr_palette_faded_out;
370 if ( gr_palette_faded_out ) {
371 gr_clear_canvas( BM_XRGB(0,0,0) );
372 gr_palette_load( gr_palette );
375 //@@ show_boxed_message(TXT_LOADING);
377 mprintf(( 0, "Loading all textures in mine..." ));
378 for (s=0; s<=Highest_segment_index; s++) {
379 paging_touch_segment( &Segments[s] );
381 paging_touch_walls();
383 for ( s=0; s < N_powerup_types; s++ ) {
384 if ( Powerup_info[s].vclip_num > -1 )
385 paging_touch_vclip(&Vclip[Powerup_info[s].vclip_num]);
388 for ( s=0; s<N_weapon_types; s++ ) {
389 paging_touch_weapon(s);
392 for ( s=0; s < N_powerup_types; s++ ) {
393 if ( Powerup_info[s].vclip_num > -1 )
394 paging_touch_vclip(&Vclip[Powerup_info[s].vclip_num]);
398 for (s=0; s<MAX_GAUGE_BMS; s++ ) {
399 if ( Gauges[s].index ) {
400 PIGGY_PAGE_IN( Gauges[s] );
403 paging_touch_vclip( &Vclip[VCLIP_PLAYER_APPEARANCE] );
404 paging_touch_vclip( &Vclip[VCLIP_POWERUP_DISAPPEARANCE] );
407 #ifdef PSX_BUILD_TOOLS
410 paging_touch_walls();
411 for(s=0; s<=Highest_object_index; s++) {
412 paging_touch_object(&Objects[s]);
418 extern int Current_level_num;
419 extern ushort GameBitmapXlat[MAX_BITMAP_FILES];
420 short Used[MAX_BITMAP_FILES];
425 if (Current_level_num<0) //secret level
426 strcpy( fname, Secret_level_names[-Current_level_num-1] );
428 strcpy( fname, Level_names[Current_level_num-1] );
429 p = strchr( fname, '.' );
431 strcat( fname, ".pag" );
433 fp = fopen( fname, "wt" );
434 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
437 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
438 Used[GameBitmapXlat[i]]++;
441 //cmp added so that .damage bitmaps are included for paged-in lights of the current level
442 for (i=0; i<MAX_TEXTURES;i++) {
443 if(Textures[i].index > 0 && Textures[i].index < MAX_BITMAP_FILES &&
444 Used[Textures[i].index] > 0 &&
445 TmapInfo[i].destroyed > 0 && TmapInfo[i].destroyed < MAX_BITMAP_FILES) {
446 Used[Textures[TmapInfo[i].destroyed].index] += 1;
447 mprintf((0, "HERE %d ", Textures[TmapInfo[i].destroyed].index));
449 PIGGY_PAGE_IN(Textures[TmapInfo[i].destroyed]);
454 // Force cockpit to be paged in.
461 // Force in the frames for markers
465 PIGGY_PAGE_IN(bonk2);
467 PIGGY_PAGE_IN(bonk2);
469 PIGGY_PAGE_IN(bonk2);
471 PIGGY_PAGE_IN(bonk2);
473 PIGGY_PAGE_IN(bonk2);
476 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
479 //piggy_get_bitmap_name(i,fname);
481 if (GameBitmaps[i].bm_flags & BM_FLAG_PAGED_OUT )
484 // if (GameBitmapXlat[i]!=i)
489 if ( (i==47) || (i==48) ) // Mark red mplayer ship textures as paged in.
493 fprintf( fp, "0,\t// Bitmap %d (%s)\n", i, "test\0"); // cmp debug fname );
495 fprintf( fp, "1,\t// Bitmap %d (%s)\n", i, "test\0"); // cmp debug fname );
502 mprintf(( 0, "done\n" ));
504 //@@ clear_boxed_message();
506 if ( black_screen ) {
508 gr_clear_canvas( BM_XRGB(0,0,0) );
511 reset_cockpit(); //force cockpit redraw next time