Ejemplo n.º 1
0
void	MazePig( void )
{
#ifdef USEX
	Fx2ShowPig( (int)pig_x[ level ]*32, (int)pig_y[level]*32, 256, 208 );
#else
	Fx2ShowPig( (int)pig_x[ level ]*32-1, (int)pig_y[level]*32, 240, 180 );
#endif
}
Ejemplo n.º 2
0
int tetris_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;
	int				i;
	int				fd;
	FILE			*fp;
	char			*line;
	char			*p;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

/* load setup */
	fp = fopen( CONFIGDIR "/games.cfg", "r" );
	if ( fp )
	{
		line=malloc(128);
		isalloc=1;
#ifdef HAVE_CURL
		proxy_addr=0;
		proxy_user=0;
#endif
		hscore=0;
		while( fgets( line, 128, fp ) )
		{
			if ( *line == '#' )
				continue;
			if ( *line == ';' )
				continue;
			p=strchr(line,'\n');
			if ( p )
				*p=0;
			p=strchr(line,'=');
			if ( !p )
				continue;
			*p=0;
			p++;
#ifdef HAVE_CURL
			if ( !strcmp(line,"proxy") )
				proxy_addr=strdup(p);
			else if ( !strcmp(line,"proxy_user") )
				proxy_user=strdup(p);
			else if ( !strcmp(line,"hscore") )
				hscore=strdup(p);
#endif
		}
		fclose(fp);
		free(line);
	}

	fd = open( GAMESDIR "/tetris.hscore", O_RDONLY );
	if ( fd == -1 )
	{
		mkdir( GAMESDIR, 567 );
		for( i=0; i < 8; i++ )
		{
			strcpy(hsc[i].name,"nobody");
			hsc[i].points=30;
		}
	}
	else
	{
		read( fd, hsc, sizeof(hsc) );
		close(fd);
	}

#ifdef HAVE_CURL
	if ( hscore )
	{
		LoadHScore();
	}
#endif

#if defined(HAVE_DBOX_HARDWARE) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
	Fx2ShowPig( 480, 400, 176, 144 );
#endif

	while( doexit != 3 )
	{
		BoardInitialize();
		DrawBoard( );	/* 0 = all */
		NextItem();
#ifdef HAVE_DREAMBOX_HARDWARE
		Fx2ShowPig(480, 400, 176, 144 );
#endif
		doexit=0;
		while( !doexit )
		{
			tv.tv_sec = 0;
			tv.tv_usec = 10000;
			x = select( 0, 0, 0, 0, &tv );		/* 10ms pause */
			RcGetActCode( );
			if ( doexit )
				break;
			tv.tv_sec = 0;
			tv.tv_usec = 10000;
			x = select( 0, 0, 0, 0, &tv );		/* 10ms pause */
			RcGetActCode( );
			if ( doexit )
				break;
			MoveSide();
			if ( !FallDown() )
			{
				RemoveCompl();
				if ( !NextItem() )
					doexit=1;
			}
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif

			RcGetActCode( );
		}

		if ( doexit != 3 )
		{
			actcode=0xee;
			DrawGameOver();
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			doexit=0;
			SaveGame();
#ifdef HAVE_CURL
			if ( use_ihsc )
				ShowIHScore();
#endif
			ShowHScore(hsc);
			Fx2PigPause();

#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			i=0;
			actcode=0xee;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
				i++;
				if ( i == 50 )
				{
					FBDrawString( 190, 480, 48, "press OK for new game",GRAY,0);
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
					FBFlushGrafic();
#endif
				}
			}
			Fx2PigResume();
		}
	}

	Fx2StopPig();

#if defined(HAVE_DBOX_HARDWARE) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}
#endif

	RcClose();
	FBClose();

