Exemple #1
0
int main(int argc, const char *argv[])
{
	pid_t pid;

	 CLEAR();
	 HIDE_CURSOR();

	//开启终端读取一个字符的功能
	disable_terminal_return();

	//创建一个线程
	pid = fork();
	PERROR("fork", pid);

	//进入父进程//控制游戏的基本运行
	if (pid > 0)
	{
		//延时1秒,等待子进程就绪
		sleep(1);
		father_process();
	}

	//进入子进程//控制玩家的操作
	if (pid == 0)
	{	
		child_process();
	}

	CLEAR();
	RESET_CURSOR();
	SHOW_CURSOR();

	return 0;
}
Exemple #2
0
/*
Initialize the accelerant.  the_fd is the file handle of the device (in
/dev/graphics) that has been opened by the app_server (or some test harness).
We need to determine if the kernel driver and the accelerant are compatible.
If they are, get the accelerant ready to handle other hook functions and
report success or failure.
*/
status_t INIT_ACCELERANT(int the_fd)
{
	status_t result;
	int pointer_reservation; //mem reserved for pointer
	int cnt; 				 //used for iteration through the overlay buffers

	if (0) {
		time_t now = time (NULL);
		// LOG not available from here to next LOG: NULL si
//		MSG(("INIT_ACCELERANT: booted since %f ms %s\n", system_time()/1000.0, real_time_clock()));
		MSG(("INIT_ACCELERANT: %s", ctime (&now)));
	}

	/* note that we're the primary accelerant (accelerantIsClone is global) */
	accelerantIsClone = 0;

	/* do the initialization common to both the primary and the clones */
	result = init_common(the_fd);

	/* bail out if the common initialization failed */
	if (result != B_OK) goto error0;
	// LOG now available: !NULL si

	/* ensure that INIT_ACCELERANT is executed just once (copies should be clones) */
	if (si->accelerant_in_use)
	{
		result = B_NOT_ALLOWED;
		goto error1;
	}

	/* assume G450/G550 signals are connected straight through (before powerup) */
	si->crossed_conns = false;

	/* call the device specific init code */
	result = gx00_general_powerup();

	/* bail out if it failed */
	if (result != B_OK) goto error1;

	/*
	Now would be a good time to figure out what video modes your card supports.
	We'll place the list of modes in another shared area so all of the copies
	of the driver can see them.  The primary copy of the accelerant (ie the one
	initialized with this routine) will own the "one true copy" of the list.
	Everybody else get's a read-only clone.
	*/
	result = create_mode_list();
	if (result != B_OK) 
	{
		goto error1;
	}

	/*
	Put the cursor at the start of the frame buffer.  The typical 64x64 4 color
	(black, white, transparent, inverse) takes up 1024 bytes of RAM.
	*/
	/* Initialize the rest of the cursor information while we're here */
	si->cursor.width = 16;
	si->cursor.height = 16;
	si->cursor.hot_x = 0;
	si->cursor.hot_y = 0;
	si->cursor.x = 0;
	si->cursor.y = 0;

	/*
	Put the frame buffer immediately following the cursor data. We store this
	info in a frame_buffer_config structure to make it convienient to return
	to the app_server later.
	*/
	pointer_reservation = 0;
	/* MIL 1/2 cards have a seperate buffer for the cursorbitmap inside the DAC */
	if ((si->ps.card_type >= G100) && si->settings.hardcursor)
		pointer_reservation = 1024;

	si->fbc.frame_buffer = (void *)((char *)si->framebuffer+pointer_reservation);
	si->fbc.frame_buffer_dma = (void *)((char *)si->framebuffer_pci+pointer_reservation);

	/* count of issued parameters or commands */
	si->engine.last_idle = si->engine.count = 0;
	INIT_BEN(si->engine.lock);

	INIT_BEN(si->overlay.lock);
	for (cnt = 0; cnt < MAXBUFFERS; cnt++)
	{
		/* make sure overlay buffers are 'marked' as being free */
		si->overlay.myBuffer[cnt].buffer = NULL;
		si->overlay.myBuffer[cnt].buffer_dma = NULL;
	}
	/* make sure overlay unit is 'marked' as being free */
	si->overlay.myToken = NULL;	

	/* note that overlay is not in use (for gx00_bes_move_overlay()) */
	si->overlay.active = false;

	/* bail out if something failed */
	if (result != B_OK) goto error1;

	/* initialise various cursor stuff*/
	gx00_crtc_cursor_init();

	/* ensure cursor state */
	SHOW_CURSOR(false);

	/* ensure DPMS state */
	si->dpms_flags = B_DPMS_ON;

	/* a winner! */
	result = B_OK;
	/* ensure that INIT_ACCELERANT won't be executed again (copies should be clones) */
	si->accelerant_in_use = true;
	goto error0;

error1:
	/*
	Initialization failed after init_common() succeeded, so we need to clean
	up before quiting.
	*/
	uninit_common();

error0:
	return result;
}