コード例 #1
0
//stop the redbook, so we can read off the CD
void songs_stop_redbook(void)
{
	int old_volume = GameCfg.MusicVolume*REDBOOK_VOLUME_SCALE/8;
	fix old_time = timer_get_fixed_seconds();
	
	if (Redbook_playing) {		//fade out volume
		int new_volume;
		do {
			fix t = timer_get_fixed_seconds();
			
			new_volume = fixmuldiv(old_volume,(FADE_TIME - (t-old_time)),FADE_TIME);
			
			if (new_volume < 0)
				new_volume = 0;
			
			RBASetVolume(new_volume);
			
		} while (new_volume > 0);
	}
	
	RBAStop();              	// Stop CD, if playing
	
	RBASetVolume(old_volume);	//restore volume
	
	Redbook_playing = 0;		
	
}
コード例 #2
0
ファイル: TESTT.C プロジェクト: NonCreature0714/descent
void main (void)
{
	fix t1, t2, t3, delta, mdelta, mt3;

	printf( "Press any key to start...\n" );

	timer_init();
	timer_set_rate( 9943 );

	t1 = t2 = timer_get_fixed_seconds();

	mdelta = 0;
	mt3 = 0;
	while(!kbhit())	{
		t3 = t2;
		t1 = timer_get_approx_seconds();
		t2 = timer_get_fixed_seconds();
		delta = t2 - t1;
		if ( abs(delta) > mdelta )
			mdelta = abs(delta);

		if ( abs(t2-t3) > mt3 )
			mt3 = abs(t2-t3);
		printf( "%.8f\t%.8f\t%.8f\t%d\t%.8f\t%.8f\n", f2fl(t2), f2fl(t2-t1), f2fl(mdelta), TICKER/19, f2fl(t2-t3), f2fl(mt3) );
//		if ( t2 < t1 )	{
//			printf( "Bad time of %.8f\n", f2fl(t1-t2) );
//		}
	}
}
コード例 #3
0
ファイル: generic.cpp プロジェクト: joshuasb/fs2open
//for timer debug, #define TIMER
void generic_render_eff_stream(generic_anim *ga)
{
	if(ga->current_frame == ga->previous_frame)
		return;
	ubyte bpp = 32;
	if(ga->use_hud_color)
		bpp = 8;
	#ifdef TIMER
		int start_time = timer_get_fixed_seconds();
	#endif

	#ifdef TIMER
		mprintf(("=========================\n"));
		mprintf(("frame: %d\n", ga->current_frame));
	#endif
		char frame_name[MAX_FILENAME_LEN];
		snprintf(frame_name, MAX_FILENAME_LEN, "%s_%.4d", ga->filename, ga->current_frame);
		if(bm_reload(ga->eff.next_frame, frame_name) == ga->eff.next_frame)
		{
			bitmap* next_frame_bmp = bm_lock(ga->eff.next_frame, bpp, (bpp==8)?BMP_AABITMAP:BMP_TEX_NONCOMP, true);
			if(next_frame_bmp->data)
				gr_update_texture(ga->bitmap_id, bpp, (ubyte*)next_frame_bmp->data, ga->width, ga->height);
			bm_unlock(ga->eff.next_frame);
			bm_unload(ga->eff.next_frame, 0, true);
			if (ga->current_frame == ga->num_frames-1)
			{
				snprintf(frame_name, MAX_FILENAME_LEN, "%s_0001", ga->filename);
				bm_reload(ga->eff.next_frame, frame_name);
			}
		}
	#ifdef TIMER
		mprintf(("end: %d\n", timer_get_fixed_seconds() - start_time));
		mprintf(("=========================\n"));
	#endif
}
コード例 #4
0
ファイル: titles.c プロジェクト: btb/d1x
//	-----------------------------------------------------------------------------
//	Returns char width.
//	If show_robot_flag set, then show a frame of the spinning robot.
int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
{
	int	w, h, aw;
	char	message[2];
	fix	start_time;
	int	i;

	start_time = timer_get_fixed_seconds();

	message[0] = the_char;
	message[1] = 0;

	gr_get_string_size(message, &w, &h, &aw );

	Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));

	//	Draw cursor if there is some delay and caller says to draw cursor
