extern void ClosePass2FilesAndFreeMem( void ) /*******************************************/ { ExeFileInfo *tmp; ExeFileInfo *old; // char *tmpfilename; tmp = &(Pass2Info.TmpFile); old = &(Pass2Info.OldFile); // tmpfilename = Pass2Info.TmpFileName; if( old->IsOpen ) { RcClose( old->Handle ); old->IsOpen = FALSE; } switch( old->Type ) { case EXE_TYPE_NE_WIN: case EXE_TYPE_NE_OS2: FreeNEFileInfoPtrs( &old->u.NEInfo ); break; case EXE_TYPE_PE: FreePEFileInfoPtrs( &old->u.PEInfo ); break; case EXE_TYPE_LX: FreeLXFileInfoPtrs( &old->u.LXInfo ); break; default: //EXE_TYPE_UNKNOWN break; } if( tmp->IsOpen ) { RcClose( tmp->Handle ); tmp->IsOpen = FALSE; } switch( tmp->Type ) { case EXE_TYPE_NE_WIN: case EXE_TYPE_NE_OS2: FreeNEFileInfoPtrs( &tmp->u.NEInfo ); break; case EXE_TYPE_PE: FreePEFileInfoPtrs( &tmp->u.PEInfo ); break; case EXE_TYPE_LX: FreeLXFileInfoPtrs( &tmp->u.LXInfo ); break; default: //EXE_TYPE_UNKNOWN break; } CloseResFiles( Pass2Info.ResFiles ); } /* ClosePass2FilesAndFreeMem */
static bool CreatePreprocFile( void ) { int hdl; bool error; int ch; char ch1; int len; error = FALSE; hdl = RcOpen( CmdLineParms.OutResFileName, O_WRONLY | O_TEXT | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH ); if( hdl == -1 ) { RcError( ERR_CANT_OPEN_FILE, CmdLineParms.OutResFileName, strerror( errno ) ); error = TRUE; } else { ch = RcIoGetChar(); while( ch != RC_EOF ) { ch1 = (char) ch; len = RcWrite( hdl, &ch1, 1 ); if( len != 1 ) { RcError( ERR_WRITTING_FILE, CmdLineParms.OutResFileName, strerror( errno ) ); error = TRUE; } ch = RcIoGetChar(); } } if( hdl != -1 ) RcClose( hdl ); return( error ); }
static void ClosePhysicalFile( PhysFileInfo * phys ) /**************************************************/ { if( phys->IsOpen ) { RcClose( phys->Handle ); phys->IsOpen = FALSE; } } /* ClosePhysicalFile */
void CloseAllFiles( void ) { /***************************/ unsigned i; for( i = 0; i < MAX_OPEN_FILES; i++ ) { if( openFileList[i] != NIL_HANDLE ) { RcClose( openFileList[i] ); } } }
// ---------------------------------------------------------------------------- // 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; }
RcStatus OpenTable( char *fname, char *path ) { int fp; RcStatus status; status = RS_OK; _searchenv( fname, "PATH", path ); if( path[0] == '\0' ) return( RS_FILE_NOT_FOUND ); fp = RcOpen( path, O_RDONLY | O_BINARY ); if( fp == -1 ) { status = RS_OPEN_ERROR; } if( status == RS_OK ) status = readDBHeader( fp ); if( status == RS_OK ) status = readDBRanges( fp ); if( status == RS_OK ) status = readDBIndex( fp ); if( status == RS_OK ) status = readDBTable( fp ); if( status != RS_OPEN_ERROR ) RcClose( fp ); if( status == RS_OK ) { ConvToUnicode = DBStringToUnicode; } return( status ); }
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; }
static void AddFontResources( WResID * name, ResMemFlags flags, char * filename ) /**************************************************************/ { FontInfo info; char * devicename; char * facename; int handle; int error; int err_code; ReadStrErrInfo readstr_err; if (name->IsName) { RcError( ERR_FONT_NAME ); return; } handle = RcIoOpenInput( filename, O_RDONLY | O_BINARY ); if (handle == -1) goto FILE_OPEN_ERROR; error = readFontInfo( handle, &info, &err_code ); if( error != RS_OK) goto READ_HEADER_ERROR; error = copyFont( &info, handle, name, flags, &err_code ); if( error != RS_OK ) goto COPY_FONT_ERROR; devicename = readString( handle, info.dfDevice, &readstr_err ); if( devicename == NULL ) { error = readstr_err.status; err_code = readstr_err.err_code; goto READ_HEADER_ERROR; } facename = readString( handle, info.dfFace, &readstr_err ); if (facename == NULL) { error = readstr_err.status; err_code = readstr_err.err_code; RcMemFree( devicename ); goto READ_HEADER_ERROR; } AddFontToDir( &info, devicename, facename, name ); RcMemFree( devicename ); RcMemFree( facename ); RcClose( handle ); return; FILE_OPEN_ERROR: RcError( ERR_CANT_OPEN_FILE, filename, strerror( errno ) ); ErrorHasOccured = TRUE; RcMemFree( name ); return; READ_HEADER_ERROR: ReportCopyError( error, ERR_READING_FONT, filename, err_code ); ErrorHasOccured = TRUE; RcMemFree( name ); RcClose( handle ); return; COPY_FONT_ERROR: ReportCopyError( error, ERR_READING_FONT, filename, err_code ); ErrorHasOccured = TRUE; RcClose( handle ); return; }