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.
21 static char rcsid[] = "$Id: paging.c,v 1.2 2001-01-31 15:17:57 bradleyb Exp $";
62 void paging_touch_vclip_w( vclip * vc )
66 for (i=0; i<vc->num_frames; i++ ) {
67 if ( GameBitmaps[(vc->frames[i]).index].bm_flags & BM_FLAG_PAGED_OUT)
68 piggy_bitmap_page_in_w( vc->frames[i],1 );
74 void paging_touch_vclip( vclip * vc )
78 for (i=0; i<vc->num_frames; i++ ) {
79 PIGGY_PAGE_IN( vc->frames[i] );
84 void paging_touch_wall_effects( int tmap_num )
88 for (i=0;i<Num_effects;i++) {
89 if ( Effects[i].changing_wall_texture == tmap_num ) {
90 paging_touch_vclip( &Effects[i].vc );
92 if (Effects[i].dest_bm_num > -1)
93 PIGGY_PAGE_IN( Textures[Effects[i].dest_bm_num] ); //use this bitmap when monitor destroyed
94 if ( Effects[i].dest_vclip > -1 )
95 paging_touch_vclip( &Vclip[Effects[i].dest_vclip] ); //what vclip to play when exploding
97 if ( Effects[i].dest_eclip > -1 )
98 paging_touch_vclip( &Effects[Effects[i].dest_eclip].vc ); //what eclip to play when exploding
100 if ( Effects[i].crit_clip > -1 )
101 paging_touch_vclip( &Effects[Effects[i].crit_clip].vc ); //what eclip to play when mine critical
107 void paging_touch_object_effects( int tmap_num )
111 for (i=0;i<Num_effects;i++) {
112 if ( Effects[i].changing_object_texture == tmap_num ) {
113 paging_touch_vclip( &Effects[i].vc );
119 void paging_touch_model( int modelnum )
122 polymodel *pm = &Polygon_models[modelnum];
124 for (i=0;i<pm->n_textures;i++) {
125 PIGGY_PAGE_IN( ObjBitmaps[ObjBitmapPtrs[pm->first_texture+i]] );
126 paging_touch_object_effects( ObjBitmapPtrs[pm->first_texture+i] );
127 #ifdef PSX_BUILD_TOOLS
129 paging_touch_object_effects( pm->first_texture+i );
134 void paging_touch_weapon( int weapon_type )
136 // Page in the robot's weapons.
138 if ( (weapon_type < 0) || (weapon_type > N_weapon_types) ) return;
140 if ( Weapon_info[weapon_type].picture.index ) {
141 PIGGY_PAGE_IN( Weapon_info[weapon_type].picture );
144 if ( Weapon_info[weapon_type].flash_vclip > -1 )
145 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].flash_vclip]);
146 if ( Weapon_info[weapon_type].wall_hit_vclip > -1 )
147 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].wall_hit_vclip]);
148 if ( Weapon_info[weapon_type].damage_radius ) {
149 // Robot_hit_vclips are actually badass_vclips
150 if ( Weapon_info[weapon_type].robot_hit_vclip > -1 )
151 paging_touch_vclip(&Vclip[Weapon_info[weapon_type].robot_hit_vclip]);
154 switch( Weapon_info[weapon_type].render_type ) {
155 case WEAPON_RENDER_VCLIP:
156 if ( Weapon_info[weapon_type].weapon_vclip > -1 )
157 paging_touch_vclip( &Vclip[Weapon_info[weapon_type].weapon_vclip] );
159 case WEAPON_RENDER_NONE:
161 case WEAPON_RENDER_POLYMODEL:
162 paging_touch_model( Weapon_info[weapon_type].model_num );
164 case WEAPON_RENDER_BLOB:
165 PIGGY_PAGE_IN( Weapon_info[weapon_type].bitmap );
172 byte super_boss_gate_type_list[13] = {0, 1, 8, 9, 10, 11, 12, 15, 16, 18, 19, 20, 22 };
174 void paging_touch_robot( int robot_index )
178 //mprintf((0, "Robot %d loading...", robot_index));
180 // Page in robot_index
181 paging_touch_model(Robot_info[robot_index].model_num);
182 if ( Robot_info[robot_index].exp1_vclip_num>-1 )
183 paging_touch_vclip(&Vclip[Robot_info[robot_index].exp1_vclip_num]);
184 if ( Robot_info[robot_index].exp2_vclip_num>-1 )
185 paging_touch_vclip(&Vclip[Robot_info[robot_index].exp2_vclip_num]);
187 // Page in his weapons
188 paging_touch_weapon( Robot_info[robot_index].weapon_type );
190 // A super-boss can gate in robots...
191 if ( Robot_info[robot_index].boss_flag==2 ) {
192 for (i=0; i<13; i++ )
193 paging_touch_robot(super_boss_gate_type_list[i]);
195 paging_touch_vclip( &Vclip[VCLIP_MORPHING_ROBOT] );
200 void paging_touch_object( object * obj )
204 switch (obj->render_type) {
206 case RT_NONE: break; //doesn't render, like the player
209 if ( obj->rtype.pobj_info.tmap_override != -1 )
210 PIGGY_PAGE_IN( Textures[obj->rtype.pobj_info.tmap_override] );
212 paging_touch_model(obj->rtype.pobj_info.model_num);
216 if ( obj->rtype.vclip_info.vclip_num > -1 ) {
218 //@@ paging_touch_vclip_w(&Vclip[obj->rtype.vclip_info.vclip_num]);
220 paging_touch_vclip(&Vclip[obj->rtype.vclip_info.vclip_num]);
225 case RT_MORPH: break;
227 case RT_FIREBALL: break;
229 case RT_WEAPON_VCLIP: break;
232 paging_touch_vclip(&Vclip[obj->rtype.vclip_info.vclip_num]);
235 case RT_LASER: break;
240 v = get_explosion_vclip(obj, 0);
242 paging_touch_vclip(&Vclip[v]);
245 paging_touch_robot( obj->id );
248 paging_touch_weapon( CONTROLCEN_WEAPON_NUM );
249 if (Dead_modelnums[obj->rtype.pobj_info.model_num] != -1) {
250 paging_touch_model( Dead_modelnums[obj->rtype.pobj_info.model_num] );
258 void paging_touch_side( segment * segp, int sidenum )
262 if (!(WALL_IS_DOORWAY(segp,sidenum) & WID_RENDER_FLAG))
265 tmap1 = segp->sides[sidenum].tmap_num;
266 paging_touch_wall_effects(tmap1);
267 tmap2 = segp->sides[sidenum].tmap_num2;
269 texmerge_get_cached_bitmap( tmap1, tmap2 );
270 paging_touch_wall_effects( tmap2 & 0x3FFF );
272 PIGGY_PAGE_IN( Textures[tmap1] );
276 #ifdef PSX_BUILD_TOOLS
277 // If there is water on the level, then force the water splash into memory
278 if(!(TmapInfo[tmap1].flags & TMI_VOLATILE) && (TmapInfo[tmap1].flags & TMI_WATER)) {
281 PIGGY_PAGE_IN(Splash);
283 PIGGY_PAGE_IN(Splash);
285 PIGGY_PAGE_IN(Splash);
287 PIGGY_PAGE_IN(Splash);
289 PIGGY_PAGE_IN(Splash);
295 void paging_touch_robot_maker( segment * segp )
297 segment2 *seg2p = &Segment2s[segp-Segments];
299 if ( seg2p->special == SEGMENT_IS_ROBOTMAKER ) {
300 paging_touch_vclip(&Vclip[VCLIP_MORPHING_ROBOT]);
301 if (RobotCenters[seg2p->matcen_num].robot_flags != 0) {
308 flags = RobotCenters[seg2p->matcen_num].robot_flags[i];
311 // Page in robot_index
312 paging_touch_robot( robot_index );
323 void paging_touch_segment(segment * segp)
327 segment2 *seg2p = &Segment2s[segp-Segments];
329 if ( seg2p->special == SEGMENT_IS_ROBOTMAKER )
330 paging_touch_robot_maker(segp);
332 // paging_draw_orb();
333 for (sn=0;sn<MAX_SIDES_PER_SEGMENT;sn++) {
334 // paging_draw_orb();
335 paging_touch_side( segp, sn );
338 for (objnum=segp->objects;objnum!=-1;objnum=Objects[objnum].next) {
339 // paging_draw_orb();
340 paging_touch_object( &Objects[objnum] );
346 void paging_touch_walls()
351 for (i=0;i<Num_walls;i++) {
352 // paging_draw_orb();
353 if ( Walls[i].clip_num > -1 ) {
354 anim = &WallAnims[Walls[i].clip_num];
355 for (j=0; j < anim->num_frames; j++ ) {
356 PIGGY_PAGE_IN( Textures[anim->frames[j]] );
362 void paging_touch_all()
369 black_screen = gr_palette_faded_out;
371 if ( gr_palette_faded_out ) {
372 gr_clear_canvas( BM_XRGB(0,0,0) );
373 gr_palette_load( gr_palette );
376 //@@ show_boxed_message(TXT_LOADING);
378 mprintf(( 0, "Loading all textures in mine..." ));
379 for (s=0; s<=Highest_segment_index; s++) {
380 paging_touch_segment( &Segments[s] );
382 paging_touch_walls();
384 for ( s=0; s < N_powerup_types; s++ ) {
385 if ( Powerup_info[s].vclip_num > -1 )
386 paging_touch_vclip(&Vclip[Powerup_info[s].vclip_num]);
389 for ( s=0; s<N_weapon_types; s++ ) {
390 paging_touch_weapon(s);
393 for ( s=0; s < N_powerup_types; s++ ) {
394 if ( Powerup_info[s].vclip_num > -1 )
395 paging_touch_vclip(&Vclip[Powerup_info[s].vclip_num]);
399 for (s=0; s<MAX_GAUGE_BMS; s++ ) {
400 if ( Gauges[s].index ) {
401 PIGGY_PAGE_IN( Gauges[s] );
404 paging_touch_vclip( &Vclip[VCLIP_PLAYER_APPEARANCE] );
405 paging_touch_vclip( &Vclip[VCLIP_POWERUP_DISAPPEARANCE] );
408 #ifdef PSX_BUILD_TOOLS
411 paging_touch_walls();
412 for(s=0; s<=Highest_object_index; s++) {
413 paging_touch_object(&Objects[s]);
419 extern int Current_level_num;
420 extern ushort GameBitmapXlat[MAX_BITMAP_FILES];
421 short Used[MAX_BITMAP_FILES];
426 if (Current_level_num<0) //secret level
427 strcpy( fname, Secret_level_names[-Current_level_num-1] );
429 strcpy( fname, Level_names[Current_level_num-1] );
430 p = strchr( fname, '.' );
432 strcat( fname, ".pag" );
434 fp = fopen( fname, "wt" );
435 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
438 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
439 Used[GameBitmapXlat[i]]++;
442 //cmp added so that .damage bitmaps are included for paged-in lights of the current level
443 for (i=0; i<MAX_TEXTURES;i++) {
444 if(Textures[i].index > 0 && Textures[i].index < MAX_BITMAP_FILES &&
445 Used[Textures[i].index] > 0 &&
446 TmapInfo[i].destroyed > 0 && TmapInfo[i].destroyed < MAX_BITMAP_FILES) {
447 Used[Textures[TmapInfo[i].destroyed].index] += 1;
448 mprintf((0, "HERE %d ", Textures[TmapInfo[i].destroyed].index));
450 PIGGY_PAGE_IN(Textures[TmapInfo[i].destroyed]);
455 // Force cockpit to be paged in.
462 // Force in the frames for markers
466 PIGGY_PAGE_IN(bonk2);
468 PIGGY_PAGE_IN(bonk2);
470 PIGGY_PAGE_IN(bonk2);
472 PIGGY_PAGE_IN(bonk2);
474 PIGGY_PAGE_IN(bonk2);
477 for (i=0; i<MAX_BITMAP_FILES;i++ ) {
480 //piggy_get_bitmap_name(i,fname);
482 if (GameBitmaps[i].bm_flags & BM_FLAG_PAGED_OUT )
485 // if (GameBitmapXlat[i]!=i)
490 if ( (i==47) || (i==48) ) // Mark red mplayer ship textures as paged in.
494 fprintf( fp, "0,\t// Bitmap %d (%s)\n", i, "test\0"); // cmp debug fname );
496 fprintf( fp, "1,\t// Bitmap %d (%s)\n", i, "test\0"); // cmp debug fname );
503 mprintf(( 0, "done\n" ));
505 //@@ clear_boxed_message();
507 if ( black_screen ) {
509 gr_clear_canvas( BM_XRGB(0,0,0) );
512 reset_cockpit(); //force cockpit redraw next time