//added/changed on 9/13/98 by adb to fix messy code and add gr_update
     if (delay)
      {
	if (cursor_flag && delay) {
		gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
		gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
	}

	for (i=0; i<2; i++) {
                if (robot_num != -1)
			show_spinning_robot_frame(robot_num);
                show_bitmap_frame();

                gr_update();

		while (timer_get_fixed_seconds() < start_time + delay/2)
			;

		start_time = timer_get_fixed_seconds();
	}

	//	Erase cursor
        if (cursor_flag) {
		gr_set_fontcolor(Erase_color, -1);
		gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
	}
      }
//end additions/changed - adb

	//	Draw the character
	gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
	gr_printf(Briefing_text_x, Briefing_text_y, message );

	gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
	gr_printf(Briefing_text_x+1, Briefing_text_y, message );

//	if (the_char != ' ')
//		if (!digi_is_sound_playing(231))
//			digi_play_sample( 231, F1_0 );

	return w;
}
コード例 #5
0
ファイル: timer.c プロジェクト: btb/d2x
void delay(int d_time)
{
	fix t, total;
	
	total = (F1_0 * d_time) / 1000;
	t = timer_get_fixed_seconds();
	while (timer_get_fixed_seconds() - t < total) ;
}
コード例 #6
0
ファイル: joy.c プロジェクト: gameplayer22/d2x-1
void joy_hat_handler(SDL_JoyHatEvent *jhe)
{
	int hat = SDL_Joysticks[jhe->which].hat_map[jhe->hat];
	int hbi;

	//Save last state of the hat-button
	Joystick.buttons[hat  ].last_state = Joystick.buttons[hat  ].state;
	Joystick.buttons[hat+1].last_state = Joystick.buttons[hat+1].state;
	Joystick.buttons[hat+2].last_state = Joystick.buttons[hat+2].state;
	Joystick.buttons[hat+3].last_state = Joystick.buttons[hat+3].state;

	//get current state of the hat-button
	Joystick.buttons[hat  ].state = ((jhe->value & SDL_HAT_UP)>0);
	Joystick.buttons[hat+1].state = ((jhe->value & SDL_HAT_RIGHT)>0);
	Joystick.buttons[hat+2].state = ((jhe->value & SDL_HAT_DOWN)>0);
	Joystick.buttons[hat+3].state = ((jhe->value & SDL_HAT_LEFT)>0);

	//determine if a hat-button up or down event based on state and last_state
	for(hbi=0;hbi<4;hbi++)
	{
		if(	!Joystick.buttons[hat+hbi].last_state && Joystick.buttons[hat+hbi].state) //last_state up, current state down
		{
			Joystick.buttons[hat+hbi].time_went_down
				= timer_get_fixed_seconds();
			Joystick.buttons[hat+hbi].num_downs++;
		}
		else if(Joystick.buttons[hat+hbi].last_state && !Joystick.buttons[hat+hbi].state)  //last_state down, current state up
		{
			Joystick.buttons[hat+hbi].num_ups++;
		}
	}
}
コード例 #7
0
void debug_draw()
{
	int i;

	gr_clear();
	gr_set_font(FONT1);
	gr_set_color_fast( &Color_bright );
	gr_string( 0x8000, 3, "Debug Console" );

	gr_set_color_fast( &Color_normal );

	for (i=0; i<DROWS; i++ ) {
		gr_string( 0, i*16+16, debug_text[i] );
	}

	int t = timer_get_fixed_seconds() / (F1_0/3);
	if ( t & 1 ) {
		int w,h;
		char c;

		c = debug_text[debug_y][command_line_pos+1];
		debug_text[debug_y][command_line_pos+1] = 0;

		gr_get_string_size( &w, &h, debug_text[debug_y] );

		//gr_string( w, debug_y*16, "_" );
		gr_rect(w+1,debug_y*16+1+16,2,14);

		debug_text[debug_y][command_line_pos+1] = c;
	}

	gr_flip();
}
コード例 #8
0
ファイル: FIREBALL.C プロジェクト: devint1/descent-win
//	------------------------------------------------------------------------------------------------------
//	Choose segment to drop a powerup in.
//	For all active net players, try to create a N segment path from the player.  If possible, return that
//	segment.  If not possible, try another player.  After a few tries, use a random segment.
//	Don't drop if control center in segment.
int choose_drop_segment(void)
{
	int	pnum = 0;
	int	segnum = -1;
	int	initial_drop_depth = BASE_NET_DROP_DEPTH + ((rand() * 10) >> 15);
	int	cur_drop_depth = initial_drop_depth;
	int	count;

	srand(timer_get_fixed_seconds());

	while ((segnum == -1) && (cur_drop_depth > BASE_NET_DROP_DEPTH/2)) {
		pnum = (rand() * N_players) >> 15;
		count = 0;
		while ((Players[pnum].connected == 0) && (count < N_players)) {
			pnum = (pnum+1)%N_players;
			count++;
		}

		if (count == N_players) {
			mprintf((1, "Warning: choose_drop_segment: Couldn't find legal drop segment because no connected players.\n"));
			return (rand() * Highest_segment_index) >> 15;
		}

		segnum = pick_connected_segment(&Objects[Players[pnum].objnum], cur_drop_depth);
		if (Segments[segnum].special == SEGMENT_IS_CONTROLCEN)
			segnum = -1;
		cur_drop_depth--;
	}
コード例 #9
0
ファイル: key.c プロジェクト: Ringdingcoder/d1x
void key_flush()
{
	int i;
	fix curtime;

	if (!Installed)
		key_init();

	arch_key_flush();

	key_data.keyhead = key_data.keytail = 0;

	//Clear the keyboard buffer
	for (i=0; i<KEY_BUFFER_SIZE; i++ )	{
		key_data.keybuffer[i] = 0;
		key_data.time_pressed[i] = 0;
	}

	//use gettimeofday here:
	curtime = timer_get_fixed_seconds();

	for (i=0; i<256; i++ )	{
		keyd_pressed[i] = 0;
		key_data.keys[i].state = 1;
		key_data.keys[i].last_state = 0;
		key_data.keys[i].timewentdown = curtime;
		key_data.keys[i].downcount=0;
		key_data.keys[i].upcount=0;
		key_data.keys[i].timehelddown = 0;
		key_data.keys[i].counter = 0;
	}
}
コード例 #10
0
ファイル: medrobot.c プロジェクト: arbruijn/d1xnacl
//-------------------------------------------------------------------------
// Called from the editor... does one instance of the robot dialog box
//-------------------------------------------------------------------------
int do_robot_dialog()
{
	int i;

	// Only open 1 instance of this window...
	if ( MainWindow != NULL ) return 0;
	
	// Close other windows
	close_all_windows();
	Cur_goody_count = 0;

	// Open a window with a quit button
	MainWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
	QuitButton = ui_add_gadget_button( MainWindow, 20, 286, 40, 32, "Done", NULL );

	ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y-3, 25, 22, "<<", GoodyPrevType );
	ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y-3, 25, 22, ">>", GoodyNextType );

	ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y+21, 25, 22, "<<", GoodyPrevID );
	ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y+21, 25, 22, ">>", GoodyNextID );

	ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y+45, 25, 22, "<<", GoodyPrevCount );
	ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y+45, 25, 22, ">>", GoodyNextCount );

	InitialMode[0] = ui_add_gadget_radio( MainWindow,  6, 58, 16, 16, 0, "Hover" );
	InitialMode[1] = ui_add_gadget_radio( MainWindow, 76, 58, 16, 16, 0, "Normal" );
	InitialMode[2] = ui_add_gadget_radio( MainWindow,  6, 78, 16, 16, 0, "(hide)" );
	InitialMode[3] = ui_add_gadget_radio( MainWindow, 76, 78, 16, 16, 0, "Avoid" );
	InitialMode[4] = ui_add_gadget_radio( MainWindow,  6, 98, 16, 16, 0, "Follow" );
	InitialMode[5] = ui_add_gadget_radio( MainWindow, 76, 98, 16, 16, 0, "Station" );

	// The little box the robots will spin in.
	RobotViewBox = ui_add_gadget_userbox( MainWindow,155, 5, 150, 125 );

	// The little box the robots will spin in.
	ContainsViewBox = ui_add_gadget_userbox( MainWindow,10, 202, 100, 80 );

	// A bunch of buttons...
	i = 135;
	ui_add_gadget_button( MainWindow,190,i,53, 26, "<<Typ", 			RobotPrevType );
	ui_add_gadget_button( MainWindow,247,i,53, 26, "Typ>>", 			RobotNextType );							i += 29;		
	ui_add_gadget_button( MainWindow,190,i,110, 26, "Next in Seg", LocalObjectSelectNextinSegment );	i += 29;		

	ui_add_gadget_button( MainWindow,190,i,53, 26, "<<Obj",		 	LocalObjectSelectPrevinMine );
	ui_add_gadget_button( MainWindow,247,i,53, 26, ">>Obj",			LocalObjectSelectNextinMine ); 		i += 29;		

	ui_add_gadget_button( MainWindow,190,i,110, 26, "Delete", 		LocalObjectDelete );						i += 29;		
	ui_add_gadget_button( MainWindow,190,i,110, 26, "Create New", 	LocalObjectPlaceObject );				i += 29;		
	ui_add_gadget_button( MainWindow,190,i,110, 26, "Set Path", 	med_set_ai_path );
	
	Time = timer_get_fixed_seconds();

	old_object = -2;		// Set to some dummy value so everything works ok on the first frame.

	if ( Cur_object_index == -1 )
		LocalObjectSelectNextinMine();

	return 1;

}
コード例 #11
0
ファイル: menu.c プロジェクト: osgcc/descent-mac
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_fixed_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)  ) {
			hide_cursor();
			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;							  	
			}
		}
	}
}
コード例 #12
0
ファイル: menu.c プロジェクト: osgcc/descent-mac
//returns number of item chosen
int DoMenu() 
{
	int menu_choice[25];
	newmenu_item m[25];
	int num_options = 0;

	if ( Players[Player_num].callsign[0]==0 )	{
		RegisterPlayer();
		return 0;
	}
	
	if ((Game_mode & GM_SERIAL) || (Game_mode & GM_MODEM)) {
		do_option(MENU_START_SERIAL);
		return 0;
	}

	create_main_menu(m, menu_choice, &num_options);

	do {
		keyd_time_when_last_pressed = timer_get_fixed_seconds();		// .. 20 seconds from now!
		if (main_menu_choice < 0 )	main_menu_choice = 0;		
		Menu_draw_copyright = 1;
		main_menu_choice = newmenu_do2( "", NULL, num_options, m, autodemo_menu_check, main_menu_choice, Menu_pcx_name);
		if ( main_menu_choice > -1 ) do_option(menu_choice[main_menu_choice]);
		create_main_menu(m, menu_choice, &num_options);	//	may have to change, eg, maybe selected pilot and no save games.
	} while( Function_mode==FMODE_MENU );

//	if (main_menu_choice != -2)
//		do_auto_demo = 0;		// No more auto demos
	if ( Function_mode==FMODE_GAME )	
		gr_palette_fade_out( gr_palette, 32, 0 );

	return main_menu_choice;
}
コード例 #13
0
ファイル: TEST1.C プロジェクト: NonCreature0714/descent
int test_john(void)
{
	int	start, finish;
	float	elapsed_time;

	mprintf(0, "John test:...");
	start = timer_get_fixed_seconds();

	john_test();

	finish = timer_get_fixed_seconds();

	elapsed_time = (float) (finish - start);
	mprintf(0, "Done, time = %7.3f\n", elapsed_time/65536.0);
	return finish - start;

}
コード例 #14
0
ファイル: titles.c プロジェクト: btb/d1x
int show_title_screen( char * filename, int allow_keys )	
{

	fix timer;
	int pcx_error;
	grs_bitmap title_bm;

	gr_init_bitmap_data (&title_bm);

	if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE)	{
		printf( "File '%s', PCX load error: %s (%i)\n  (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
		mprintf((0, "File '%s', PCX load error: %s (%i)\n  (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error));
		Int3();
		gr_free_bitmap_data (&title_bm);
		return 0;
	}

//        vfx_set_palette_sub( New_pal );
#ifdef OGL
	gr_palette_load(New_pal);
#else
	gr_palette_clear();	
#endif
	gr_set_current_canvas( NULL );
	show_fullscr(&title_bm);
        //added on 9/13/98 by adb to make update-needing arch's work
        gr_update();
        //end addition - adb

	gr_free_bitmap_data (&title_bm);

	if (allow_keys > 2 || gr_palette_fade_in( New_pal, 32, allow_keys ) || allow_keys > 1) {
		return 1;
	}

	gr_palette_load( New_pal );
	timer = timer_get_fixed_seconds() + i2f(3);
	while (1)	{
		if ( local_key_inkey() && allow_keys ) break;
		if ( timer_get_fixed_seconds() > timer ) break;
        }                
	if (gr_palette_fade_out( New_pal, 32, allow_keys ))
		return 1;
	return 0;
}
コード例 #15
0
ファイル: mouse.c プロジェクト: arbruijn/d1xnacl
void mouse_button_handler(SDL_MouseButtonEvent *mbe)
{
	// to bad, SDL buttons use a different mapping as descent expects,
	// this is at least true and tested for the first three buttons 
	int button_remap[17] = {
		MBTN_LEFT,
		MBTN_MIDDLE,
		MBTN_RIGHT,
		MBTN_Z_UP,
		MBTN_Z_DOWN,
		MBTN_PITCH_BACKWARD,
		MBTN_PITCH_FORWARD,
		MBTN_BANK_LEFT,
		MBTN_BANK_RIGHT,
		MBTN_HEAD_LEFT,
		MBTN_HEAD_RIGHT,
		MBTN_11,
		MBTN_12,
		MBTN_13,
		MBTN_14,
		MBTN_15,
		MBTN_16
	};

	int button = button_remap[mbe->button - 1]; // -1 since SDL seems to start counting at 1

	if (mbe->state == SDL_PRESSED) {
		Mouse.buttons[button].pressed = 1;
		Mouse.buttons[button].time_went_down = timer_get_fixed_seconds();
		Mouse.buttons[button].num_downs++;

		if (button == MBTN_Z_UP) {
			Mouse.delta_z += Z_SENSITIVITY;
			Mouse.z += Z_SENSITIVITY;
		} else if (button == MBTN_Z_DOWN) {
			Mouse.delta_z -= Z_SENSITIVITY;
			Mouse.z -= Z_SENSITIVITY;
		}
	} else {
		Mouse.buttons[button].pressed = 0;
		Mouse.buttons[button].time_held_down += timer_get_fixed_seconds() - Mouse.buttons[button].time_went_down;
		Mouse.buttons[button].num_ups++;
	}
}
コード例 #16
0
ファイル: rbtest.c プロジェクト: btb/d2x
int main()
{
	fix fsecs;
	int oldmin=-1, oldsec=-1;

	error_init(NULL, NULL);
	dpmi_init(0);
	timer_init();
	key_init();
	RBAInit();
	RBARegisterCD();
	RBAPlayTrack(2);

	fsecs = timer_get_fixed_seconds();
	do
	{
		int min, sec, frame;
		long headloc;

		if ((timer_get_fixed_seconds() - fsecs) >= F2_0) {
			headloc = RBAGetHeadLoc(&min, &sec, &frame);
			printf("Head loc: %d (%d:%d:%d)\n", headloc, min, sec, frame);
			if (min==oldmin && sec==oldsec) {
				printf("\nRepeating track..\n");
				RBAPlayTrack(2);
			}
			oldmin = min; oldsec = sec;
			fsecs = timer_get_fixed_seconds();
		}
		if (key_inkey()) {
			RBAStop();
			printf("\nCD stopped.\n");
			break;
		}
	}
	while (1); 

	key_close();
	timer_close();

	return 0;
}
コード例 #17
0
// evaluate a pong return on the given struct
void multi_ping_eval_pong(ping_struct* ps)
{
	int idx;
	float ping_sum;

	// if the ping technically hasn't started,
	if (ps->ping_start < 0.0f)
	{
		nprintf(("Network", "Processing pong for ping which hasn't started yet!\n"));
		return;
	}

	// if we still have room to add a ping
	if (ps->num_pings < MAX_PINGS)
	{
		ps->ping_times[ps->ping_add++] = f2fl(timer_get_fixed_seconds()) - ps->ping_start;
		ps->num_pings++;
	}
		// otherwise if we've wrapped around
	else
	{
		// increment the place to add the ping time
		if (ps->ping_add >= MAX_PINGS - 1)
		{
			ps->ping_add = 0;
		}
		else
		{
			ps->ping_add++;
		}

		ps->ping_times[ps->ping_add] = f2fl(timer_get_fixed_seconds()) - ps->ping_start;
	}

	// calculate the average ping time
	ping_sum = 0.0f;
	for (idx = 0; idx < ps->num_pings; idx++)
	{
		ping_sum += ps->ping_times[idx];
	}
	ps->ping_avg = (int)(1000.0f * (ping_sum / (float)ps->num_pings));
}
コード例 #18
0
ファイル: KEY.C プロジェクト: NonCreature0714/descent2
void key_init()
{
	// Initialize queue

	Status1= *(ubyte*)0x417;
	Status2= *(ubyte*)0x418;
 
	keyd_time_when_last_pressed = timer_get_fixed_seconds();
	keyd_buffer_type = 1;
	keyd_repeat = 1;
	key_data.in_key_handler = 0;
	key_data.E0Flag = 0;
	key_data.E1Flag = 0;

	// Clear the keyboard array
	key_flush();

	if (Installed) return;
	Installed = 1;

	//--------------- lock everything for the virtal memory ----------------------------------
	if (!dpmi_lock_region ((void near *)key_handler, (char *)key_handler_end - (char near *)key_handler))	{
		Error( "Can't lock keyboard handler!\n" );
	}
	if (!dpmi_lock_region (&key_data, sizeof(keyboard)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_buffer_type, sizeof(char)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_repeat, sizeof(char)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_editor_mode, sizeof(char)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_last_pressed, sizeof(char)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_last_released, sizeof(char)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_pressed, sizeof(char)*256))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_time_when_last_pressed, sizeof(int)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}

	key_data.prev_int_9 = _dos_getvect( 9 );
	_dos_setvect( 9, key_handler );

	atexit( key_close );
}
コード例 #19
0
ファイル: menu.c プロジェクト: Ringdingcoder/d1x
//returns number of item chosen
int DoMenu() 
{
	int menu_choice[25];
	newmenu_item m[25];
	int num_options = 0;

	if ( Players[Player_num].callsign[0]==0 )	{
		RegisterPlayer();
		return 0;
	}
	
	if ((Game_mode & GM_SERIAL) || (Game_mode & GM_MODEM)) {
		do_option(MENU_START_SERIAL);
		return 0;
	}

	create_main_menu(m, menu_choice, &num_options);

	do {
		keyd_time_when_last_pressed = timer_get_fixed_seconds();		// .. 20 seconds from now!
		if (main_menu_choice < 0 )	main_menu_choice = 0;		
		Menu_draw_copyright = 1;
                //added on 11/19/98 by Victor Rachels to add immediate join/start
                 if(start_net_immediately == 1){
					if ( gr_palette_faded_out )	{//fix black screen with -startnetgame
						gr_palette_fade_in( gr_palette, 32, 0 );
					}
                    do_option(MENU_START_NETGAME);
                    start_net_immediately = 0;
				 }
                 else if(start_net_immediately == 2)
                  {
                    do_option(MENU_JOIN_NETGAME);
                    start_net_immediately = 0;
                  }
                 else
                  {
                //end this section addition - VR
                   extern int Menu_Special;
                    Menu_Special = 1;
                    main_menu_choice = newmenu_do2(NULL, NULL, num_options, m, autodemo_menu_check, main_menu_choice, Menu_pcx_name);
                    if ( main_menu_choice > -1 ) do_option(menu_choice[main_menu_choice]);
                  }
		create_main_menu(m, menu_choice, &num_options);	//	may have to change, eg, maybe selected pilot and no save games.
	} while( Function_mode==FMODE_MENU );

//	if (main_menu_choice != -2)
//		do_auto_demo = 0;		// No more auto demos
	if ( Function_mode==FMODE_GAME )	
		gr_palette_fade_out( gr_palette, 32, 0 );

	return main_menu_choice;
}
コード例 #20
0
ファイル: key.c プロジェクト: gameplayer22/d2x-1
void key_init()
{
	Installed=1;

	keyd_time_when_last_pressed = timer_get_fixed_seconds();
	keyd_buffer_type = 1;
	keyd_repeat = 1;

// Clear the keyboard array
	key_flush();
	atexit(key_close);
}
コード例 #21
0
ファイル: joy.c プロジェクト: gameplayer22/d2x-1
fix joy_get_button_down_time(int btn)
{
	fix time = F0_0;

	if (!num_joysticks)
		return 0;

	event_poll();

	switch (Joystick.buttons[btn].state) {
	case SDL_PRESSED:
		time = timer_get_fixed_seconds() - Joystick.buttons[btn].time_went_down;
		Joystick.buttons[btn].time_went_down = timer_get_fixed_seconds();
		break;
	case SDL_RELEASED:
		time = 0;
		break;
	}

	return time;
}
コード例 #22
0
int fs2netd_update_valid_tables_do()
{
	if (timeout == -1) {
		timeout = timer_get_fixed_seconds() + (30 * F1_0);
	}

	int rc = FS2NetD_ValidateTableList(do_full_packet);

	// if timeout passes then bail on crc failure
	if ( timer_get_fixed_seconds() > timeout ) {
		timeout = -1;
		return 1;
	}

	do_full_packet = 0;

	if ( rc == 0 ) {
		return 0;
	}

	switch (rc) {
		// some error occured, assume that there are no valid table crcs
		case -1:
			timeout = -1;
			return 2;

		// timeout
		case 1:
			timeout = -1;
			return 1;

		// done!
		case 2:
			timeout = -1;
			return 3;
	}

	return 0;
}
コード例 #23
0
ファイル: titles.c プロジェクト: btb/d1x
//	-----------------------------------------------------------------------------
void flash_cursor(int cursor_flag)
{
	if (cursor_flag == 0)
		return;

	if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
		gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
	else
		gr_set_fontcolor(Erase_color, -1);

	gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );

}
コード例 #24
0
void dc_draw_cursor( SCP_string &cmd_string, int x, int y )
{
	int t;
	int w, h;	// gr_string width and height

	t = timer_get_fixed_seconds() / (F1_0/3);
	if ( t & 1 ) {
		gr_get_string_size( &w, &h, cmd_string.c_str() );

		w %= (DCOLS * Current_font->w);
		//gr_string( w, debug_y*16, "_" );
		gr_rect((x + (w + 1)), (y + (h + 1)), 2, Current_font->h, GR_RESIZE_NONE);
	}
}
コード例 #25
0
int fs2netd_load_servers_do()
{
	if (timeout == -1) {
		timeout = timer_get_fixed_seconds() + (30 * F1_0);
	}

	// if timeout passes then bail on stats failure
	if ( timer_get_fixed_seconds() > timeout ) {
		timeout = -1;
		return 3;
	}

	int rescode = FS2NetD_GetServerList(do_full_packet);

	do_full_packet = 0;

	if (rescode) {
		timeout = -1;
		return rescode;
	}

	return 0;
}
コード例 #26
0
int fs2netd_update_ban_list_do()
{
	if (timeout == -1) {
		timeout = timer_get_fixed_seconds() + (30 * F1_0);
	}

	// if timeout passes then bail on stats failure
	if ( timer_get_fixed_seconds() > timeout ) {
		timeout = -1;
		return 2;
	}

	FS2NetD_ban_list = FS2NetD_GetBanList(&FS2NetD_ban_list_count, do_full_packet);

	do_full_packet = 0;

	if ( (FS2NetD_ban_list != NULL) || (FS2NetD_ban_list_count >= 0) ) {
		timeout = -1;
		return 1;
	}

	return 0;
}
コード例 #27
0
ファイル: EHOSTAGE.C プロジェクト: NonCreature0714/descent
//-------------------------------------------------------------------------
// Called from the editor... does one instance of the hostage dialog box
//-------------------------------------------------------------------------
int do_hostage_dialog()
{
	int i;

	// Only open 1 instance of this window...
	if ( MainWindow != NULL ) return 0;
	
	// Close other windows
	close_all_windows();

	CurrentHostageIndex = 0;
	SelectClosestHostage();

	// Open a window with a quit button
	MainWindow = ui_open_window( TMAPBOX_X+10, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
	QuitButton = ui_add_gadget_button( MainWindow, 20, 222, 48, 40, "Done", NULL );

	ui_wprintf_at( MainWindow, 10, 32,"&Message:" );
	HostageText = ui_add_gadget_inputbox( MainWindow, 10, 50, HOSTAGE_MESSAGE_LEN, HOSTAGE_MESSAGE_LEN, HostageMessage );

	// The little box the hostage vclip will play in.
	HostageViewBox = ui_add_gadget_userbox( MainWindow,10, 90+10, 64, 64 );

	// A bunch of buttons...
	i = 90;
//@@	ui_add_gadget_button( MainWindow,155,i,70, 26, "<< Type", SelectPrevVclip );
//@@	ui_add_gadget_button( MainWindow,155+70,i,70, 26, "Type >>", SelectNextVclip );i += 29;		
//@@	ui_add_gadget_button( MainWindow,155,i,70, 26, "<< Sound",  find_prev_hostage_sound );
//@@	ui_add_gadget_button( MainWindow,155+70,i,70, 26, "Sound >>", find_next_hostage_sound );i += 29;		

	ui_add_gadget_button( MainWindow,155,i,70, 26, "<< Face", SelectPrevFace );
	ui_add_gadget_button( MainWindow,155+70,i,70, 26, "Face >>", SelectNextFace );i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Play sound", PlayHostageSound );i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Next Hostage", SelectNextHostage );	i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Prev Hostage", SelectPrevHostage ); i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Compress All", CompressHostages ); i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Delete", ObjectDelete );	i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Create New", PlaceHostage );	i += 29;		
	
	Time = timer_get_fixed_seconds();

	LastHostageIndex = -2;		// Set to some dummy value so everything works ok on the first frame.
	
