コード例 #1
0
ファイル: palw32.c プロジェクト: paud/d2x-xl
int GrPaletteFadeIn(ubyte *pal, int nsteps, int allow_keys)
{
	int i,j, k;
//	ubyte c;
	fix fade_palette[768];
	fix fade_palette_delta[768];

	PALETTEENTRY pe[256];

	allow_keys  = allow_keys;

	if (!gameStates.render.bPaletteFadedOut) return 0;

	if (pal==NULL) pal=gr_current_pal;


	for (i=0; i<768; i++ )	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i]) / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		for (i=0, k = 0; k<256; k++ )	{
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] < 0 )
				fade_palette[i] = 0;
			if (fade_palette[i] > i2f(pal[i] + gameData.render.nPaletteGamma) )
				fade_palette[i] = i2f(pal[i] + gameData.render.nPaletteGamma);

			pe[k].peRed = min(f2i(fade_palette[i]), 63) * 4;
 			i++;
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] < 0 )
				fade_palette[i] = 0;
			if (fade_palette[i] > i2f(pal[i] + gameData.render.nPaletteGamma) )
				fade_palette[i] = i2f(pal[i] + gameData.render.nPaletteGamma);

			pe[k].peGreen = min(f2i(fade_palette[i]), 63) * 4;
 			i++;
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] < 0 )
				fade_palette[i] = 0;
			if (fade_palette[i] > i2f(pal[i] + gameData.render.nPaletteGamma) )
				fade_palette[i] = i2f(pal[i] + gameData.render.nPaletteGamma);

			pe[k].peBlue = min(f2i(fade_palette[i]), 63) * 4;
			pe[k].peFlags = 0;
 			i++;
		}

		Win32_DoSetPalette (pe);
		//added on 7/11/99 by adb to allow fade in on non-palette displays
		Win32_MakePalVisible ();
		//end additions - adb
	}

	gameStates.render.bPaletteFadedOut = 0;
	return 0;
}
コード例 #2
0
ファイル: tmapflat.c プロジェクト: paud/d2x-xl
//this takes the same partms as draw_tmap, but draws a flat-shaded polygon
void DrawTexPolyFlat(grsBitmap *bp,int nverts,g3sPoint **vertbuf)
{
	pnt2d	points[MAX_TMAP_VERTS];
	int	i;
	fix	average_light;
	int	color;

	Assert(nverts < MAX_TMAP_VERTS);

	average_light = vertbuf[0]->p3_uvl.l;
	for (i=1; i<nverts; i++)
		average_light += vertbuf[i]->p3_uvl.l;

	if (nverts == 4)
		average_light = f2i(average_light * NUM_LIGHTING_LEVELS/4);
	else
		average_light = f2i(average_light * NUM_LIGHTING_LEVELS/nverts);

	if (average_light < 0)
		average_light = 0;
	else if (average_light > NUM_LIGHTING_LEVELS-1)
		average_light = NUM_LIGHTING_LEVELS-1;

	color = grFadeTable[average_light*256 + bp->bmAvgColor];
	GrSetColor(color);

	for (i=0;i<nverts;i++) {
		points[i].x = vertbuf[i]->p3_screen.x;
		points[i].y = vertbuf[i]->p3_screen.y;
	}

	gr_upoly_tmap(nverts,(int *) points);

}
コード例 #3
0
ファイル: line.c プロジェクト: paud/d2x-xl
//unclipped version just calls clipping version for now
int gr_uline(fix _a1, fix _b1, fix _a2, fix _b2)
{
	int a1,b1,a2,b2;
	a1 = f2i(_a1); b1 = f2i(_b1); a2 = f2i(_a2); b2 = f2i(_b2);
	switch(TYPE)
	{
	case BM_OGL:
		OglULineC(a1,b1,a2,b2,&COLOR);
		return 0;
	case BM_LINEAR:
#ifdef NO_ASM
		gr_universal_uline( a1,b1,a2,b2);
#else
		gr_linear_line( a1, b1, a2, b2 );
#endif
		return 0;
#ifdef __DJGPP__
	case BM_MODEX:
		modex_line_x1 = a1+XOFFSET;
		modex_line_y1 = b1+YOFFSET;
		modex_line_x2 = a2+XOFFSET;
		modex_line_y2 = b2+YOFFSET;
		modex_line_Color = grdCurCanv->cv_color;
		gr_modex_line();
		return 0;
	default:
		gr_universal_uline( a1, b1, a2, b2 );
		return 0;
#endif
	}
	return 2;
}
コード例 #4
0
ファイル: hostage.c プロジェクト: CDarrow/Spectator-JinX
//------------- Called once per frame to do the hostage effects --------------------------------
//returns true if something drew
int do_hostage_effects()
{
	int bitmapnum;

	// Don't do the effect if the time is <= 0
	if ( Hostage_animation_time < 0 )
		return 0;

	// Find next bitmap in the vclip
	bitmapnum = f2i(Hostage_animation_time);

	// Check if vclip is done playing.
	if (bitmapnum >= Hostage_vclip->num_frames)		{
		stop_hostage_clip();

		if (Hostage_animation_time >= 0)		//new clip
			bitmapnum = f2i(Hostage_animation_time);
		else
			return 0;		//no new one
	}

	get_hostage_window_coords(&Hostage_monitor_x,&Hostage_monitor_y,&Hostage_monitor_w,&Hostage_monitor_h);

	PIGGY_PAGE_IN(Hostage_vclip->frames[bitmapnum]);	
	gr_bitmap(Hostage_monitor_x,Hostage_monitor_y,Hostage_vclip->frames[bitmapnum]);

	// Increment the hostage rescue time scaled to playback speed.
	// This means that the integer part of the fix is the frame number
	// of the animation.

	Hostage_animation_time += fixmul(FrameTime,HostagePlaybackSpeed);

	return 1;
}
コード例 #5
0
ファイル: scanline.c プロジェクト: jihnsius/d2r
void c_tmap_scanline_lin_nolight()
{
    ubyte *dest;
    uint c;
    int x, index = fx_xleft + (bytes_per_row * fx_y );
    fix u,v,dudx, dvdx;

    u = fx_u;
    v = fx_v*64;
    dudx = fx_du_dx;
    dvdx = fx_dv_dx*64;

    dest = (ubyte *)(write_buffer + fx_xleft + (bytes_per_row * fx_y)  );

    if (!Transparency_on)	{
        for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
            if (++index >= SWIDTH*SHEIGHT) return;
            *dest++ = (uint)pixptr[ (f2i(v)&(64*63)) + (f2i(u)&63) ];
            u += dudx;
            v += dvdx;
        }
    } else {
        for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
            if (++index >= SWIDTH*SHEIGHT) return;
            c = (uint)pixptr[ (f2i(v)&(64*63)) + (f2i(u)&63) ];
            if ( c!=255)
                *dest = c;
            dest++;
            u += dudx;
            v += dvdx;
        }
    }
}
コード例 #6
0
ファイル: scale.c プロジェクト: arbruijn/d1xnacl
void scale_bitmap_cc_asm_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0,  fix u1, fix v1  )
{
	fix dv, v;
	int y, last_row = -1;

	dv = (v1-v0) / (y1-y0);
		
	rls_stretch_scanline_setup( (int)(x1-x0), f2i(u1)-f2i(u0) );
	if ( scale_ydelta_minus_1 < 1 ) return;
	rls_do_cc_setup_asm();

	v = v0;

	for (y=y0; y<=y1; y++ )			{
		if ( f2i(v) != last_row )	{
			last_row = f2i(v);
			decode_row( source_bmp, last_row );
		}
		//scale_source_ptr = &source_bmp->bm_data[source_bmp->bm_rowsize*f2i(v)+f2i(u0)];
		scale_source_ptr = &scale_rle_data[f2i(u0)];
		scale_dest_ptr = &dest_bmp->bm_data[dest_bmp->bm_rowsize*y+x0];
		scale_do_cc_scanline();
		v += dv;
	}
}
コード例 #7
0
ファイル: radar.c プロジェクト: btb/d1x
void radar_plot_object( object * objp, int hue )
{
	ubyte flags;
	g3s_point pos;
	int color;
	fix dist, rscale, zdist, distance;
	int xpos, ypos;

	flags = g3_rotate_point(&pos,&objp->pos);
	dist = vm_vec_mag_quick(&pos.p3_vec);

        // Make distance be 1.0 to 0.0, where 0.0 is maximum segments away;
	if ( dist >= Radar_farthest_dist ) return;
	distance = F1_0 - fixdiv( dist, Radar_farthest_dist );
	color = f2i( distance*31 );

	zdist = fix_sqrt( fixmul(pos.p3_x,pos.p3_x)+fixmul(pos.p3_y,pos.p3_y) );
	if (zdist < 100 ) return;		// Watch for divide overflow

	rscale = fix_acos( fixdiv(pos.p3_z,dist) )/2;

	xpos = f2i(fixmul( rox+fixmul(fixdiv(pos.p3_x,zdist),rscale), radx));
	ypos = f2i(fixmul( roy-fixmul(fixdiv(pos.p3_y,zdist),rscale), rady));

	if ( xpos < Hostage_monitor_x ) xpos = Hostage_monitor_x;
	if ( ypos < Hostage_monitor_y ) ypos = Hostage_monitor_y;
        if ( xpos > Hostage_monitor_x+Hostage_monitor_size-1 ) xpos = Hostage_monitor_x+Hostage_monitor_size-1;
        if ( ypos > Hostage_monitor_y+Hostage_monitor_size-1 ) ypos = Hostage_monitor_y+Hostage_monitor_size-1;

	Blips[N_blips].c = gr_fade_table[hue+color*256];
	Blips[N_blips].x = xpos; Blips[N_blips].y = ypos;
	N_blips++;
}
コード例 #8
0
ファイル: scalec.cpp プロジェクト: Foran/dxx-rebirth
void scale_up_bitmap_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0,  fix u1, fix v1, int orientation  )
{
	fix dv, v;
	int y, last_row = -1;

	if (orientation & 1) {
		int	t;
		t = u0;	u0 = u1;	u1 = t;
	}

	if (orientation & 2) {
		int	t;
		t = v0;	v0 = v1;	v1 = t;
		if (v1 < v0)
			v0--;
	}

	dv = (v1-v0) / (y1-y0);

	rls_stretch_scanline_setup( (int)(x1-x0), f2i(u1)-f2i(u0) );
	if ( scale_ydelta_minus_1 < 1 ) return;

	v = v0;

	for (y=y0; y<=y1; y++ )			{
		if ( f2i(v) != last_row )	{
			last_row = f2i(v);
			decode_row( source_bmp, last_row );
		}
		scale_source_ptr = &scale_rle_data[f2i(u0)];
		scale_dest_ptr = &dest_bmp->bm_data[dest_bmp->bm_rowsize*y+x0];
		rls_stretch_scanline( );
		v += dv;
	}
}
コード例 #9
0
ファイル: hud.c プロジェクト: jihnsius/d2r
void player_dead_message(void)
{
	if (!(Game_mode & GM_CAPTURE))
	{
		if (Player_exploded) {
			if ( Players[Player_num].lives < 2 )    {
				int x, y, w, h, aw;
				gr_set_curfont( HUGE_FONT );
				gr_get_string_size( TXT_GAME_OVER, &w, &h, &aw );
				w += 20;
				h += 8;
				x = (grd_curcanv->cv_bitmap.bm_w - w ) / 2;
				y = (grd_curcanv->cv_bitmap.bm_h - h ) / 2;
			
				gr_settransblend(14, GR_BLEND_NORMAL);
				gr_setcolor( BM_XRGB(0,0,0) );
				gr_rect( x, y, x+w, y+h );
				gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
			
				gr_printf(0x8000, (GHEIGHT - h)/2 + h/8, TXT_GAME_OVER );
			}
		
			gr_set_curfont( GAME_FONT );
			if (HUD_color == -1)
				HUD_color = BM_XRGB(0,28,0);
			gr_set_fontcolor( HUD_color, -1);
			gr_printf(0x8000, GHEIGHT-LINE_SPACING, TXT_PRESS_ANY_KEY);
		}
	}
	extern int player_spawn_timer;
	if (Game_mode & GM_CAPTURE)
	{
		if (Player_exploded) {
			if ( Players[Player_num].lives < 2 )    {
				int x, y, w, h, aw;
				gr_set_curfont( HUGE_FONT );
				gr_get_string_size( TXT_GAME_OVER, &w, &h, &aw );
				w += 20;
				h += 8;
				x = (grd_curcanv->cv_bitmap.bm_w - w ) / 2;
				y = (grd_curcanv->cv_bitmap.bm_h - h ) / 2;
			
				gr_settransblend(14, GR_BLEND_NORMAL);
				gr_setcolor( BM_XRGB(0,0,0) );
				gr_rect( x, y, x+w, y+h );
				gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
			
				gr_printf(0x8000, (GHEIGHT - h)/2 + h/8, TXT_GAME_OVER );
			}
		
			gr_set_curfont( GAME_FONT );
			if (HUD_color == -1)
				HUD_color = BM_XRGB(0,28,0);
			gr_set_fontcolor( HUD_color, -1);
			if (((player_spawn_timer + Netgame.RespawnTime*5) > f2i(Players[Player_num].time_level)) && force_respawn == 0) gr_printf(0x8000, GHEIGHT-LINE_SPACING, "You must wait %d seconds to respawn.", (player_spawn_timer + (Netgame.RespawnTime*5)) - f2i(Players[Player_num].time_level));
			if (((player_spawn_timer + Netgame.RespawnTime*5) > f2i(Players[Player_num].time_level)) && force_respawn == 1) gr_printf(0x8000, GHEIGHT-LINE_SPACING, "You will respawn in %d seconds.", (player_spawn_timer + (Netgame.RespawnTime*5)) - f2i(Players[Player_num].time_level));
			if ((player_spawn_timer + Netgame.RespawnTime*5) <= f2i(Players[Player_num].time_level)) gr_printf(0x8000, GHEIGHT-LINE_SPACING, "Press any key or button to respawn.");
		}
	}
}
コード例 #10
0
ファイル: tmapflat.c プロジェクト: btb/d1x
//this takes the same partms as draw_tmap, but draws a flat-shaded polygon
void draw_tmap_flat(grs_bitmap *bp,int nverts,g3s_point **vertbuf)
{
	pnt2d	points[MAX_TMAP_VERTS];
	int	i;
	fix	average_light;
	int	color;

	Assert(nverts < MAX_TMAP_VERTS);

	average_light = vertbuf[0]->p3_l;
	for (i=1; i<nverts; i++)
		average_light += vertbuf[i]->p3_l;

	if (nverts == 4)
		average_light = f2i(average_light * NUM_LIGHTING_LEVELS/4);
	else
		average_light = f2i(average_light * NUM_LIGHTING_LEVELS/nverts);

	if (average_light < 0)
		average_light = 0;
	else if (average_light > NUM_LIGHTING_LEVELS-1)
		average_light = NUM_LIGHTING_LEVELS-1;

	color = gr_fade_table[average_light*256 + bp->avg_color];
	gr_setcolor(color);

	for (i=0;i<nverts;i++) {
		points[i].x = vertbuf[i]->p3_sx;
		points[i].y = vertbuf[i]->p3_sy;
	}

	gr_upoly_tmap(nverts,(int *) points);

}
コード例 #11
0
ファイル: scalec.c プロジェクト: paud/d2x-xl
void scale_up_bitmap(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0,  fix u1, fix v1, int orientation  )
{
	fix dv, v;
	int y;

	if (orientation & 1) {
		int	t;
		t = u0;	u0 = u1;	u1 = t;
	}

	if (orientation & 2) {
		int	t;
		t = v0;	v0 = v1;	v1 = t;
		if (v1 < v0)
			v0--;
	}

	v = v0;

	dv = (v1-v0) / (y1-y0);

	rls_stretch_scanline_setup( (int)(x1-x0), f2i(u1)-f2i(u0) );
	if ( scale_ydelta_minus_1 < 1 ) return;

	v = v0;

	for (y=y0; y<=y1; y++ )			{
		scale_source_ptr = &source_bmp->bm_texBuf[source_bmp->bm_props.rowsize*f2i(v)+f2i(u0)];
		scale_dest_ptr = &dest_bmp->bm_texBuf[dest_bmp->bm_props.rowsize*y+x0];
		rls_stretch_scanline();
		v += dv;
	}
}
コード例 #12
0
ファイル: gamecntl.c プロジェクト: nightwish75/d2x-ta
int do_game_pause()
{
	char *msg;
	char total_time[9],level_time[9];

#ifdef NETWORK
	if (Game_mode & GM_MULTI)
	{
		netplayerinfo_on= !netplayerinfo_on;
		return(KEY_PAUSE);
	}
#endif

	MALLOC(msg, char, 1024);
	if (!msg)
		return 0;

	songs_pause();

	format_time(total_time, f2i(Players[Player_num].time_total) + Players[Player_num].hours_total*3600);
	format_time(level_time, f2i(Players[Player_num].time_level) + Players[Player_num].hours_level*3600);
	if (Newdemo_state!=ND_STATE_PLAYBACK)
		snprintf(msg,1024,"PAUSE\n\nSkill level:  %s\nHostages on board:  %d\nTime on level: %s\nTotal time in game: %s",MENU_DIFFICULTY_TEXT(Difficulty_level),Players[Player_num].hostages_on_board,level_time,total_time);
	else
	  	snprintf(msg,1024,"PAUSE\n\nSkill level:  %s\nHostages on board:  %d\n",MENU_DIFFICULTY_TEXT(Difficulty_level),Players[Player_num].hostages_on_board);
	set_screen_mode(SCREEN_MENU);

	if (!window_create(&grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, (int (*)(window *, d_event *, void *))pause_handler, msg))
		d_free(msg);

	return 0 /*key*/;	// Keycode returning ripped out (kreatordxx)
}
コード例 #13
0
ファイル: LINE.C プロジェクト: devint1/descent-win
//unclipped version just calls clipping version for now
int gr_uline(fix _a1, fix _b1, fix _a2, fix _b2) {
	int a1, b1, a2, b2;
	a1 = f2i(_a1); b1 = f2i(_b1); a2 = f2i(_a2); b2 = f2i(_b2);

	//	gr_linear_line( a1, b1, a2, b2 );
	gr_universal_uline(a1, b1, a2, b2);
	return 0;
}
コード例 #14
0
ファイル: scalec.cpp プロジェクト: Foran/dxx-rebirth
static void scale_row_transparent( ubyte * sbits, ubyte * dbits, int width, fix u, fix du )
{
	int i;
	ubyte c;
	ubyte *dbits_end = &dbits[width-1];

	if ( du < F1_0 )	{
		// Scaling up.
		fix next_u;
		int next_u_int;

		next_u_int = f2i(u)+1;
		c = sbits[ next_u_int ];
		next_u = i2f(next_u_int);
		if ( c != TRANSPARENCY_COLOR ) goto NonTransparent;

Transparent:
		while (1)	{
			dbits++;
			if ( dbits > dbits_end ) return;
			u += du;
			if ( u > next_u )	{
				next_u_int = f2i(u)+1;
				c = sbits[ next_u_int ];
				next_u = i2f(next_u_int);
				if ( c != TRANSPARENCY_COLOR ) goto NonTransparent;
			}
		}
		return;

NonTransparent:
		while (1)	{
			*dbits++ = c;
			if ( dbits > dbits_end ) return;
			u += du;
			if ( u > next_u )	{
				next_u_int = f2i(u)+1;
				c = sbits[ next_u_int ];
				next_u = i2f(next_u_int);
				if ( c == TRANSPARENCY_COLOR ) goto Transparent;
			}
		}
		return;



	} else {
		for ( i=0; i<width; i++ )	{
			c = sbits[ f2i(u) ];

			if ( c != TRANSPARENCY_COLOR )
				*dbits = c;

			dbits++;
			u += du;
		}
	}
}
コード例 #15
0
ファイル: palw32.c プロジェクト: paud/d2x-xl
int GrPaletteFadeOut(ubyte *pal, int nsteps, int allow_keys )
{
	int i,j,k;
	fix fade_palette[768];
	fix fade_palette_delta[768];
	PALETTEENTRY pe[256];

	allow_keys  = allow_keys;

	if (gameStates.render.bPaletteFadedOut) return 0;

	if (pal==NULL) pal=gr_current_pal;

	for (i=0; i<768; i++ )
	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = i2f(pal[i]);
		fade_palette_delta[i] = fade_palette[i] / nsteps;
	}

	for (j=0; j<nsteps; j++ )
	{
		for (i=0, k = 0; k < 256; k++)
		{
			fade_palette[i] -= fade_palette_delta[i];
			if (fade_palette[i] < 0 )
				fade_palette[i] = 0;
			if (fade_palette[i] > i2f(pal[i] + gameData.render.nPaletteGamma) )
				fade_palette[i] = i2f(pal[i] + gameData.render.nPaletteGamma);

			pe[k].peRed = min(f2i(fade_palette[i]), 63) * 4;
 			i++;
			fade_palette[i] -= fade_palette_delta[i];
			if (fade_palette[i] < 0 )
				fade_palette[i] = 0;
			if (fade_palette[i] > i2f(pal[i] + gameData.render.nPaletteGamma) )
				fade_palette[i] = i2f(pal[i] + gameData.render.nPaletteGamma);

			pe[k].peGreen = min(f2i(fade_palette[i]), 63) * 4;
 			i++;
			fade_palette[i] -= fade_palette_delta[i];
			if (fade_palette[i] < 0 )
				fade_palette[i] = 0;
			if (fade_palette[i] > i2f(pal[i] + gameData.render.nPaletteGamma) )
				fade_palette[i] = i2f(pal[i] + gameData.render.nPaletteGamma);

			pe[k].peBlue = min(f2i(fade_palette[i]), 63) * 4;
			pe[k].peFlags = 0;
 			i++;
		}

		Win32_DoSetPalette (pe);
		Win32_MakePalVisible ();
	}

	gameStates.render.bPaletteFadedOut = 1;
	return 0;
}
コード例 #16
0
ファイル: gr.c プロジェクト: Ringdingcoder/d1x
int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys)
{
 int i, j, k;
 ubyte c;
 fix fade_palette[768];
 fix fade_palette_delta[768];

 SDL_Palette *palette;
 SDL_Color fade_colors[256];

 if (gr_palette_faded_out) return 0;

 palette = screen->format->palette;
 if (palette == NULL) {
    return -1; // Display is not palettised
 }

 if (pal==NULL) pal=gr_current_pal;

 for (i=0; i<768; i++ )	{
     gr_current_pal[i] = pal[i];
     fade_palette[i] = i2f(pal[i]);
     fade_palette_delta[i] = fade_palette[i] / nsteps;
 }
 for (j=0; j<nsteps; j++ )	{
     for (i=0, k = 0; k<256; k++ )	{
         fade_palette[i] -= fade_palette_delta[i];
         if (fade_palette[i] > i2f(pal[i] + gr_palette_gamma) )
            fade_palette[i] = i2f(pal[i] + gr_palette_gamma);
	 c = f2i(fade_palette[i]);
         if (c > 63) c = 63;
         fade_colors[k].r = c * 4;
         i++;

         fade_palette[i] -= fade_palette_delta[i];
         if (fade_palette[i] > i2f(pal[i] + gr_palette_gamma) )
            fade_palette[i] = i2f(pal[i] + gr_palette_gamma);
	 c = f2i(fade_palette[i]);
         if (c > 63) c = 63;
         fade_colors[k].g = c * 4;
         i++;

         fade_palette[i] -= fade_palette_delta[i];
         if (fade_palette[i] > i2f(pal[i] + gr_palette_gamma) )
            fade_palette[i] = i2f(pal[i] + gr_palette_gamma);
	 c = f2i(fade_palette[i]);
         if (c > 63) c = 63;
         fade_colors[k].b = c * 4;
         i++;
     }

  SDL_SetColors(screen, fade_colors, 0, 256);
 }

 gr_palette_faded_out = 1;
 return 0;
}
コード例 #17
0
ファイル: 3dfx.c プロジェクト: gameplayer22/d2x-1
void _3dfx_BlitScale( grs_bitmap *source_bmp, grs_bitmap *dest_bmp,
                      int x0, int y0, int x1, int y1,
                      fix u0, fix v0, fix u1, fix v1, int orient )
{
   if ( _3dfx_available )
   {
      if ( source_bmp->bm_flags & BM_FLAG_RLE )
      {
         fix u, v, du, dv;
         int x, y;
         ubyte * sbits;
         unsigned long * dbits;
         unsigned long * fb;

         du = (u1-u0) / (x1-x0);
         dv = (v1-v0) / (y1-y0);

         v = v0;

         grLfbBegin();

         grLfbBypassMode( GR_LFBBYPASS_ENABLE );

         fb = ( unsigned long * ) grLfbGetWritePtr( GR_BUFFER_BACKBUFFER );
         grLfbWriteMode( GR_LFBWRITEMODE_8888 );

         guColorCombineFunction( GR_COLORCOMBINE_DECAL_TEXTURE );

         for ( y = y0; y <= y1; y++, v += dv )
         {
            extern ubyte scale_rle_data[];

            decode_row( source_bmp, f2i( v ) );

            sbits = scale_rle_data + f2i( u0 );
            dbits = fb + _3DFX_FB_WIDTH * y + x0;

            u = u0;

            for ( x = x0; x <= x1; x++ )
            {
               int pindex = sbits[ u >> 16 ];

               if ( pindex != 255 )
                  *dbits = _3dfx_PaletteToARGB( pindex );

               dbits++;
               u += du;
            }
         }
         grLfbBypassMode( GR_LFBBYPASS_DISABLE );

         grLfbEnd();
      }
      else
      {
コード例 #18
0
ファイル: gamecntl.c プロジェクト: Mako88/DXX-Retro
void do_cheat_menu()
{
	int mmn;
	newmenu_item mm[16];
	char score_text[21];

	sprintf( score_text, "%d", Players[Player_num].score );

	mm[0].type=NM_TYPE_CHECK; mm[0].value=Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE; mm[0].text="Invulnerability";
	mm[1].type=NM_TYPE_CHECK; mm[1].value=Players[Player_num].flags & PLAYER_FLAGS_CLOAKED; mm[1].text="Cloaked";
	mm[2].type=NM_TYPE_CHECK; mm[2].value=0; mm[2].text="All keys";
	mm[3].type=NM_TYPE_NUMBER; mm[3].value=f2i(Players[Player_num].energy); mm[3].text="% Energy"; mm[3].min_value=0; mm[3].max_value=200;
	mm[4].type=NM_TYPE_NUMBER; mm[4].value=f2i(Players[Player_num].shields); mm[4].text="% Shields"; mm[4].min_value=0; mm[4].max_value=200;
	mm[5].type=NM_TYPE_TEXT; mm[5].text = "Score:";
	mm[6].type=NM_TYPE_INPUT; mm[6].text_len = 10; mm[6].text = score_text;
	mm[7].type=NM_TYPE_RADIO; mm[7].value=(Players[Player_num].laser_level==0); mm[7].group=0; mm[7].text="Laser level 1";
	mm[8].type=NM_TYPE_RADIO; mm[8].value=(Players[Player_num].laser_level==1); mm[8].group=0; mm[8].text="Laser level 2";
	mm[9].type=NM_TYPE_RADIO; mm[9].value=(Players[Player_num].laser_level==2); mm[9].group=0; mm[9].text="Laser level 3";
	mm[10].type=NM_TYPE_RADIO; mm[10].value=(Players[Player_num].laser_level==3); mm[10].group=0; mm[10].text="Laser level 4";
	mm[11].type=NM_TYPE_NUMBER; mm[11].value=Players[Player_num].secondary_ammo[CONCUSSION_INDEX]; mm[11].text="Missiles"; mm[11].min_value=0; mm[11].max_value=200;

	mmn = newmenu_do("Wimp Menu",NULL,12, mm, NULL, NULL );

	if (mmn > -1 )  {
		if ( mm[0].value )  {
			Players[Player_num].flags |= PLAYER_FLAGS_INVULNERABLE;
			Players[Player_num].invulnerable_time = GameTime64+i2f(1000);
		} else
			Players[Player_num].flags &= ~PLAYER_FLAGS_INVULNERABLE;
		if ( mm[1].value )
		{
			Players[Player_num].flags |= PLAYER_FLAGS_CLOAKED;
			#ifdef NETWORK
			if (Game_mode & GM_MULTI)
				multi_send_cloak();
			#endif
			ai_do_cloak_stuff();
			Players[Player_num].cloak_time = GameTime64;
		}
		else
			Players[Player_num].flags &= ~PLAYER_FLAGS_CLOAKED;

		if (mm[2].value) Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
		Players[Player_num].energy=i2f(mm[3].value);
		Players[Player_num].shields=i2f(mm[4].value);
		Players[Player_num].score = atoi(mm[6].text);
		if (mm[7].value) Players[Player_num].laser_level=0;
		if (mm[8].value) Players[Player_num].laser_level=1;
		if (mm[9].value) Players[Player_num].laser_level=2;
		if (mm[10].value) Players[Player_num].laser_level=3;
		Players[Player_num].secondary_ammo[CONCUSSION_INDEX] = mm[11].value;
		init_gauges();
	}
}
コード例 #19
0
void draw_stars()
{
	int i;
	int intensity=31;
	g3s_point p;

	for (i=0;i<MAX_STARS;i++) {

		if ((i&63) == 0) {
			gr_setcolor(BM_XRGB(intensity,intensity,intensity));
			intensity-=3;
		}			

		//g3_rotate_point(&p,&stars[i]);
		g3_rotate_delta_vec(&p.p3_vec,&stars[i]);
		g3_code_point(&p);

		if (p.p3_codes == 0) {

			p.p3_flags &= ~PF_PROJECTED;

			g3_project_point(&p);
#ifndef OGL
			gr_pixel(f2i(p.p3_sx),f2i(p.p3_sy));
#else
			g3_draw_sphere(&p,F1_0*3);
#endif
		}
	}

//@@	{
//@@		vms_vector delta;
//@@		g3s_point top_pnt;
//@@
//@@		g3_rotate_point(&p,&satellite_pos);
//@@		g3_rotate_delta_vec(&delta,&satellite_upvec);
//@@
//@@		g3_add_delta_vec(&top_pnt,&p,&delta);
//@@
//@@		if (! (p.p3_codes & CC_BEHIND)) {
//@@			int save_im = Interpolation_method;
//@@			Interpolation_method = 0;
//@@			//p.p3_flags &= ~PF_PROJECTED;
//@@			g3_project_point(&p);
//@@			if (! (p.p3_flags & PF_OVERFLOW))
//@@				//gr_bitmapm(f2i(p.p3_sx)-32,f2i(p.p3_sy)-32,satellite_bitmap);
//@@				g3_draw_rod_tmap(satellite_bitmap,&p,SATELLITE_WIDTH,&top_pnt,SATELLITE_WIDTH,f1_0);
//@@			Interpolation_method = save_im;
//@@		}
//@@	}

}
コード例 #20
0
ファイル: downloader.cpp プロジェクト: WPN-XM/WPN-XM
void Downloader::updateSpeed(NetFile *file, Timer *timer)
{
    if(ui)
    {
        double speed = (double)file->bytesDownloaded / ((double)timer->totalElapsed() / 1000.0);
        double rtime = (double)(filesSize - (downloadedFilesSize + file->bytesDownloaded)) / speed * 1000.0;
        
        if((filesSize == FILE_SIZE_UNKNOWN) || ((downloadedFilesSize + file->bytesDownloaded) > filesSize))
            ui->setSpeedInfo(f2i(speed));
        else
            ui->setSpeedInfo(f2i(speed), f2i(rtime));
    }
}
コード例 #21
0
ファイル: ui.cpp プロジェクト: SCORE42/inno-download-plugin
void Ui::setProgressInfo(DWORDLONG totalSize, DWORDLONG totalDownloaded, DWORDLONG fileSize, DWORDLONG fileDownloaded)
{
    if(!(totalSize == FILE_SIZE_UNKNOWN))
    {
        double totalPercents = 100.0 / ((double)totalSize / (double)totalDownloaded);
        setProgressBarPos(controls["TotalProgressBar"], f2i(totalPercents));
    }

    if(!(fileSize == FILE_SIZE_UNKNOWN))
    {
        double filePercents  = 100.0 / ((double)fileSize / (double)fileDownloaded);
        setProgressBarPos(controls["FileProgressBar"], f2i(filePercents));
    }
}
コード例 #22
0
ファイル: gamecntl.c プロジェクト: nightwish75/d2x-ta
void transfer_energy_to_shield()
{
	fix e;		//how much energy gets transfered
	static fix64 last_play_time=0;

	e = min(min(FrameTime*CONVERTER_RATE,Players[Player_num].energy - INITIAL_ENERGY),(MAX_SHIELDS-Players[Player_num].shields)*CONVERTER_SCALE);

	if (e <= 0) {

		if (Players[Player_num].energy <= INITIAL_ENERGY) {
			HUD_init_message(HM_DEFAULT, "Need more than %i energy to enable transfer", f2i(INITIAL_ENERGY));
		}
		else if (Players[Player_num].shields >= MAX_SHIELDS) {
			HUD_init_message_literal(HM_DEFAULT, "No transfer: Shields already at max");
		}
		return;
	}

	Players[Player_num].energy  -= e;
	Players[Player_num].shields += e/CONVERTER_SCALE;

	if (last_play_time > GameTime64)
		last_play_time = 0;

	if (GameTime64 > last_play_time+CONVERTER_SOUND_DELAY) {
		digi_play_sample_once(SOUND_CONVERT_ENERGY, F1_0);
		last_play_time = GameTime64;
	}

}
コード例 #23
0
ファイル: 1185.cpp プロジェクト: 8cbx/code-area
long long solve(long long x)
{
    long long w, s[100];
    w = i2f(x, s + 1);
    s[0] = 0;
    long long n = 1;
    while(!s[n]) ++n;
    if(n & 1)
    {
        return f2i(w + 1, s);
    }
    else
    {
        return f2i(w - 1, s + 2);
    }
}
コード例 #24
0
ファイル: EHOSTAGE.C プロジェクト: NonCreature0714/descent
void vclip_play( vclip * vc, fix frame_time )	
{
	int bitmapnum;

	if ( vc == NULL )
		return;

	if ( vc != Vclip_ptr )	{
		// Start new vclip
		Vclip_ptr = vc;
		Vclip_animation_time = 1;

		// Calculate the frame/second of the playback
		Vclip_playback_speed = fixdiv(i2f(Vclip_ptr->num_frames),Vclip_ptr->play_time);
	}

	if ( Vclip_animation_time <= 0 )
		return;

	// Find next bitmap in the vclip
	bitmapnum = f2i(Vclip_animation_time);

	// Check if vclip is done playing.
	if (bitmapnum >= Vclip_ptr->num_frames)		{
		Vclip_animation_time	= 1;											// Restart this vclip
		bitmapnum = 0;
	}

	PIGGY_PAGE_IN( Vclip_ptr->frames[bitmapnum] );
	gr_bitmap(0,0,&GameBitmaps[Vclip_ptr->frames[bitmapnum].index] );
	
	Vclip_animation_time += fixmul(frame_time, Vclip_playback_speed );
}
コード例 #25
0
ファイル: gr.c プロジェクト: Ringdingcoder/d1x
int gr_palette_fade_in (ubyte *pal, int nsteps, int allow_keys)
{
	int i, j;
	ubyte c;
	fix fade_palette[768];
	fix fade_palette_delta[768];

	int fade_colors[768];

	if (!gr_palette_faded_out) return 0;

	for (i=0; i<768; i++)
	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i] + gr_palette_gamma) / nsteps;
	}

 	for (j=0; j<nsteps; j++ )
	{
		for (i = 0; i < 768; i++ )
		{
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i] + gr_palette_gamma))
				fade_palette[i] = i2f(pal[i] + gr_palette_gamma);
			c = f2i(fade_palette[i]);
			if (c > 63) c = 63;
			fade_colors[i] = c;
		}
		vga_setpalvec (0, 256, fade_colors);
	}

	gr_palette_faded_out = 0;
	return 0;
}
コード例 #26
0
ファイル: PALETTE.C プロジェクト: devint1/descent-win
int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys )	
{
	ubyte c[768];
	int i,j;
	fix fade_palette[768];
	fix fade_palette_delta[768];

	allow_keys  = allow_keys;

	if (gr_palette_faded_out)  return 0;

	for (i=0; i<768; i++ )	{
		fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
		fade_palette_delta[i] = fade_palette[i] / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		for (i=0; i<768; i++ )	{		
			fade_palette[i] -= fade_palette_delta[i];
			if (fade_palette[i] < 0 )
				fade_palette[i] = 0;
			c[i] = f2i(fade_palette[i]);
			if ( c[i] > 63 ) c[i] = 63;							
		}
		gr_palette_apply(c);
	}
	gr_palette_faded_out = 1;
	return 0;
}
コード例 #27
0
ファイル: gr.c プロジェクト: gameplayer22/d2x-1
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)
{
	int i,j;
	ubyte c;
	fix fade_palette[768];
	fix fade_palette_delta[768];


	if (!gr_palette_faded_out) return 0;

	for (i=0; i<768; i++ )	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		outp( 0x3c6, 0xff );
		outp( 0x3c8, 0 );
		for (i=0; i<768; i++ )	{
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i]+gr_palette_gamma) )
				fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
			c = f2i(fade_palette[i]);
                        if ( c > 63 ) c = 63;
			outp( 0x3c9, c );
		}
	}
	gr_palette_faded_out = 0;
	return 0;
}
コード例 #28
0
ファイル: digi.c プロジェクト: Ringdingcoder/d1x
void digi_get_sound_loc( vms_matrix * listener, vms_vector * listener_pos, int listener_seg, vms_vector * sound_pos, int sound_seg, fix max_volume, int *volume, int *pan, fix max_distance )
{	  
  vms_vector      vector_to_sound;
  fix angle_from_ear, cosang,sinang;
  fix distance;
  fix path_distance;

  *volume = 0;
  *pan = 0;

        max_distance = (max_distance*5)/4;              // Make all sounds travel 1.25 times as far.

	//	Warning: Made the vm_vec_normalized_dir be vm_vec_normalized_dir_quick and got illegal values to acos in the fang computation.
	distance = vm_vec_normalized_dir_quick( &vector_to_sound, sound_pos, listener_pos );
		
	if (distance < max_distance )	{
		int num_search_segs = f2i(max_distance/20);
		if ( num_search_segs < 1 ) num_search_segs = 1;

		path_distance = find_connected_distance(listener_pos, listener_seg, sound_pos, sound_seg, num_search_segs, WID_RENDPAST_FLAG );
		if ( path_distance > -1 )	{
			*volume = max_volume - fixdiv(path_distance,max_distance);
			//mprintf( (0, "Sound path distance %.2f, volume is %d / %d\n", f2fl(distance), *volume, max_volume ));
			if (*volume > 0 )	{
				angle_from_ear = vm_vec_delta_ang_norm(&listener->rvec,&vector_to_sound,&listener->uvec);
				fix_sincos(angle_from_ear,&sinang,&cosang);
				//mprintf( (0, "volume is %.2f\n", f2fl(*volume) ));
				if (Config_channels_reversed) cosang *= -1;
				*pan = (cosang + F1_0)/2;
			} else {
				*volume = 0;
			}
		}
	}																					  
}
コード例 #29
0
ファイル: PALETTE.C プロジェクト: devint1/descent-win
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)	
{
	int i,j;
	ubyte c[768];
	fix fade_palette[768];
	fix fade_palette_delta[768];

	allow_keys  = allow_keys;

	if (!gr_palette_faded_out) return 0;

	for (i=0; i<768; i++ )	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		for (i=0; i<768; i++ )	{		
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i]+gr_palette_gamma) )
				fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
			c[i] = f2i(fade_palette[i]);
			if ( c[i] > 63 ) c[i] = 63;					
		}
		gr_palette_apply(c);
	}
	gr_palette_faded_out = 0;
	return 0;
}
コード例 #30
0
ファイル: digiobj.c プロジェクト: paud/d2x-xl
void DigiGetSoundLoc (
	vmsMatrix * mListener, vmsVector * vListenerPos, short nListenerSeg, vmsVector * vSoundPos, 
	short nSoundSeg, fix maxVolume, int *volume, int *pan, fix maxDistance)	
{	  
	vmsVector	vecToSound;
	fix 			angleFromEar, cosang,sinang;
	fix 			distance;
	fix 			pathDistance;

*volume = 0;
*pan = 0;
maxDistance = (5 * maxDistance) / 4;	// Make all sounds travel 1.25 times as far.
//	Warning: Made the VmVecNormalizedDir be VmVecNormalizedDirQuick and got illegal values to acos in the fang computation.
distance = VmVecNormalizedDirQuick (&vecToSound, vSoundPos, vListenerPos);
if (distance < maxDistance) {
	int nSearchSegs = f2i (maxDistance / 20);
	if (nSearchSegs < 1)
		nSearchSegs = 1;
	pathDistance = FindConnectedDistance (vListenerPos, nListenerSeg, vSoundPos, nSoundSeg, nSearchSegs, WID_RENDPAST_FLAG + WID_FLY_FLAG);
	if (pathDistance > -1) {
		*volume = maxVolume - FixDiv (pathDistance, maxDistance);
		if (*volume <= 0) 
			*volume = 0;
		else {
			angleFromEar = VmVecDeltaAngNorm (&mListener->rVec, &vecToSound, &mListener->uVec);
			FixSinCos (angleFromEar, &sinang, &cosang);
			if (gameConfig.bReverseChannels) 
				cosang = -cosang;
			*pan = (cosang + F1_0) / 2;
			}
		}
	}																					  
}