comparison VideoPlayer.cpp @ 180:d8aa322a19e5

VideoSound(work)
author Ritor1
date Wed, 19 Dec 2012 18:04:28 +0600
parents ccc0cf95706a
children 80201f210d42 705a6c270835
comparison
equal deleted inserted replaced
179:dd1e818a6b4c 180:d8aa322a19e5
326 pRenderer->Present(); 326 pRenderer->Present();
327 if (!bNoSound && pAudioPlayer->hAILRedbook ) 327 if (!bNoSound && pAudioPlayer->hAILRedbook )
328 { 328 {
329 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0)); 329 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
330 AIL_redbook_stop(pAudioPlayer->hAILRedbook); 330 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
331 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xEu, &uTrackStartMS, &uTrackEndMS); 331 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xE, &uTrackStartMS, &uTrackEndMS);
332 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); 332 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS);
333 } 333 }
334 bGameoverLoop = 0; 334 bGameoverLoop = 0;
335 } 335 }
336 336
337 337
338 338
339 339
340 //----- (004BE70E) -------------------------------------------------------- 340 //----- (004BE70E) --------------------------------------------------------
341 void __fastcall VideoPlayer::MovieLoop(const char *pMovieName, int a2, int a3, int a4) 341 void __fastcall VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4)
342 { 342 {
343 int v4; // ebp@1 343 int v4; // ebp@1
344 const char *v5; // edi@1 344 const char *pName; // edi@1
345 MSG Msg; // [sp+Ch] [bp-1Ch]@12 345 MSG Msg; // [sp+Ch] [bp-1Ch]@12
346 346
347 v4 = a2; 347 v4 = a2;
348 v5 = pMovieName; 348 pName = pMovieName;
349 if ( !(dword_6BE364_game_settings_1 & 0x44) ) 349 if ( !(dword_6BE364_game_settings_1 & 0x44) )
350 { 350 {
351 if ( a2 == 2 ) 351 if ( a2 == 2 )
352 v4 = 0; 352 v4 = 0;
353 ShowCursor(0); 353 ShowCursor(0);
354 pVideoPlayer->OpenMovie(v5, 0, a3); 354 pVideoPlayer->OpenMovie(pName, 0, ScreenSizeFlag);
355 pVideoPlayer->bPlayingMovie = 1; 355 pVideoPlayer->bPlayingMovie = 1;
356 pVideoPlayer->field_44 = v4; 356 pVideoPlayer->field_44 = v4;
357 if ( pRenderer->pRenderD3D ) 357 if ( pRenderer->pRenderD3D )
358 { 358 {
359 pRenderer->ClearTarget(0); 359 pRenderer->ClearTarget(0);
367 pCurrentScreen = 16; 367 pCurrentScreen = 16;
368 if ( pVideoPlayer->uMovieFormat == 2 ) 368 if ( pVideoPlayer->uMovieFormat == 2 )
369 { 369 {
370 if ( pVideoPlayer->pBinkMovie ) 370 if ( pVideoPlayer->pBinkMovie )
371 { 371 {
372 pVideoPlayer->BinkDrawFrame(pVideoPlayer->hWindow, v4, a3); 372 pVideoPlayer->BinkDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
373 while ( pVideoPlayer->pBinkMovie ) 373 while ( pVideoPlayer->pBinkMovie )
374 { 374 {
375 if ( pVideoPlayer->bStopBeforeSchedule ) 375 if ( pVideoPlayer->bStopBeforeSchedule )
376 break; 376 break;
377 while ( PeekMessageA(&Msg, 0, 0, 0, 1u) ) 377 while ( PeekMessageA(&Msg, 0, 0, 0, 1) )
378 { 378 {
379 if ( Msg.message == 18 ) 379 if ( Msg.message == 18 )
380 Game_DeinitializeAndTerminate(0); 380 Game_DeinitializeAndTerminate(0);
381 if ( Msg.message == 15 ) 381 if ( Msg.message == 15 )
382 break; 382 break;
385 } 385 }
386 GUI_MainMenuMessageProc(); 386 GUI_MainMenuMessageProc();
387 if ( !pVideoPlayer->pBinkMovie ) 387 if ( !pVideoPlayer->pBinkMovie )
388 break; 388 break;
389 if ( !BinkWait(pVideoPlayer->pBinkMovie) && !pVideoPlayer->bStopBeforeSchedule ) 389 if ( !BinkWait(pVideoPlayer->pBinkMovie) && !pVideoPlayer->bStopBeforeSchedule )
390 pVideoPlayer->BinkDrawFrame(pVideoPlayer->hWindow, v4, a3); 390 pVideoPlayer->BinkDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
391 } 391 }
392 } 392 }
393 if ( pVideoPlayer->bStopBeforeSchedule == 1 ) 393 if ( pVideoPlayer->bStopBeforeSchedule == 1 )
394 Sleep(0x3E8u); 394 Sleep(0x3E8u);
395 } 395 }
397 { 397 {
398 if ( pVideoPlayer->uMovieFormat == 1 ) 398 if ( pVideoPlayer->uMovieFormat == 1 )
399 { 399 {
400 if ( pVideoPlayer->pSmackerMovie ) 400 if ( pVideoPlayer->pSmackerMovie )
401 { 401 {
402 pVideoPlayer->SmackDrawFrame(pVideoPlayer->hWindow, v4, a3); 402 pVideoPlayer->SmackDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
403 while ( pVideoPlayer->pSmackerMovie ) 403 while ( pVideoPlayer->pSmackerMovie )
404 { 404 {
405 if ( pVideoPlayer->bStopBeforeSchedule ) 405 if ( pVideoPlayer->bStopBeforeSchedule )
406 break; 406 break;
407 while ( PeekMessageW(&Msg, 0, 0, 0, 1u) ) 407 while ( PeekMessageW(&Msg, 0, 0, 0, 1) )
408 { 408 {
409 if (Msg.message == WM_QUIT) 409 if (Msg.message == WM_QUIT)
410 Game_DeinitializeAndTerminate(0); 410 Game_DeinitializeAndTerminate(0);
411 if (Msg.message == WM_PAINT) 411 if (Msg.message == WM_PAINT)
412 break; 412 break;
415 } 415 }
416 GUI_MainMenuMessageProc(); 416 GUI_MainMenuMessageProc();
417 if ( !pVideoPlayer->pSmackerMovie ) 417 if ( !pVideoPlayer->pSmackerMovie )
418 break; 418 break;
419 if ( !SmackWait(pVideoPlayer->pSmackerMovie) && !pVideoPlayer->bStopBeforeSchedule ) 419 if ( !SmackWait(pVideoPlayer->pSmackerMovie) && !pVideoPlayer->bStopBeforeSchedule )
420 pVideoPlayer->SmackDrawFrame(pVideoPlayer->hWindow, v4, a3); 420 pVideoPlayer->SmackDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
421 } 421 }
422 } 422 }
423 } 423 }
424 } 424 }
425 if ( a4 == 1 ) 425 if ( a4 == 1 )
560 560
561 561
562 //----- (004BEBD7) -------------------------------------------------------- 562 //----- (004BEBD7) --------------------------------------------------------
563 void VideoPlayer::Unload() 563 void VideoPlayer::Unload()
564 { 564 {
565 VideoPlayer *v1; // esi@1 565 VideoPlayer *pVideoPlayer; // esi@1
566 _BINK *v2; // eax@1 566 _BINK *pBinkMovie; // eax@1
567 _BINKBUF *v3; // eax@3 567 _BINKBUF *pBinkBuffer; // eax@3
568 _SMACK *v4; // eax@5 568 _SMACK *pSmackerMovie; // eax@5
569 569
570 v1 = this; 570 pVideoPlayer = this;
571 v2 = this->pBinkMovie; 571 pBinkMovie = this->pBinkMovie;
572 if ( v2 ) 572 if ( pBinkMovie )
573 { 573 {
574 BinkPause(v2, 1); 574 BinkPause(pBinkMovie, 1);
575 Sleep(300u); 575 Sleep(300);
576 BinkClose(v1->pBinkMovie); 576 BinkClose(pVideoPlayer->pBinkMovie);
577 v1->pBinkMovie = 0; 577 pVideoPlayer->pBinkMovie = 0;
578 } 578 }
579 v3 = v1->pBinkBuffer; 579 pBinkBuffer = pVideoPlayer->pBinkBuffer;
580 if ( v3 ) 580 if ( pBinkBuffer )
581 { 581 {
582 v3->pTargetDDrawSurface->Release(); 582 pBinkBuffer->pTargetDDrawSurface->Release();
583 v1->pBinkBuffer->pTargetDDrawSurface = 0; 583 pVideoPlayer->pBinkBuffer->pTargetDDrawSurface = 0;
584 free(v1->pBinkBuffer); 584 free(pVideoPlayer->pBinkBuffer);
585 v1->pBinkBuffer = 0; 585 pVideoPlayer->pBinkBuffer = 0;
586 } 586 }
587 v4 = v1->pSmackerMovie; 587 pSmackerMovie = pVideoPlayer->pSmackerMovie;
588 if ( v4 ) 588 if ( pSmackerMovie )
589 { 589 {
590 SmackSoundOnOff(v4, 0); 590 SmackSoundOnOff(pSmackerMovie, 0);
591 SmackClose(v1->pSmackerMovie); 591 SmackClose(pVideoPlayer->pSmackerMovie);
592 v1->pSmackerMovie = 0; 592 pVideoPlayer->pSmackerMovie = 0;
593 } 593 }
594 if ( v1->pSmackerBuffer ) 594 if ( pVideoPlayer->pSmackerBuffer )
595 { 595 {
596 SmackBufferClose(v1->pSmackerBuffer); 596 SmackBufferClose(pVideoPlayer->pSmackerBuffer);
597 v1->pSmackerBuffer = 0; 597 pVideoPlayer->pSmackerBuffer = 0;
598 } 598 }
599 if ( v1->pSmackMovieBlit ) 599 if ( pVideoPlayer->pSmackMovieBlit )
600 { 600 {
601 SmackBlitClose(v1->pSmackMovieBlit); 601 SmackBlitClose(pVideoPlayer->pSmackMovieBlit);
602 v1->pSmackMovieBlit = 0; 602 pVideoPlayer->pSmackMovieBlit = 0;
603 } 603 }
604 v1->field_54 = 0; 604 pVideoPlayer->field_54 = 0;
605 v1->uMovieFormat = 0; 605 pVideoPlayer->uMovieFormat = 0;
606 v1->dword_0000A0 = 0; 606 pVideoPlayer->dword_0000A0 = 0;
607 memset(v1->pCurrentMovieName, 0, 0x40u); 607 memset(pVideoPlayer->pCurrentMovieName, 0, 0x40);
608 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop ) 608 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop )
609 AIL_redbook_resume(pAudioPlayer->hAILRedbook); 609 AIL_redbook_resume(pAudioPlayer->hAILRedbook);
610 pEventTimer->Resume(); 610 pEventTimer->Resume();
611 } 611 }
612 612
939 } 939 }
940 940
941 //----- (004BF1E6) -------------------------------------------------------- 941 //----- (004BF1E6) --------------------------------------------------------
942 _SMACK *VideoPlayer::OpenSmack(const char *pFilename) 942 _SMACK *VideoPlayer::OpenSmack(const char *pFilename)
943 { 943 {
944 VideoPlayer *v2; // esi@1 944 VideoPlayer *pVideoPlayer; // esi@1
945 signed int v3; // edi@1 945 signed int v3; // edi@1
946 int v4; // ebx@2 946 int v4; // ebx@2
947 signed int v5; // edi@5 947 signed int v5; // edi@5
948 int v6; // ebx@6 948 int v6; // ebx@6
949 HANDLE v8; // [sp-Ch] [bp-1Ch]@10 949 HANDLE v8; // [sp-Ch] [bp-1Ch]@10
950 unsigned int v9; // [sp-8h] [bp-18h]@10 950 unsigned int v9; // [sp-8h] [bp-18h]@10
951 signed int v10; // [sp-4h] [bp-14h]@10 951 signed int v10; // [sp-4h] [bp-14h]@10
952 952
953 v2 = this; 953 pVideoPlayer = this;
954 v3 = 0; 954 v3 = 0;
955 if ( (signed int)this->uNumMightVideoHeaders > 0 ) 955 if ( (signed int)this->uNumMightVideoHeaders > 0 )
956 { 956 {
957 v4 = 0; 957 v4 = 0;
958 while ( _strcmpi(v2->pMightVideoHeaders[v4].pVideoName, pFilename) ) 958 while ( _strcmpi(pVideoPlayer->pMightVideoHeaders[v4].pVideoName, pFilename) )
959 { 959 {
960 ++v3; 960 ++v3;
961 ++v4; 961 ++v4;
962 if ( v3 >= (signed int)v2->uNumMightVideoHeaders ) 962 if ( v3 >= (signed int)pVideoPlayer->uNumMightVideoHeaders )
963 goto LABEL_5; 963 goto LABEL_5;
964 } 964 }
965 SetFilePointer(v2->hMightVid, v2->pMightVideoHeaders[v3].uFileOffset, 0, 0); 965 SetFilePointer(pVideoPlayer->hMightVid, pVideoPlayer->pMightVideoHeaders[v3].uFileOffset, 0, 0);
966 return SmackOpen(pVideoPlayer->hMightVid, 0x7140, -1);
967 }
968 LABEL_5:
969 v5 = 0;
970 if ( (signed int)pVideoPlayer->uNumMagicVideoHeaders > 0 )
971 {
972 v6 = 0;
973 while ( _strcmpi(pVideoPlayer->pMagicVideoHeaders[v6].pVideoName, pFilename) )
974 {
975 ++v5;
976 ++v6;
977 if ( v5 >= (signed int)pVideoPlayer->uNumMagicVideoHeaders )
978 return 0;
979 }
980 SetFilePointer(pVideoPlayer->hMagicVid, pVideoPlayer->pMagicVideoHeaders[v5].uFileOffset, 0, 0);
966 v10 = -1; 981 v10 = -1;
967 v9 = 0x7140u; 982 v9 = 0x7140u;
968 v8 = v2->hMightVid; 983 v8 = pVideoPlayer->hMagicVid;
969 return SmackOpen(v8, v9, v10);
970 }
971 LABEL_5:
972 v5 = 0;
973 if ( (signed int)v2->uNumMagicVideoHeaders > 0 )
974 {
975 v6 = 0;
976 while ( _strcmpi(v2->pMagicVideoHeaders[v6].pVideoName, pFilename) )
977 {
978 ++v5;
979 ++v6;
980 if ( v5 >= (signed int)v2->uNumMagicVideoHeaders )
981 return 0;
982 }
983 SetFilePointer(v2->hMagicVid, v2->pMagicVideoHeaders[v5].uFileOffset, 0, 0);
984 v10 = -1;
985 v9 = 0x7140u;
986 v8 = v2->hMagicVid;
987 return SmackOpen(v8, v9, v10); 984 return SmackOpen(v8, v9, v10);
988 } 985 }
989 return 0; 986 return 0;
990 } 987 }
991 988
1066 } 1063 }
1067 1064
1068 //----- (004BF411) -------------------------------------------------------- 1065 //----- (004BF411) --------------------------------------------------------
1069 void VideoPlayer::OpenMovie(const char *pFilename, unsigned int bLoop, int a4) 1066 void VideoPlayer::OpenMovie(const char *pFilename, unsigned int bLoop, int a4)
1070 { 1067 {
1071 VideoPlayer *v4; // esi@1 1068 VideoPlayer *pVideoPlayer; // esi@1
1072 _BINK *v5; // eax@2 1069 _BINK *pVideoOpen; // eax@2
1073 _SMACK *v6; // eax@3 1070 _SMACK *v6; // eax@3
1074 _BINK *pBinkMovie; // eax@5 1071 _BINK *pBinkMovie; // eax@5
1075 _SMACK *v8; // eax@7 1072 _SMACK *v8; // eax@7
1076 char *v9; // eax@7 1073 char *v9; // eax@7
1077 unsigned int v10; // eax@11 1074 unsigned int v10; // eax@11
1078 _SMACKBLIT *v11; // eax@14 1075 _SMACKBLIT *v11; // eax@14
1079 const char *v12; // [sp-4h] [bp-38h]@8 1076 const char *v12; // [sp-4h] [bp-38h]@8
1080 char pVideoName[120]; // [sp+Ch] [bp-28h]@2 1077 char pVideoName[120]; // [sp+Ch] [bp-28h]@2
1081 1078
1082 v4 = this; 1079 pVideoPlayer = this;
1083 if ( !this->field_54 ) 1080 if ( !this->field_54 )
1084 { 1081 {
1085 Prepare(); 1082 Prepare();
1086 v4->bLoopPlaying = bLoop; 1083 pVideoPlayer->bLoopPlaying = bLoop;
1087 sprintf(pVideoName, "%s.bik", pFilename); 1084 sprintf(pVideoName, "%s.bik", pFilename);
1088 v5 = OpenBink(pVideoName); 1085 pVideoOpen = OpenBink(pVideoName);
1089 v4->pBinkMovie = v5; 1086 pVideoPlayer->pBinkMovie = pVideoOpen;
1090 if ( v5 ) 1087 if ( pVideoOpen )
1091 { 1088 {
1092 v4->uMovieFormat = 2; 1089 pVideoPlayer->uMovieFormat = 2;
1093 strcpy(v4->pCurrentMovieName, pFilename); 1090 strcpy(pVideoPlayer->pCurrentMovieName, pFilename);
1094 pBinkMovie = v4->pBinkMovie; 1091 pBinkMovie = pVideoPlayer->pBinkMovie;
1095 v4->dword_0000A0 = 1; 1092 pVideoPlayer->dword_0000A0 = 1;
1096 if ( pBinkMovie ) 1093 if ( pBinkMovie )
1097 v4->pBinkBuffer = CreateBinkBuffer(v4->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0); 1094 pVideoPlayer->pBinkBuffer = CreateBinkBuffer(pVideoPlayer->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0);
1098 } 1095 }
1099 else 1096 else
1100 { 1097 {
1101 Unload(); 1098 Unload();
1102 sprintf(pVideoName, "%s.smk", pFilename); 1099 sprintf(pVideoName, "%s.smk", pFilename);
1103 v6 = OpenSmack(pVideoName); 1100 v6 = OpenSmack(pVideoName);
1104 v4->pSmackerMovie = v6; 1101 pVideoPlayer->pSmackerMovie = v6;
1105 if ( !v6 ) 1102 if ( !v6 )
1106 { 1103 {
1107 Unload(); 1104 Unload();
1108 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename); 1105 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename);
1109 LABEL_17: 1106 //LABEL_17:
1110 MessageBoxA(0, pVideoName, "Smacker Error", 0); 1107 MessageBoxA(0, pVideoName, "Smacker Error", 0);
1111 return; 1108 return;
1112 } 1109 }
1113 v4->uMovieFormat = 1; 1110 pVideoPlayer->uMovieFormat = 1;
1114 strcpy(v4->pCurrentMovieName, pFilename); 1111 strcpy(pVideoPlayer->pCurrentMovieName, pFilename);
1115 v8 = v4->pSmackerMovie; 1112 v8 = pVideoPlayer->pSmackerMovie;
1116 v4->dword_0000A0 = 2; 1113 pVideoPlayer->dword_0000A0 = 2;
1117 v9 = (char *)malloc(v8->Width * v8->Height); 1114 v9 = (char *)malloc(v8->Width * v8->Height);
1118 v4->pSomeSmackerBuffer = v9; 1115 pVideoPlayer->pSomeSmackerBuffer = v9;
1119 if ( !v9 ) 1116 if ( !v9 )
1120 { 1117 {
1121 Unload(); 1118 Unload();
1122 v12 = "Can't allocate memory for buffer"; 1119 v12 = "Can't allocate memory for buffer";
1123 LABEL_16: 1120 //LABEL_16:
1124 sprintf(pVideoName, v12); 1121 sprintf(pVideoName, v12);
1125 goto LABEL_17; 1122 //goto LABEL_17;
1126 } 1123 MessageBoxA(0, pVideoName, "Smacker Error", 0);
1127 SmackToBuffer(v4->pSmackerMovie, 0, 0, v4->pSmackerMovie->Width, v4->pSmackerMovie->Height, v9, 0); 1124 return;
1125 }
1126 SmackToBuffer(pVideoPlayer->pSmackerMovie, 0, 0, pVideoPlayer->pSmackerMovie->Width, pVideoPlayer->pSmackerMovie->Height, v9, 0);
1128 if ( a4 ) 1127 if ( a4 )
1129 { 1128 {
1130 if ( (unsigned int)uCPUSpeed < 165 ) 1129 if ( (unsigned int)uCPUSpeed < 165 )
1131 { 1130 {
1132 v10 = SmackCheckSurfaceFromat() | 2; 1131 v10 = SmackCheckSurfaceFromat() | 2;
1140 else 1139 else
1141 { 1140 {
1142 v10 = SmackCheckSurfaceFromat(); 1141 v10 = SmackCheckSurfaceFromat();
1143 } 1142 }
1144 v11 = SmackBlitOpen(v10); 1143 v11 = SmackBlitOpen(v10);
1145 v4->pSmackMovieBlit = v11; 1144 pVideoPlayer->pSmackMovieBlit = v11;
1146 if ( !v11 ) 1145 if ( !v11 )
1147 { 1146 {
1148 Unload(); 1147 Unload();
1149 v12 = "Failed to open Blit API"; 1148 v12 = "Failed to open Blit API";
1150 goto LABEL_16; 1149 //goto LABEL_16;
1150 sprintf(pVideoName, v12);
1151 MessageBoxA(0, pVideoName, "Smacker Error", 0);
1152 return;
1151 } 1153 }
1152 } 1154 }
1153 } 1155 }
1154 } 1156 }
1155 1157