// ---------------------------------------------------------------------------- // shutdown // ---------------------------------------------------------------------------- void shutdown() { Sleep(300000); // 300ms pause /* realcode = RC_0; while(realcode != 0xEE) { RcGetActCode(); } */ RcClose(); FBClose(); }
int yahtzee_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; doexit=0; while( !doexit ) { EnterPlayer(); if ( !doexit ) { RunYahtzee(); DrawWinner(); } } 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; }
int solitair_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile ) { int rc = 0; CTable table; if ( FBInitialize( 720, 576, 8, fdfb ) < 0 ) return -1; Set_8Bit_Pal(); if ( RcInitialize( fdrc ) < 0 ) return -1; rc = table.Run(); RcClose(); FBClose(); return rc; }
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; }
int pacman_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile ) { struct timeval tv; int x; int jumplevel=-1; if ( FBInitialize( 720, 576, 8, fdfb ) < 0 ) return -1; setup_colors(); if ( RcInitialize( fdrc ) < 0 ) return -1; InitLevel( 0 ); while( doexit != 3 ) { MazeInitialize(); DrawMaze( ); /* 0 = all */ DrawFill(); DrawGhosts( ); DrawPac( ); MazePig(); doexit=0; while( !doexit ) { tv.tv_sec = 0; #ifdef HAVE_DREAMBOX_HARDWARE tv.tv_usec = 8000; #else tv.tv_usec = 1000; #endif x = select( 0, 0, 0, 0, &tv ); /* 10ms pause */ MovePac( ); MoveGhosts( ); DrawGhosts( ); DrawPac( ); #if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE) FBFlushGrafic(); #endif RcGetActCode( ); CheckGhosts( ); } if ( doexit != 3 ) { actcode=0xee; if ( score ) DrawScore(); if ( !gametime ) DrawGameOver(); #if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE) FBFlushGrafic(); #endif doexit=0; jumplevel=-1; 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 == RC_HELP ) { while( realcode != 0xee ) RcGetActCode( ); actcode=0xee; while(( actcode == 0xee ) && !doexit ) { tv.tv_sec = 0; tv.tv_usec = 100000; x = select( 0, 0, 0, 0, &tv ); /* 100ms pause */ RcGetActCode( ); } if ( actcode <= RC_9 ) { jumplevel=actcode; actcode=RC_OK; } } } if ( gametime ) NextLevel(); else InitLevel( jumplevel ); } } 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; }
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; }
int bouquet_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile ) { struct timeval tv; int t; int r; int i; int idx=0; int cnum; int x; Channel *ch=NULL; FILE *fp; char line[512]; char l2[512]; char *p; if ( FBInitialize( 720, 576, 8, fdfb ) < 0 ) return -1; setup_colors(); if ( RcInitialize( fdrc ) < 0 ) return -1; /* load setup */ fp = fopen( CONFIGDIR "/zapit/services.xml", "r" ); if ( !fp ) { FBDrawString( 190, 100, 64, "services.xml not found !", RED, 0 ); #ifdef USEX FBFlushGrafic(); #endif tv.tv_sec = 5; tv.tv_usec = 0; select( 0, 0, 0, 0, &tv ); RcClose(); FBClose(); return 0; } while( fgets(line,512,fp) ) { num_lines++; if ( strstr(line,"channelNR") ) { p=strstr(line,"serviceType"); if ( p && (*(p+15) == '0') ) { p+=16; if ( *p == '1' ) num_ch_tv++; if ( *p == '2' ) num_ch_radio++; if ( *p == '4' ) num_ch_tv++; } } } fclose(fp); lines = (char**)malloc(sizeof(char*)*num_lines); tv_ch = (Channel*)malloc(sizeof(Channel)*num_ch_tv); radio_ch = (Channel*)malloc(sizeof(Channel)*num_ch_radio); for( i=0;i<num_ch_tv;i++) tv_ch[i].flag=0; for( i=0;i<num_ch_radio;i++) radio_ch[i].flag=0; fp = fopen( CONFIGDIR "/zapit/services.xml", "r" ); t=num_ch_tv-1; r=num_ch_radio-1; for(i=0; i<num_lines;i++) { fgets( line, 512, fp ); lines[i] = strdup(line); if ( !strstr(line,"channelNR") ) continue; p=strstr(line,"name="); copyname(l2,p+6); p=strstr(line,"channelNR="); cnum=_atoi(p+11); if ( cnum ) idx=cnum-1; p=strstr(line,"serviceType"); if ( !p || ( *(p+15) != '0' ) ) continue; switch( *(p+16) ) { case '1' : case '4' : ch=tv_ch; if ( !cnum || ch[idx].flag ) { idx=t; t--; } break; case '2' : ch=radio_ch; if ( !cnum || ch[idx].flag ) { idx=r; r--; } break; default: p=0; break; } if ( !p ) continue; ch[idx].name=strdup(l2); ch[idx].flag=*(p+14); ch[idx].line=lines[i]; } fclose(fp); t=0; while( doexit != 3 ) { if ( t ) SortBouquet( radio_ch, num_ch_radio ); else SortBouquet( tv_ch, num_ch_tv ); t=!t; switch( doexit ) { case 2 : doexit=0; break; case 1 : SaveServices(); doexit=3; break; } } for( i=0; i<num_ch_tv; i++ ) free( tv_ch[i].name ); for( i=0; i<num_ch_radio; i++ ) free( radio_ch[i].name ); for( i=0; i<num_lines; i++ ) free( lines[i] ); free( lines ); free( tv_ch ); free( radio_ch ); /* 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; }
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; }
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; }