/*----------------------------------------------------------------------------- Name : binkOpen Description : wrapper for opening a Bink video file Inputs : filename - name of the Bink video file to open Outputs : Return : TRUE or FALSE ----------------------------------------------------------------------------*/ static bool binkOpen(char* filename) { char fullname[1024]; char cdname[1024]; char* dir; // get CD path strcpy(cdname,filePathPrepend(filename,FF_CDROM)); dir = getenv("HW_Data"); if (dir == NULL) { // set default path strcpy(fullname, filename); } else { // set HW_Data path strcpy(fullname, dir); strcat(fullname, "\\"); strcat(fullname, filename); } BinkSoundUseDirectSound(NULL); // try default path or HW_Data path bnk = BinkOpen(fullname, BINKNOTHREADEDIO); if (!bnk) { // try filename alone bnk = BinkOpen(filename, BINKNOTHREADEDIO); if (!bnk) { // try CD path bnk = BinkOpen(cdname, BINKNOTHREADEDIO); if (!bnk) { return FALSE; } } } // BinkSetSoundOnOff(bnk, 0); binkFrameRate = (real32)bnk->FrameRate / (real32)bnk->FrameRateDiv; return TRUE; }
void PlayBinkInstant(char *pszName,int iStop,int iLoop) { if(!iBinkTextureID) iBinkTextureID = g_pSurface->CreateNewTextureID(); if(pCvar_DrawBink->value <1) { LogToFile("[Bink]³¢ÊÔ²¥·Å%s µ«ÊDZ»Cvar×èÖ¹",pszName); return; } if(!iPlaying) { // Clear Mem if(pBinkMem) { LogToFile("[Bink]ÊÍ·ÅÄÚ´æ¿Õ¼ä"); free(pBinkMem); pBinkMem = NULL; } hBink = BinkOpen(pszName,135266304); if(!hBink) { LogToFile("[Bink]¼ÓÔØBIKÎļþʧ°Ü£º %s",pszName); return; } fStartTime = 0; iFrame = 1; iPlaying = 1; iBinkLoop = iLoop; iBinkStop = iStop; if(strstr(pszName,"scope")) { iBinkIsScope = 1; iFrame = 60; // skip some frames } else iBinkIsScope = 0; // Alloc Memory int iPixelSize = 4 * hBink->Width * hBink->Height; pBinkMem = (BYTE *)malloc(iPixelSize); if(pBinkMem) LogToFile("[Bink]ÉêÇëÄÚ´æ¿Õ¼ä:%d",iPixelSize); else LogToFile("[Bink]ÉêÇëÄÚ´æ¿Õ¼äʧ°Ü!"); } else { if(iStop) iPlaying = 0; } }
ITextureVideo::ITextureVideo(ITextureManager *manager, IString filename) : ITexture(manager,filename) { #if USE_BINK BinkSoundUseDirectSound( 0 ); Bink = BinkOpen( filename, 0 ); if (Bink) { int width=2; int height=2; while (width<Bink->Width) width*=2; while (height<Bink->Height) height*=2; m_pBuffer.SetImage(width,height); printf("Video loaded\n"); }else printf("Video loading error\n"); #endif }
BINKFLIC *BinkOpenFlic( const CHAR8 *cFilename ) { BINKFLIC *pBink; // Get an available flic slot from the list if( !( pBink = BinkGetFreeFlic() ) ) { ErrorMsg("BINK ERROR: Out of flic slots, cannot open another"); return(NULL); } #ifndef USE_VFS // Attempt opening the filename if(!(pBink->hFileHandle = FileOpen( const_cast<CHAR8*>(cFilename), FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE ) ) ) { ErrorMsg("BINK ERROR: Can't open the BINK file"); return(NULL); } //Get the real file handle for the file man handle for the smacker file HANDLE hFile = GetRealFileHandleFromFileManFileHandle( pBink->hFileHandle ); #else vfs::Path introname(cFilename); vfs::Path dir,filename; introname.splitLast(dir,filename); vfs::Path tempfile = vfs::Path(L"Temp") + filename; if(!getVFS()->fileExists(tempfile)) { try { if(!getVFS()->fileExists(introname)) { return NULL; } vfs::COpenReadFile rfile(introname); vfs::size_t size = rfile->getSize(); std::vector<vfs::Byte> data(size); rfile->read(&data[0],size); vfs::COpenWriteFile wfile(tempfile,true); wfile->write(&data[0],size); } catch(std::exception& ex) { SGP_RETHROW(_BS(L"Intro file \"") << filename << L"\" could not be extracted" << _BS::wget, ex); } } #endif #ifndef USE_VFS if( !( pBink->BinkHandle = BinkOpen((CHAR8 *)hFile, BINKFILEHANDLE ) ) ) //| SMACKTRACKS #else vfs::Path tempfilename; try { vfs::COpenWriteFile wfile(tempfile); if(!wfile->_getRealPath(tempfilename)) { return NULL; } } catch(std::exception& ex) { SGP_RETHROW(L"Temporary intro file could not be read", ex); } if( !( pBink->BinkHandle = BinkOpen(tempfilename.to_string().c_str(), BINKNOTHREADEDIO /*BINKFILEHANDLE*/ ) ) ) //| SMACKTRACKS #endif { ErrorMsg("BINK ERROR: Bink won't open the BINK file"); return(NULL); } // Make sure we have a video surface BinkSetupVideo(); pBink->cFilename = cFilename; pBink->lpDDS = lpBinkVideoPlayback2; pBink->hWindow = hBinkDisplayWindow; // Bink flic is now open and ready to go pBink->uiFlags |= BINK_FLIC_OPEN; return( pBink ); }
int PASCAL WinMain( HINSTANCE instance, HINSTANCE previous_instance, LPSTR cmd_line, int cmd_show ) { // // Win32 locals. // HWND window = 0; MSG msg; // // Miles locals // HDIGDRIVER digital=0; // // Try to create our window. // window = Build_window_handle( instance, previous_instance ); if ( !window ) { MessageBox( 0, "Error creating window.", "Windows", MB_OK | MB_ICONSTOP ); return( 1 ); } // // Open the Miles Sound System. AIL_startup(); #ifdef BINK51 digital = AIL_open_digital_driver( 44100, 16, MSS_MC_51_DISCRETE, 0 ); #else digital = AIL_open_digital_driver( 44100, 16, 2, 0 ); #endif if ( !digital ) { MessageBox( 0, AIL_last_error( ), "Error opening Miles", MB_OK | MB_ICONSTOP ); return( 2 ); } // // // Tell Bink to use the Miles Sound System (must be before BinkOpen)! // BinkSoundUseMiles( digital ); // // Try to open the Bink file. // #ifdef BINK51 { // // Tell Bink to play all of the 5.1 tracks // S32 volumes[ 6 ]; U32 TrackIDsToPlay[ 4 ] = { 0, 1, 2, 3 }; BinkSetSoundTrack( 4, TrackIDsToPlay ); // // Try to open the Bink file. // Bink = BinkOpen( cmd_line, BINKSNDTRACK ); // // Now route the sound tracks to the correct speaker // volumes[ 0 ] = 32768; volumes[ 1 ] = 32768; volumes[ 2 ] = 0; volumes[ 3 ] = 0; volumes[ 4 ] = 0; volumes[ 5 ] = 0; BinkSetMixBinVolumes( Bink, 0, 0, volumes, 6 ); volumes[ 0 ] = 0; volumes[ 1 ] = 0; volumes[ 2 ] = 32768; BinkSetMixBinVolumes( Bink, 1, 0, volumes, 6 ); volumes[ 2 ] = 0; volumes[ 3 ] = 32768; BinkSetMixBinVolumes( Bink, 2, 0, volumes, 6 ); volumes[ 3 ] = 0; volumes[ 4 ] = 32768; volumes[ 5 ] = 32768; BinkSetMixBinVolumes( Bink, 3, 0, volumes, 6 ); } #else Bink = BinkOpen( cmd_line, 0 ); #endif if ( !Bink ) { MessageBox( 0, BinkGetError( ), "Bink Error", MB_OK | MB_ICONSTOP ); DestroyWindow( window ); return( 3 ); } // // Try to open the Bink buffer. // Bink_buffer = BinkBufferOpen( window, Bink->Width, Bink->Height, 0 ); if ( !Bink_buffer ) { MessageBox( 0, BinkBufferGetError( ), "Bink Error", MB_OK | MB_ICONSTOP ); DestroyWindow( window ); BinkClose( Bink ); return( 4 ); } // // Size the window such that its client area exactly fits our Bink movie. // SetWindowPos( window, 0, 0, 0, Bink_buffer->WindowWidth, Bink_buffer->WindowHeight, SWP_NOMOVE ); // // Now display the window and start the message loop. // ShowWindow( window, cmd_show ); for ( ; ; ) { // // Are there any messages to handle? // if ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) { // // Yup, handle them. // if ( msg.message == WM_QUIT ) break; TranslateMessage( &msg ); DispatchMessage( &msg ); } else { // // Is it time for a new Bink frame? // if ( !BinkWait( Bink ) ) { // // Yup, draw the next frame. // Show_next_frame( Bink, Bink_buffer, window ); } else { // // Nope, give the rest of the system a chance to run (1 ms). // Sleep( 1 ); } } } // // Close the Bink file. // if ( Bink ) { BinkClose( Bink ); Bink = 0; } // // Close the Bink buffer. // if ( Bink_buffer ) { BinkBufferClose( Bink_buffer ); Bink_buffer = 0; } // // Close Miles. // if ( digital ) { AIL_close_digital_driver( digital ); digital = 0; } AIL_shutdown( ); // // And exit. // return( 0 ); }
int PASCAL WinMain( HINSTANCE instance, HINSTANCE previous_instance, LPSTR cmd_line, int cmd_show ) { // // Win32 locals. // HWND window = 0; MSG msg; // // Miles locals // HDIGDRIVER digital=0; // // Try to create our window. // window = Build_window_handle( instance, previous_instance ); if ( !window ) { MessageBox( 0, "Error creating window.", "Windows", MB_OK | MB_ICONSTOP ); return( 1 ); } // // Open the Miles Sound System. AIL_startup(); digital = AIL_open_digital_driver( 44100, 16, 2, 0 ); if ( !digital ) { MessageBox( 0, AIL_last_error( ), "Error opening Miles", MB_OK | MB_ICONSTOP ); return( 2 ); } // // // Tell Bink to use the Miles Sound System (must be before BinkOpen)! // BinkSoundUseMiles( digital ); // // Try to open the Bink file. // Bink = BinkOpen( cmd_line, 0 ); if ( !Bink ) { MessageBox( 0, BinkGetError( ), "Bink Error", MB_OK | MB_ICONSTOP ); DestroyWindow( window ); return( 3 ); } // // Try to open the Bink buffer. // Bink_buffer = BinkBufferOpen( window, Bink->Width, Bink->Height, 0 ); if ( !Bink_buffer ) { MessageBox( 0, BinkBufferGetError( ), "Bink Error", MB_OK | MB_ICONSTOP ); DestroyWindow( window ); BinkClose( Bink ); return( 4 ); } // // Size the window such that its client area exactly fits our Bink movie. // SetWindowPos( window, 0, 0, 0, Bink_buffer->WindowWidth, Bink_buffer->WindowHeight, SWP_NOMOVE ); // // Now display the window and start the message loop. // ShowWindow( window, cmd_show ); for ( ; ; ) { // // Are there any messages to handle? // if ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) { // // Yup, handle them. // if ( msg.message == WM_QUIT ) break; TranslateMessage( &msg ); DispatchMessage( &msg ); } else { // // Is it time for a new Bink frame? // if ( !BinkWait( Bink ) ) { // // Yup, draw the next frame. // Show_next_frame( Bink, Bink_buffer, window ); } else { // // Nope, give the rest of the system a chance to run (500 MICROseconds). // Good_sleep_us( 500 ); } } } // // Close the Bink file. // if ( Bink ) { BinkClose( Bink ); Bink = 0; } // // Close the Bink buffer. // if ( Bink_buffer ) { BinkBufferClose( Bink_buffer ); Bink_buffer = 0; } // // Close Miles. // if ( digital ) { AIL_close_digital_driver( digital ); digital = 0; } AIL_shutdown( ); // // And exit. // return( 0 ); }