Beispiel #1
0
/** Inverses mx.
 *  Returns materr(2) if mx isn't a square, 2x2 matrix,
 *  or materr(1) if the initialization didn't go right.
 */
matrix MatrixInv(matrix mx)
{
    if (!isValidOp(mx,mx,'i')) {
        return materr(2);
    }

    if(mx.rows == 2) {

        matrix inv = initialize(mx.rows, mx.columns);
        if(inv.mx == NULL) {
            return materr(1);
        }

        frac tmp;
        frac det = fdiv(i2f(1),
                        fsub(fmul(mx.mx[0][0], mx.mx[1][1]),
                             fmul(mx.mx[0][1], mx.mx[1][0])));

        tmp = mx.mx[0][0];
        inv.mx[0][0] = mx.mx[1][1];
        inv.mx[1][1] = tmp;

        inv.mx[0][1] = fmul(mx.mx[0][1], i2f(-1));
        inv.mx[1][0] = fmul(mx.mx[1][0], i2f(-1));
        return MatrixSMul(mx, det);
    } else {
        return materr(2);
    }
}
Beispiel #2
0
fix timer_get_fixed_seconds(void)
{
	fix x;
	unsigned long tv_now = SDL_GetTicks();
	x=i2f(tv_now/1000) | fixdiv(i2f(tv_now % 1000),i2f(1000));
	return x;
}
Beispiel #3
0
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;
}
Beispiel #4
0
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;
}
Beispiel #5
0
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;
}
Beispiel #6
0
//update various information about the player
void update_player_stats()
{
// I took out this 'if' because it was causing the reactor invul time to be
// off for players that sit in the death screen. -JS jul 6,95
//	if (!Player_exploded) {
		Players[Player_num].time_level += FrameTime;	//the never-ending march of time...
		if ( Players[Player_num].time_level > i2f(3600) )	{
			Players[Player_num].time_level -= i2f(3600);
			Players[Player_num].hours_level++;
		}

		Players[Player_num].time_total += FrameTime;	//the never-ending march of time...
		if ( Players[Player_num].time_total > i2f(3600) )	{
			Players[Player_num].time_total -= i2f(3600);
			Players[Player_num].hours_total++;
		}
//	}

//	Players[Player_num].energy += FrameTime*Energy_regen_ratio;	//slowly regenerate energy

//MK1015:	//slowly reduces player's energy & shields if over max
//MK1015:
//MK1015:	if (Players[Player_num].energy > MAX_ENERGY) {
//MK1015:		Players[Player_num].energy -= FrameTime/8;
//MK1015:		if (Players[Player_num].energy < MAX_ENERGY)
//MK1015:			Players[Player_num].energy = MAX_ENERGY;
//MK1015:	}
//MK1015:
//MK1015:	if (Players[Player_num].shields > MAX_SHIELDS) {
//MK1015:		Players[Player_num].shields -= FrameTime/8;
//MK1015:		if (Players[Player_num].shields < MAX_SHIELDS)
//MK1015:			Players[Player_num].shields = MAX_SHIELDS;
//MK1015:	}
}
Beispiel #7
0
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)	
{
	int i;
	
	if (!gr_palette_faded_out) return 0;
	
#ifdef OGLES
	GLuint saved_screen_tex;
	grs_canvas *save_canvas;
	int darken_step;
	
	if (!grd_curscreen) {
		return 0;
	}
	
	save_canvas = grd_curcanv;
	gr_set_current_canvas(NULL);
	darken_step = GR_FADE_LEVELS / nsteps;
	Gr_scanline_darkening_level = 1;
	saved_screen_tex = ogles_save_screen();
	for (i = 0; i < nsteps; ++i) {
		ogles_draw_saved_screen(saved_screen_tex);
		Gr_scanline_darkening_level	+= darken_step;
		gr_urect(0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h);
		showRenderBuffer();
		gr_sync_display();
	}
	glDeleteTextures(1, &saved_screen_tex);
	Gr_scanline_darkening_level = GR_FADE_LEVELS;
	gr_set_current_canvas(save_canvas);
	gr_palette_apply(pal);
#else
	int j;
	ubyte c[768];
	fix fade_palette[768];
	fix fade_palette_delta[768];
	
	allow_keys  = allow_keys;
	
	for (i=0; i<768; 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);
	}