//	if ( CurrentHostageIndex == -1 )
//		SelectNextHostage();

	return 1;

}
コード例 #28
0
ファイル: console.cpp プロジェクト: Kobrar/fs2open.github.com
void dc_draw_cursor( SCP_string &cmd_string, int x, int y )
{
	int t;
	int w, h;	// gr_string width and height

	t = timer_get_fixed_seconds() / (F1_0/3);
	if ( t & 1 ) {
		gr_get_string_size( &w, &h, cmd_string.c_str() );

		w %= (DCOLS * col_width);
		//gr_string( w, debug_y*16, "_" );
		gr_rect(gr_screen.center_offset_x + (x + (w + 1)), gr_screen.center_offset_y + (y + (h + 1)), 2,
			fl2i(font::get_current_font()->getHeight()), GR_RESIZE_NONE);
	}
}
コード例 #29
0
ファイル: joyhh.c プロジェクト: Ringdingcoder/d1x
fix joy_get_button_down_time( int btn ) 
{
        fix count;

        if ((!joy_installed)||(!joy_present)) return 0;
	if ( btn >= MAX_BUTTONS ) return 0;

        joy_get_btns();

        if (joystick.buttons[btn].state) {
                count = timer_get_fixed_seconds() - joystick.buttons[btn].timedown;
                joystick.buttons[btn].timedown = 0;
        } else count = 0;
        
        return count;
}
コード例 #30
0
ファイル: mouse.c プロジェクト: gameplayer22/d2x-1
// Returns how long this button has been down since last call.
fix mouse_button_down_time(int button)
{
	fix time_down, time;

	event_poll();

	if (!Mouse.buttons[button].pressed) {
		time_down = Mouse.buttons[button].time_held_down;
		Mouse.buttons[button].time_held_down = 0;
	} else {
		time = timer_get_fixed_seconds();
		time_down = time - Mouse.buttons[button].time_held_down;
		Mouse.buttons[button].time_held_down = time;
	}
	return time_down;
}