void Play_Loaded_Fli( fli_file_type *fli_file ) { unsigned char exit = 0; /* Flag for the loop */ file_length = fli_file->file_length; /* Update global */ DB_Clear_Screen(); /* Clear the double buffer */ while( !exit ) { if ( Read_Chunk_Ram( fli_file->file_buffer, &fli_file->file_pos ) == 0 ) /* If we reach the last chunk */ exit = 1; if( exit == 1 ) /* Reset to first frame (set in color_chunk) */ { fli_file->file_pos = first_frame; exit = 0; } Swap_Buffer(); /* Swap the double buffer into video memory */ // AJT // if( Check_Raw() == 1 || Jon_Kbhit() ) /* If the user presses a key, exit */ // { // if( Jon_Kbhit() ) /* Eat the keypress */ // Jon_Getkey(); // // while( Check_Raw() == 1 ) {} // exit = 1; // } } DB_Clear_Screen(); Swap_Buffer(); fli_file->file_pos = 128; } /* End of play_fli_ram */
void Play_Fli( const char *filename ) { flic_header header; /* Header for the entire file */ FILE *fp; /* Pointer to opened .fli file */ unsigned char exit = 0; /* Flag for the loop */ char newfilename[512]; uint32_t time; sprintf(newfilename,"%s%s",g_DataPath,filename); fp = fopen( newfilename, "rb" ); /* Open file */ fread( &header, sizeof( flic_header ), 1, fp ); /* Get the flic header */ fseek( fp, 128, SEEK_SET ); /* Move to end of header */ DB_Clear_Screen(); /* Clear the double buffer */ time = SYS_GetTimeMS(); while ( !feof( fp ) && !exit ) { if ( Read_Chunk( fp ) == 0 ) /* If we reach the last chunk */ exit = 1; if( exit == 1 ) /* Reset to first frame (set in color_chunk) */ { fseek( fp, first_frame, SEEK_SET ); /* exit = 0; */ } Swap_Buffer(); /* Swap the double buffer into video memory */ while ( SYS_GetTimeMS() < (time + 33) ); time = SYS_GetTimeMS(); // AJT: // if( Jon_Kbhit() ) /* If the user presses a key, exit */ // { // exit = 1; // } } fclose( fp ); /* Close the file */ }
int PlayFliProcess() { int exit = 0; if ( feof( gCurrentFile ) ) return 0; if ( SYS_GetTimeMS() < (gFrameTime + 33) ) return 1; gFrameTime = SYS_GetTimeMS(); if ( Read_Chunk( gCurrentFile ) == 0 ) /* If we reach the last chunk */ return 0; Swap_Buffer(); /* Swap the double buffer into video memory */ return 1; }
void One_Frame( fli_file_type *fli_file ) { long done = 0; file_length = fli_file->file_length; /* Update global */ fli_file->first_frame = 128; if ( Read_Chunk_Ram( fli_file->file_buffer, &fli_file->file_pos ) == 0 ) /* If we reach the last chunk */ done = 1; if( done == 1 ) /* Reset to first frame (set in color_chunk) */ { fli_file->file_pos = fli_file->first_frame; } Swap_Buffer(); /* Swap the double buffer into video memory */ } /* End of One_Frame */
void Play_Fli_Buffered( char *filename ) { unsigned char done = 0; /* Flag for the loop */ FILE *fp; unsigned char *buffer_one, *buffer_two, *current_buffer, *old_buffer; flic_header header; uint32_t file_pos = 0; int flip = 0; unsigned long bytes_left = 0; unsigned long end_file_pos, current_file_pos; int done_reading = 0; /* Flag to say we're done reading file */ long i, temp; char newfilename[512]; sprintf(newfilename,"%s%s",g_DataPath,filename); DB_Clear_Screen(); /* Clear screen before enabling palette */ Swap_Buffer(); /* Open the damned file */ fp = fopen( newfilename, "rb" ); if( !fp ) return; /* Read the damm header */ fread( &header, sizeof( header ), 1, fp); current_frame = 0; /* fprintf(stderr, "Number of frames is %d \n", header.number_of_frames ); Get_Keypress(); */ /* Prime the buffer */ if( (buffer_one = (unsigned char*)malloc( FLI_BUFFER_SIZE )) == NULL ) { fprintf(stderr, "Error mallocing memory in FLI FILE reader \n"); return; } if( (buffer_two = (unsigned char*)malloc( FLI_BUFFER_SIZE )) == NULL ) { fprintf(stderr, "Error mallocing memory in FLI FILE reader \n"); return; } fread( buffer_one, FLI_BUFFER_SIZE, 1, fp ); current_buffer = buffer_one; old_buffer = buffer_two; file_length = FLI_BUFFER_SIZE; /* Update global */ //Set_Timer(0); // AJT: while( done == 0 ) { if( Read_Chunk_Ram( current_buffer, &file_pos ) == 0 ) /* If we reach the last chunk */ done = 1; if( current_frame > header.number_of_frames - 2 ) done = 1; // AJT: /* if( Jon_Kbhit() ) if( Jon_Getkey() == INDEX_ESC ) done = 1; */ // AJT // if( ceiling_on ) // while( Check_Timer() < ((float)TIMER_CLICKS_PER_SECOND / (float)25) ); // Set_Timer(0); // Wait_For_Vsync(); if( !done ) { Swap_Buffer(); /* Swap the double buffer into video memory */ } /* If we have read in enough shizit load summore */ if( (file_pos > (1)) && !done_reading ) { current_file_pos = ftell( fp ); fseek( fp, 0, SEEK_END ); end_file_pos = ftell( fp ); fseek( fp, current_file_pos, SEEK_SET ); bytes_left = end_file_pos - current_file_pos; /* fprintf(stderr, "bytes left is %ld \n", bytes_left ); */ if( bytes_left > 0 ) { if( !flip ) { flip = !flip; old_buffer = buffer_one; current_buffer = buffer_two; } else { flip = !flip; old_buffer = buffer_two; current_buffer = buffer_one; } temp = 0; for( i = file_pos; i < FLI_BUFFER_SIZE; i++ ) { current_buffer[temp++] = old_buffer[i]; } /* End for */ file_pos = 0; if( bytes_left >= (unsigned long)(FLI_BUFFER_SIZE - temp) ) { fread( ¤t_buffer[temp], (FLI_BUFFER_SIZE - temp), 1, fp ); } else { fread( ¤t_buffer[temp], bytes_left, 1, fp ); file_length = temp + bytes_left; } } else { done_reading = 1; } } /* End if time to load shizit */ } /* End while not done */ DB_Clear_Screen(); Swap_Buffer(); free( buffer_one ); /* Free da memory */ free( buffer_two ); } /* End of Play_Fli_Buffered */
void Play_Fli_Ram( char *filename ) { flic_header header; /* Header for the entire file */ FILE *fp; /* Pointer to opened .fli file */ unsigned char exit = 0; /* Flag for the loop */ unsigned char *file_buffer; uint32_t file_pos = 0; long temp; long i; unsigned char *temp_buffer; char newfilename[512]; sprintf(newfilename,"%s%s",g_DataPath,filename); fp = fopen( newfilename, "rb" ); /* Open file */ /* Allocate space in Ram for fli file */ fseek( fp, 0, SEEK_END ); /* Move to end of file */ /* This should be the size of the file */ file_buffer = (unsigned char*)malloc( temp = ftell( fp ) ); fseek( fp, 0, SEEK_SET ); /* Move back to beginning of file */ fread( file_buffer, temp, 1, fp ); /* Read whole file into ram */ fclose( fp ); /* Close the file */ /* Alias pointer to header */ temp_buffer = (unsigned char *)&header; for( i = 0; i < 128; i++ ) /* Read in the header from ram */ { temp_buffer[i] = file_buffer[i]; file_pos++; } file_length = header.file_size; DB_Clear_Screen(); /* Clear the double buffer */ while( !exit ) { if ( Read_Chunk_Ram( file_buffer, &file_pos ) == 0 ) /* If we reach the last chunk */ exit = 1; if( exit == 1 ) /* Reset to first frame (set in color_chunk) */ { file_pos = first_frame; exit = 0; } Swap_Buffer(); /* Swap the double buffer into video memory */ // AJT // if( Check_Raw() == 1 || Jon_Kbhit() ) /* If the user presses a key, exit */ // { // if( Jon_Kbhit() ) /* Eat the keypress */ // Jon_Getkey(); // // while( Check_Raw() == 1 ) {} // exit = 1; // } } free( file_buffer ); DB_Clear_Screen(); Swap_Buffer(); } /* End of play_fli_ram */