#endif
	gr_palette_faded_out = 0;
	return 0;
}
Beispiel #8
0
fix timer_get_fixed_seconds(void)
{
	fix x;
	struct timeval tv_now;
	gettimeofday(&tv_now, NULL);
	x=i2f(tv_now.tv_sec - tv_old.tv_sec) + fixdiv(i2f((tv_now.tv_usec - tv_old.tv_usec)/1000), i2f(1000));
	return x;
}
Beispiel #9
0
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;
		}
	}
}
Beispiel #10
0
mesh_t* build_mesh() {
	int p;
	double c;
	mesh_t* mesh = mesh_new(5, 6);	// 5 vertexes, 6 triangles
	vector_t* points = mesh->points;
	triangle_t* triangles = mesh->triangles;

	double M_PI = 8.0 * atan(1.0);

	// define the base points
	for (p = 0; p < 4; p++) {
		c = M_PI * p / 4.0;
		points[p].x = (int)(10.0 * cos(c) * 64.0);
		points[p].y = (int)(10.0 * sin(c) * 64.0);
		points[p].z = i2f(5);
	}
	// define the top point
	points[4].x = 0;
	points[4].y = 0;
	points[4].z = i2f(-5);

	// define triangles
	// side a
	triangles[0].vertexes[0] = &points[4];
	triangles[0].vertexes[1] = &points[0];
	triangles[0].vertexes[2] = &points[1];

	// side b
	triangles[1].vertexes[0] = &points[4];
	triangles[1].vertexes[1] = &points[1];
	triangles[1].vertexes[2] = &points[2];

	// side c
	triangles[2].vertexes[0] = &points[4];
	triangles[2].vertexes[1] = &points[2];
	triangles[2].vertexes[2] = &points[3];

	// side d
	triangles[3].vertexes[0] = &points[4];
	triangles[3].vertexes[1] = &points[3];
	triangles[3].vertexes[2] = &points[0];

	// base 1
	triangles[4].vertexes[0] = &points[0];
	triangles[4].vertexes[1] = &points[3];
	triangles[4].vertexes[2] = &points[2];

	// base 2
	triangles[5].vertexes[0] = &points[2];
	triangles[5].vertexes[1] = &points[1];
	triangles[5].vertexes[2] = &points[0];

	return mesh;	// done! :)
}
Beispiel #11
0
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();
	}
}
Beispiel #12
0
void gr_line(grs_canvas &canvas, fix a1, fix b1, fix a2, fix b2, const uint8_t color)
{
	int x1, y1, x2, y2;
	x1 = i2f(MINX);
	y1 = i2f(MINY);
	x2 = i2f(canvas.cv_bitmap.bm_w - 1);
	y2 = i2f(canvas.cv_bitmap.bm_h - 1);

	CLIPLINE(a1,b1,a2,b2,x1,y1,x2,y2,return,, FIXSCALE );
	gr_uline(canvas, a1, b1, a2, b2, color);
}
Beispiel #13
0
draw_exit_model()
{
	vms_vector model_pos;
	int f=15,u=0;	//21;

	vm_vec_scale_add(&model_pos,&mine_exit_point,&mine_exit_orient.fvec,i2f(f));
	vm_vec_scale_add2(&model_pos,&mine_exit_orient.uvec,i2f(u));

	draw_polygon_model(&model_pos,&mine_exit_orient,NULL,(mine_destroyed)?destroyed_exit_modelnum:exit_modelnum,0,f1_0,NULL,NULL);

}
Beispiel #14
0
void MultiDoCheatPenalty ()
{
DoCheatPenalty ();
LOCALPLAYER.shields = i2f (1);
MultiSendShields ();
LOCALPLAYER.energy = i2f (1);
if (gameData.app.nGameMode & GM_MULTI) {
	gameData.multigame.msg.nReceiver = 100;		// Send to everyone...
	sprintf (gameData.multigame.msg.szMsg, TXT_CRIPPLED, LOCALPLAYER.callsign);
	}
HUDInitMessage (TXT_TAKE_THAT);
}
Beispiel #15
0
namespace dcx {
constexpr fix Fuelcen_give_amount = i2f(25);
constexpr fix Fuelcen_max_amount = i2f(100);

// Every time a robot is created in the morphing code, it decreases capacity of the morpher
// by this amount... when capacity gets to 0, no more morphers...
constexpr fix EnergyToCreateOneRobot = i2f(1);

unsigned Num_robot_centers;
unsigned Num_fuelcenters;

static int Num_extry_robots = 15;
}
Beispiel #16
0
void MultiDoCheatPenalty ()
{
DoCheatPenalty ();
gameData.multi.players [gameData.multi.nLocalPlayer].shields = i2f (1);
MultiSendShields ();
gameData.multi.players [gameData.multi.nLocalPlayer].energy = i2f (1);
#ifdef NETWORK
if (gameData.app.nGameMode & GM_MULTI) {
	multiData.msg.nReceiver = 100;		// Send to everyone...
	sprintf (multiData.msg.szMsg, TXT_CRIPPLED, gameData.multi.players [gameData.multi.nLocalPlayer].callsign);
	}
#endif
HUDInitMessage (TXT_TAKE_THAT);
}
Beispiel #17
0
Datei: timer.c Projekt: btb/d2x
fix timer_get_fixed_seconds()
{
        fix x;

	//Ye good olde unix:
        //Ye bad olde Windows DPH:-)
/* DPH: Using timeGetTime will fail approximately 47 days after Windows was
   started as the timer wraps around to 0. Ever had Windows not crash for 47
   consecutive days? Thought not. */

        unsigned long tv_now=timeGetTime()-old_tv;
        x=i2f(tv_now/1000) | fixdiv(i2f(tv_now % 1000),i2f(1000));
	return x;
}
Beispiel #18
0
//update various information about the player
void update_player_stats()
{
	Players[Player_num].time_level += FrameTime;	//the never-ending march of time...
	if ( Players[Player_num].time_level > i2f(3600) )	{
		Players[Player_num].time_level -= i2f(3600);
		Players[Player_num].hours_level++;
	}

	Players[Player_num].time_total += FrameTime;	//the never-ending march of time...
	if ( Players[Player_num].time_total > i2f(3600) )	{
		Players[Player_num].time_total -= i2f(3600);
		Players[Player_num].hours_total++;
	}
}
Beispiel #19
0
void state_callback(int nitems, newmenu_item *items, int *last_key, int citem) {
	fix x = fl2f((grd_curcanv->cv_bitmap.bm_w - THUMBNAIL_W * f2fl(Scale_x)) / 2);
	fix y = fl2f(items[0].y - 5 * f2fl(Scale_factor));
	grs_point scale_pts[] = {
			{x,                              y},
			{x + i2f(THUMBNAIL_W),           y + i2f(THUMBNAIL_H)},
			{x + THUMBNAIL_W * Scale_factor, y + THUMBNAIL_H * Scale_factor}
	};

	if (citem > 0) {
		if (sc_bmp[citem - 1]) {
			scale_bitmap(sc_bmp[citem - 1], scale_pts);
		}
	}
}
// ok
void player_start_editor::OnOK()
{
	int i, idx;

	// store player entry time delay
	Entry_delay_time = i2f(m_delay);	

	// store ship pools	
	for(i=0; i<MAX_TEAMS; i++){
		Team_data[i].number_choices = 0;
		for(idx=0; idx<Num_ship_types; idx++){
			// if we have ships here
			if(ship_pool[i][idx] > 0){
				Team_data[i].ship_count[Team_data[i].number_choices] = ship_pool[i][idx];
				Team_data[i].ship_list[Team_data[i].number_choices++] = idx;
			}
		}
	}

	// store weapon pools
	for(i=0; i<MAX_TEAMS; i++){		
		for(idx=0; idx<Num_weapon_types; idx++){
			// if we have weapons here
			Team_data[i].weaponry_pool[idx] = weapon_pool[i][idx];
		}
	}

	theApp.record_window_data(&Player_wnd_data, this);
	CDialog::OnOK();
}
Beispiel #21
0
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 );
}
int main(void)
{
    int n;

    while (1) {
        printf("1. Feet to Inches \n");
        printf("2. Inches to feet \n");
        printf("3. Exit \n");
        printf("Enter choice : ");
        scanf("%d",&n);
        switch(n) {
        case 1:
            f2i();
            break;
        case 2:
            i2f();
            break;
        case 3:
            printf("Thanks! \n");
            return 0;
            break;
        default:
            printf("Invalid input.. try again \n");
            break;
        }
    }

    return 0;
}
Beispiel #23
0
int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys )
{
	ubyte c;
	int i,j;
	fix fade_palette[768];
	fix fade_palette_delta[768];

	if (gr_palette_faded_out) return 0;

	if (!pal)
		pal = gr_current_pal;

	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();
		outp( 0x3c6, 0xff );
		outp( 0x3c8, 0 );
		for (i=0; i<768; i++ )	{
			fade_palette[i] -= fade_palette_delta[i];
			if (fade_palette[i] < 0 )
				fade_palette[i] = 0;
			c = f2i(fade_palette[i]);
			if ( c > 63 ) c = 63;
			outp( 0x3c9, c );
		}
	}
	gr_palette_faded_out = 1;
	return 0;
}
Beispiel #24
0
static void show_title_screen(const char * filename, int allow_keys, int from_hog_only )
{
	int pcx_error;
	char new_filename[PATH_MAX] = "";

	auto ts = make_unique<title_screen>();
	ts->allow_keys = allow_keys;

#ifdef RELEASE
	if (from_hog_only)
		strcpy(new_filename,"\x01");	//only read from hog file
#else
	(void)from_hog_only;
#endif

	strcat(new_filename,filename);
	filename = new_filename;
	if ((pcx_error=pcx_read_bitmap( filename, ts->title_bm, gr_palette ))!=PCX_ERROR_NONE)	{
		Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
	}

	ts->timer = timer_query() + i2f(3);

	gr_palette_load( gr_palette );

	const auto wind = window_create(grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, title_handler, ts.get());
	if (!wind)
	{
		return;
	}

	event_process_all();
}
Beispiel #25
0
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;
}
Beispiel #26
0
int main(int argc, char ** argv)
{
	char op;
	char mStr[1024];
	matrix ans, m1, m2;
	int sc = 0;

	if(argc > 1){
		op = getOp(argv[1]);
	} else {
		printf("Which operation: ");
		op = getOp(NULL);
	}


	printf("First matrix:\n");
	scanf("%s", mStr);
	m1 = MatrixInit(mStr);

	if(op == 'a' || op == 's' || op == 'm'){
		printf("Second matrix:\n");
		scanf("%s", mStr);
		m2 = MatrixInit(mStr);
	} else if(op == 'c') {
		printf("Scalar multiple:\n");
		scanf("%d", &sc);
	}

	switch(op){
		case 'a':
			ans = MatrixAdd(m1, m2);
			break;
		case 's':
			ans = MatrixSub(m1, m2);
			break;
		case 'm':
			ans = MatrixMul(m1, m2);
			break;
		case 'i':
			ans = MatrixInv(m1);
			break;
		case 'c':
			ans = MatrixSMul(m1, i2f(sc));
			break;
		default:
			printf("Something went very wrong.\n");
			return 1;
	}

	printf("Answer:\n");
	MatrixPrint(ans);

	MatrixFree(m1);
	MatrixFree(ans);
	if(op == 'a' || op == 's' || op == 'm'){
		MatrixFree(m2);
	}

	return 0;
}
Beispiel #27
0
void autodemo_menu_check(int nitems, newmenu_item * items, int *last_key, int citem )
{
	int curtime;

	nitems = nitems;
	items=items;
	citem = citem;

	//draw copyright message
	if ( Menu_draw_copyright )		{
		Menu_draw_copyright = 0;
		gr_set_current_canvas(NULL);
		gr_set_curfont(GAME_FONT);
		gr_set_fontcolor(BM_XRGB(6,6,6),-1);
		gr_printf(0x8000,grd_curcanv->cv_bitmap.bm_h-GAME_FONT->ft_h-2,TXT_COPYRIGHT);
	}
	
	// Don't allow them to hit ESC in the main menu.
	if (*last_key==KEY_ESC) *last_key = 0;

	if ( do_auto_demo )	{
		curtime = timer_get_approx_seconds();
		//if ( ((keyd_time_when_last_pressed+i2f(20)) < curtime) && ((last_joy_time+i2f(20)) < curtime) && (!speedtest_on)  ) {
		if ( ((keyd_time_when_last_pressed+i2f(45)) < curtime) && (!speedtest_on)  ) {
			keyd_time_when_last_pressed = curtime;			// Reset timer so that disk won't thrash if no demos.
			newdemo_start_playback(NULL);		// Randomly pick a file
			if (Newdemo_state == ND_STATE_PLAYBACK)	{
				Function_mode = FMODE_GAME;
				*last_key = -2;							  	
			}
		}
	}
}
Beispiel #28
0
//------------------------------------------------------------
// Adds a matcen that already is a special type into the Station array.
// This function is separate from other fuelcens because we don't want values reset.
static void matcen_create(const vsegptridx_t segp)
{
	int	station_type = segp->special;

	Assert(station_type == SEGMENT_IS_ROBOTMAKER);

	Assert( Num_fuelcenters < MAX_NUM_FUELCENS );

	segp->value = Num_fuelcenters;
	Station[Num_fuelcenters].Type = station_type;
	Station[Num_fuelcenters].Capacity = i2f(Difficulty_level + 3);
	Station[Num_fuelcenters].MaxCapacity = Station[Num_fuelcenters].Capacity;

	Station[Num_fuelcenters].segnum = segp;
	Station[Num_fuelcenters].Timer = -1;
	Station[Num_fuelcenters].Flag = 0;

	segp->matcen_num = Num_robot_centers;
	Num_robot_centers++;

	RobotCenters[segp->matcen_num].segnum = segp;
	RobotCenters[segp->matcen_num].fuelcen_num = Num_fuelcenters;

	Num_fuelcenters++;
}
Beispiel #29
0
//	-----------------------------------------------------------------------------
//	Called when control center gets destroyed.
//	This code is common to whether control center is implicitly imbedded in a boss,
//	or is an object of its own.
//	if objP == NULL that means the boss was the control center and don't set gameData.reactor.nDeadObj
void DoReactorDestroyedStuff (object *objP)
{
    int	i;

    if ((gameData.app.nGameMode & GM_MULTI_ROBOTS) && gameData.reactor.bDestroyed)
        return; // Don't allow resetting if control center and boss on same level
// Must toggle walls whether it is a boss or control center.
    for (i = 0; i < gameData.reactor.triggers.num_links; i++)
        WallToggle (gameData.segs.segments + gameData.reactor.triggers.seg [i], gameData.reactor.triggers.side[i]);
// And start the countdown stuff.
    if (!(gameStates.app.bD2XLevel && gameStates.gameplay.bMultiBosses && extraGameInfo [0].nBossCount))
        gameData.reactor.bDestroyed = 1;
//	If a secret level, delete secret.sgc to indicate that we can't return to our secret level.
    if (gameData.missions.nCurrentLevel < 0)
        CFDelete ("secret.sgc", gameFolders.szSaveDir);
    if (gameStates.app.nBaseCtrlCenExplTime != DEFAULT_CONTROL_CENTER_EXPLOSION_TIME)
        gameData.reactor.countdown.nTotalTime = gameStates.app.nBaseCtrlCenExplTime + gameStates.app.nBaseCtrlCenExplTime * (NDL-gameStates.app.nDifficultyLevel-1)/2;
    else
        gameData.reactor.countdown.nTotalTime = nAlanPavlishReactorTimes [gameStates.app.bD1Mission][gameStates.app.nDifficultyLevel];
    gameData.reactor.countdown.nTimer = i2f (gameData.reactor.countdown.nTotalTime);
    if (!(gameData.reactor.bPresent && objP)) {
        //Assert (objP == NULL);
        return;
    }
    gameData.reactor.nDeadObj = OBJ_IDX (objP);
}
Beispiel #30
0
int gr_line(fix a1, fix b1, fix a2, fix b2) {
	int x1, y1, x2, y2;
	int clipped = 0;

	x1 = i2f(MINX);
	y1 = i2f(MINY);
	x2 = i2f(MAXX);
	y2 = i2f(MAXY);

	CLIPLINE(a1, b1, a2, b2, x1, y1, x2, y2, return 2, clipped = 1, FSCALE);

	gr_uline(a1, b1, a2, b2);

	return clipped;

}