/* save hscore */
	fd = open( GAMESDIR "/tetris.hscore", O_CREAT|O_WRONLY, 438 );
	if ( fd != -1 )
	{
		write( fd, hsc, sizeof(hsc) );
		close(fd);
	}

	if ( isalloc )
	{
#ifdef HAVE_CURL
		if ( proxy_addr )
			free ( proxy_addr );
		if ( proxy_user )
			free ( proxy_user );
#endif
		if ( hscore )
			free ( hscore );
	}

	return 0;
}
int snake_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int		x;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

	Fx2ShowPig( 540, 449, 135, 96 );

	while ( doexit != 3 ) {
		DrawMaze( );	/* 0 = all */

		doexit=0;
		while ( !doexit ) {
			tv.tv_sec = 0;
			tv.tv_usec = 100000;
			x = select( 0, 0, 0, 0, &tv );		/* 10ms pause */

			RcGetActCode( );
			MoveSnake();
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
		}

		FreeSnake();

		if ( doexit != 3 ) {
			actcode=0xee;
			DrawFinalScore();
			DrawGameOver();
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif

			doexit=0;
			while (( actcode != RC_OK ) && !doexit ) {
				tv.tv_sec = 0;
				tv.tv_usec = 200000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
			}
		}
	}

	Fx2StopPig();

	/* fx2 */
	/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while ( realcode != 0xee ) {
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	return 0;
}
Ejemplo n.º 4
0
int mines_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;


	while( doexit != 3 )
	{
		BoardInitialize();
		DrawBoard( 0 );
		Fx2ShowPig( 470, 300, 176, 144 );

		doexit=0;
		while( !doexit )
		{
			tv.tv_sec = 0;
			tv.tv_usec = 10000;
			x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
	
			RcGetActCode( );
			MoveMouse();
#ifdef USEX
			FBFlushGrafic();
#endif
		}

		if ( doexit != 3 )
		{
			actcode=0xee;
			if ( doexit ==2 )
				DrawScore();
			else
				DrawGameOver();
#ifdef USEX
			FBFlushGrafic();
#endif
			doexit=0;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
			}
		}
	}

	Fx2StopPig();

/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	return 0;
}
Ejemplo n.º 5
0
int master_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;


	while( doexit != 3 )
	{
		MasterInitialize();

#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
		FBFlushGrafic();
#endif
		Fx2ShowPig( 430, 355, 176, 144 );

		doexit=0;
		while( !doexit )
		{
			tv.tv_sec = 0;
			tv.tv_usec = 200000;
			select( 0, 0, 0, 0, &tv );

			actcode=0xee;
			RcGetActCode( );
			Play();
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			while( realcode != 0xee )
				RcGetActCode( );
		}
		if ( doexit == 4 )		// level changed
		{
			doexit=0;
			continue;
		}

		if ( doexit != 3 )
		{
			actcode=0xee;
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			doexit=0;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
				if (( actcode > 0 ) && (actcode < 5 ))
				{
					Play();
					doexit=1;
				}
			}
		}
	}

	Fx2StopPig();

/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	return 0;
}
Ejemplo n.º 6
0
int soko_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

	Fx2ShowPig( 540, 450, 120, 90 );

	ladeVerzeichnis();
	Startbildschirm();

	while( doexit != 3 )
	{
		doexit=0;
		BoardInitialize();
#ifdef USEX
		FBFlushGrafic();
#endif

		if ( doexit == 4 )	/* fx2 - install error: no level found */
		{
			doexit=0;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
			}
			break;
		}

		while( !doexit )
		{
			tv.tv_sec = 0;
			tv.tv_usec = 10000;
			x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
	
			RcGetActCode( );
			MoveMouse();
		}

		if ( doexit != 3 )
		{
			actcode=0xee;
			if ( doexit ==2 )
				DrawScore();
			else
				DrawGameOver();
				if (level+1 < max_level)
					{
					level++;
					}
				else
					{
					level = 0;
					}
			doexit=0;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
			}
		}
	}

	Fx2StopPig();

/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	freeMem();

	return 0;
}