Mercurial > mm7
comparison VideoPlayer.cpp @ 1445:6de9c1316852
Слияние
author | Ritor1 |
---|---|
date | Sat, 03 Aug 2013 00:00:31 +0600 |
parents | c7489dd19f88 |
children | 934074e7fcc1 |
comparison
equal
deleted
inserted
replaced
1444:7b1a94270756 | 1445:6de9c1316852 |
---|---|
898 return nullptr; | 898 return nullptr; |
899 } | 899 } |
900 //----- (004BF1E6) -------------------------------------------------------- | 900 //----- (004BF1E6) -------------------------------------------------------- |
901 _SMACK *VideoPlayer::OpenSmack(const char *pFilename) | 901 _SMACK *VideoPlayer::OpenSmack(const char *pFilename) |
902 { | 902 { |
903 VideoPlayer *pVideoPlayer; // esi@1 | 903 if ( this->uNumMightVideoHeaders ) |
904 signed int v3; // edi@1 | 904 { |
905 int v4; // ebx@2 | 905 for ( uint i = 0; i < (signed int)this->uNumMightVideoHeaders; ++i) |
906 signed int v5; // edi@5 | 906 { |
907 //int v6; // ebx@6 | 907 if ( !_stricmp(this->pMightVideoHeaders[i].pVideoName, pFilename) ) |
908 //HANDLE v8; // [sp-Ch] [bp-1Ch]@10 | 908 { |
909 //unsigned int v9; // [sp-8h] [bp-18h]@10 | 909 SetFilePointer(this->hMightVid, this->pMightVideoHeaders[i].uFileOffset, 0, 0); |
910 //signed int v10; // [sp-4h] [bp-14h]@10 | 910 return SmackOpen(this->hMightVid, 0x7140, -1); |
911 | 911 } |
912 pVideoPlayer = this; | 912 } |
913 if ( (signed int)this->uNumMightVideoHeaders > 0 ) | 913 } |
914 { | 914 if ( this->uNumMagicVideoHeaders ) |
915 for ( v3 = 0; v3 < (signed int)pVideoPlayer->uNumMightVideoHeaders; ++v3) | 915 { |
916 { | 916 for ( uint i = 0; i < (signed int)this->uNumMagicVideoHeaders; ++i ) |
917 v4 = _stricmp(pVideoPlayer->pMightVideoHeaders[v3].pVideoName, pFilename); | 917 { |
918 if ( !v4 ) | 918 if ( !_stricmp(this->pMagicVideoHeaders[i].pVideoName, pFilename) ) |
919 { | 919 { |
920 SetFilePointer(pVideoPlayer->hMightVid, pVideoPlayer->pMightVideoHeaders[v3].uFileOffset, 0, 0); | 920 SetFilePointer(this->hMagicVid, this->pMagicVideoHeaders[i].uFileOffset, 0, 0); |
921 return SmackOpen(pVideoPlayer->hMightVid, 0x7140, -1);//problem training house video in WinXP | 921 return SmackOpen(this->hMagicVid, 0x7140, -1); |
922 } | 922 } |
923 } | 923 } |
924 } | |
925 v5 = 0; | |
926 if ( (signed int)pVideoPlayer->uNumMagicVideoHeaders > 0 ) | |
927 { | |
928 while ( _stricmp(pVideoPlayer->pMagicVideoHeaders[v5].pVideoName, pFilename) ) | |
929 { | |
930 ++v5; | |
931 if ( v5 >= (signed int)pVideoPlayer->uNumMagicVideoHeaders ) | |
932 return 0; | |
933 } | |
934 SetFilePointer(pVideoPlayer->hMagicVid, pVideoPlayer->pMagicVideoHeaders[v5].uFileOffset, 0, 0); | |
935 return SmackOpen(pVideoPlayer->hMagicVid, 0x7140, -1); | |
936 } | 924 } |
937 return 0; | 925 return 0; |
938 } | 926 } |
939 | 927 |
940 //----- (004BF28F) -------------------------------------------------------- | 928 //----- (004BF28F) -------------------------------------------------------- |
941 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) | 929 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) |
942 { | 930 { |
943 VideoPlayer *v3; // esi@1 | |
944 std::string *v4; // ecx@3 | |
945 _SMACK *v5; // eax@4 | |
946 _SMACK *v6; // eax@7 | |
947 int v7; // eax@7 | |
948 int v8; // ecx@7 | |
949 unsigned int v9; // ebx@8 | |
950 unsigned int v10; // eax@8 | |
951 signed __int64 v11; // qax@9 | |
952 char *v12; // [sp-20h] [bp-54h]@3 | |
953 int v13; // [sp-1Ch] [bp-50h]@3 | |
954 std::string v14; // [sp-18h] [bp-4Ch]@3 | |
955 const char *v15; // [sp-8h] [bp-3Ch]@3 | |
956 int v16; // [sp-4h] [bp-38h]@3 | |
957 char Str2[0x30]; // [sp+Ch] [bp-28h]@4 | |
958 std::string *v18; // [sp+3Ch] [bp+8h]@3 | |
959 std::string *v19; // [sp+3Ch] [bp+8h]@5 | |
960 unsigned __int16 *v20; // [sp+3Ch] [bp+8h]@8 | |
961 | |
962 v3 = this; | |
963 if ( !this->field_54 ) | 931 if ( !this->field_54 ) |
964 { | 932 { |
965 Prepare(); | 933 Prepare(); |
966 v3->bLoopPlaying = a3_1; | 934 this->bLoopPlaying = a3_1; |
967 if ( LOBYTE(v3->field_104) == 1 ) | 935 if ( LOBYTE(this->field_104) == 1 ) |
968 { | 936 { |
969 v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925"; | 937 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); |
970 v12 = "Unsupported Bink playback!"; | |
971 MessageBoxA(nullptr, v12, v15, 0); | |
972 return; | 938 return; |
973 } | 939 } |
974 sprintfex(Str2, "%s.smk", pMovieName); | 940 sprintfex(Str2, "%s.smk", pMovieName); |
975 v5 = OpenSmack(Str2); | 941 this->pSmackerMovie = OpenSmack(Str2); |
976 v3->pSmackerMovie = v5; | 942 if ( !this->pSmackerMovie ) |
977 if ( !v5 ) | 943 { |
978 { | 944 this->Unload(); |
979 v3->Unload(); | |
980 sprintf(pTmpBuf.data(), "Can't load %s", &Str2); | 945 sprintf(pTmpBuf.data(), "Can't load %s", &Str2); |
981 v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937"; | 946 MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937", 0); |
982 MessageBoxA(nullptr, pTmpBuf.data(), v15, 0); | |
983 return; | 947 return; |
984 } | 948 } |
985 v16 = (int)pMovieName; | 949 this->uMovieFormat = 1; |
986 v3->uMovieFormat = 1; | 950 strcpy(this->pCurrentMovieName, (const char *)pMovieName); |
987 strcpy(v3->pCurrentMovieName, (const char *)v16); | 951 this->dword_0000A0 = 1; |
988 v6 = v3->pSmackerMovie; | 952 this->pSmackerBuffer = (_SMACKBUF *)SmackBufferOpen(this->hWindow, 4, LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height), LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height)); |
989 v3->dword_0000A0 = 1; | 953 if ( this->pSmackerBuffer ) |
990 v7 = SmackBufferOpen(v3->hWindow, 4, LOWORD(v6->Width), LOWORD(v6->Height), LOWORD(v6->Width), LOWORD(v6->Height)); | |
991 v3->pSmackerBuffer = (_SMACKBUF *)v7; | |
992 if ( v7 ) | |
993 { | 954 { |
994 pRenderer->BeginScene(); | 955 pRenderer->BeginScene(); |
995 v9 = pRenderer->uTargetSurfacePitch; | 956 SmackToBuffer(this->pSmackerMovie, 8, 8, 2 * pRenderer->uTargetSurfacePitch, pRenderer->field_14, pRenderer->pTargetSurface, SmackCheckSurfaceFromat()); |
996 v20 = pRenderer->pTargetSurface; | |
997 v10 = SmackCheckSurfaceFromat(); | |
998 SmackToBuffer(v3->pSmackerMovie, 8, 8, 2 * v9, pRenderer->field_14, v20, v10); | |
999 pRenderer->EndScene(); | 957 pRenderer->EndScene(); |
1000 } | 958 } |
1001 v16 = 32767; | 959 SmackVolumePan(this->pSmackerMovie, 1040384, (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0), 32767); |
1002 v11 = (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0); | |
1003 SmackVolumePan(v3->pSmackerMovie, 1040384, v11, 32767); | |
1004 } | 960 } |
1005 } | 961 } |
1006 | 962 |
1007 //----- (004BF3F9) -------------------------------------------------------- | 963 //----- (004BF3F9) -------------------------------------------------------- |
1008 bool VideoPlayer::AnyMovieLoaded() | 964 bool VideoPlayer::AnyMovieLoaded() |
1011 } | 967 } |
1012 | 968 |
1013 //----- (004BF411) -------------------------------------------------------- | 969 //----- (004BF411) -------------------------------------------------------- |
1014 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) | 970 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) |
1015 { | 971 { |
1016 VideoPlayer *pVideoPlayer; // esi@1 | |
1017 _BINK *pVideoOpen; // eax@2 | |
1018 _SMACK *v6; // eax@3 | |
1019 _BINK *pBinkMovie; // eax@5 | |
1020 _SMACK *v8; // eax@7 | |
1021 char *v9; // eax@7 | |
1022 unsigned int v10; // eax@11 | 972 unsigned int v10; // eax@11 |
1023 _SMACKBLIT *v11; // eax@14 | |
1024 const char *v12; // [sp-4h] [bp-38h]@8 | |
1025 char pVideoName[120]; // [sp+Ch] [bp-28h]@2 | 973 char pVideoName[120]; // [sp+Ch] [bp-28h]@2 |
1026 | 974 |
1027 pVideoPlayer = this; | |
1028 if ( !this->field_54 ) | 975 if ( !this->field_54 ) |
1029 { | 976 { |
1030 Prepare(); | 977 Prepare(); |
1031 pVideoPlayer->bLoopPlaying = bLoop; | 978 this->bLoopPlaying = bLoop; |
1032 sprintf(pVideoName, "%s.bik", pFilename); | 979 sprintf(pVideoName, "%s.bik", pFilename); |
1033 pVideoOpen = OpenBink(pVideoName); | 980 this->pBinkMovie = OpenBink(pVideoName); |
1034 pVideoPlayer->pBinkMovie = pVideoOpen; | 981 if ( this->pBinkMovie ) |
1035 if ( pVideoOpen ) | 982 { |
1036 { | 983 this->uMovieFormat = 2; |
1037 pVideoPlayer->uMovieFormat = 2; | 984 strcpy(this->pCurrentMovieName, pFilename); |
1038 strcpy(pVideoPlayer->pCurrentMovieName, pFilename); | 985 pBinkMovie = this->pBinkMovie; |
1039 pBinkMovie = pVideoPlayer->pBinkMovie; | 986 this->dword_0000A0 = 1; |
1040 pVideoPlayer->dword_0000A0 = 1; | |
1041 if ( pBinkMovie ) | 987 if ( pBinkMovie ) |
1042 pVideoPlayer->pBinkBuffer = CreateBinkBuffer(pVideoPlayer->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0); | 988 this->pBinkBuffer = CreateBinkBuffer(this->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0); |
1043 } | 989 } |
1044 else | 990 else |
1045 { | 991 { |
1046 Unload(); | 992 Unload(); |
1047 sprintfex(pVideoName, "%s.smk", pFilename); | 993 sprintfex(pVideoName, "%s.smk", pFilename); |
1048 v6 = OpenSmack(pVideoName); | 994 this->pSmackerMovie = OpenSmack(pVideoName); |
1049 pVideoPlayer->pSmackerMovie = v6; | 995 if ( !this->pSmackerMovie ) |
1050 if ( !v6 ) | |
1051 { | 996 { |
1052 Unload(); | 997 Unload(); |
1053 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename); | 998 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename); |
1054 MessageBoxA(0, pVideoName, "Smacker Error", 0); | 999 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1055 return; | 1000 return; |
1056 } | 1001 } |
1057 pVideoPlayer->uMovieFormat = 1; | 1002 this->uMovieFormat = 1; |
1058 strcpy(pVideoPlayer->pCurrentMovieName, pFilename); | 1003 strcpy(this->pCurrentMovieName, pFilename); |
1059 v8 = pVideoPlayer->pSmackerMovie; | 1004 this->dword_0000A0 = 2; |
1060 pVideoPlayer->dword_0000A0 = 2; | 1005 this->pSomeSmackerBuffer = (char *)malloc(this->pSmackerMovie->Width * this->pSmackerMovie->Height); |
1061 v9 = (char *)malloc(v8->Width * v8->Height); | 1006 if ( !this->pSomeSmackerBuffer ) |
1062 pVideoPlayer->pSomeSmackerBuffer = v9; | |
1063 if ( !v9 ) | |
1064 { | 1007 { |
1065 Unload(); | 1008 Unload(); |
1066 v12 = "Can't allocate memory for buffer"; | 1009 sprintf(pVideoName, "Can't allocate memory for buffer"); |
1067 sprintf(pVideoName, v12); | 1010 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1068 MessageBoxA(0, pVideoName, "Smacker Error", 0); | |
1069 return; | 1011 return; |
1070 } | 1012 } |
1071 SmackToBuffer(pVideoPlayer->pSmackerMovie, 0, 0, pVideoPlayer->pSmackerMovie->Width, pVideoPlayer->pSmackerMovie->Height, v9, 0); | 1013 SmackToBuffer(this->pSmackerMovie, 0, 0, this->pSmackerMovie->Width, this->pSmackerMovie->Height, this->pSomeSmackerBuffer, 0); |
1072 | 1014 |
1073 v10 = SmackCheckSurfaceFromat(); | 1015 v10 = SmackCheckSurfaceFromat(); |
1074 if ( a4 ) | 1016 if ( a4 ) |
1075 { | 1017 { |
1076 v10 |= SMACKBLIT2X; | 1018 v10 |= SMACKBLIT2X; |
1079 v10 |= SMACKBLIT2XSMOOTHING; | 1021 v10 |= SMACKBLIT2XSMOOTHING; |
1080 else | 1022 else |
1081 Log::Warning(L"Smacker seems to use lower resolution because it thinks CPU is slow"); | 1023 Log::Warning(L"Smacker seems to use lower resolution because it thinks CPU is slow"); |
1082 } | 1024 } |
1083 | 1025 |
1084 v11 = SmackBlitOpen(v10); | 1026 this->pSmackMovieBlit = SmackBlitOpen(v10); |
1085 pVideoPlayer->pSmackMovieBlit = v11; | 1027 if ( !this->pSmackMovieBlit ) |
1086 if ( !v11 ) | |
1087 { | 1028 { |
1088 Unload(); | 1029 Unload(); |
1089 v12 = "Failed to open Blit API"; | 1030 sprintf(pVideoName, "Failed to open Blit API"); |
1090 sprintf(pVideoName, v12); | |
1091 MessageBoxA(0, pVideoName, "Smacker Error", 0); | 1031 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1092 return; | 1032 return; |
1093 } | 1033 } |
1094 } | 1034 } |
1095 } | 1035 } |
1097 | 1037 |
1098 | 1038 |
1099 //----- (004BF5B2) -------------------------------------------------------- | 1039 //----- (004BF5B2) -------------------------------------------------------- |
1100 void VideoPlayer::_4BF5B2() | 1040 void VideoPlayer::_4BF5B2() |
1101 { | 1041 { |
1102 VideoPlayer *v1; // esi@1 | 1042 if ( this->uMovieFormat == 2 ) |
1103 unsigned int v2; // eax@1 | 1043 { |
1104 _BINK **v3; // edi@2 | |
1105 | |
1106 v1 = this; | |
1107 v2 = this->uMovieFormat; | |
1108 if ( v2 == 2 ) | |
1109 { | |
1110 v3 = &this->pBinkMovie; | |
1111 BinkGoto(pBinkMovie, 1, 0); | 1044 BinkGoto(pBinkMovie, 1, 0); |
1112 BinkDoFrame(pBinkMovie); | 1045 BinkDoFrame(pBinkMovie); |
1113 BinkNextFrame(pBinkMovie); | 1046 BinkNextFrame(pBinkMovie); |
1114 } | 1047 } |
1115 else | 1048 else |
1116 { | 1049 { |
1117 if ( v2 != 1 ) | 1050 if ( this->uMovieFormat != 1 ) |
1118 return; | 1051 return; |
1119 SmackGoto(pSmackerMovie, 1); | 1052 SmackGoto(pSmackerMovie, 1); |
1120 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 1053 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
1121 { | 1054 { |
1122 SmackDoFrame(pSmackerMovie); | 1055 SmackDoFrame(pSmackerMovie); |
1123 SmackNextFrame(pSmackerMovie); | 1056 SmackNextFrame(pSmackerMovie); |
1124 } | 1057 } |
1125 } | 1058 } |
1126 pMouse->_469E24(); | 1059 pMouse->_469E24(); |
1127 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !v1->pSmackerMovie ) | 1060 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pSmackerMovie ) |
1128 { | 1061 { |
1129 bGameoverLoop = 1; | 1062 bGameoverLoop = 1; |
1130 sub_4BD8B5(); | 1063 sub_4BD8B5(); |
1131 window_SpeakInHouse->Release(); | 1064 window_SpeakInHouse->Release(); |
1132 pParty->uFlags &= 0xFFFFFFFDu; | 1065 pParty->uFlags &= 0xFFFFFFFDu; |
1144 } | 1077 } |
1145 | 1078 |
1146 //----- (004BF73A) -------------------------------------------------------- | 1079 //----- (004BF73A) -------------------------------------------------------- |
1147 void VideoPlayer::SelectMovieType() | 1080 void VideoPlayer::SelectMovieType() |
1148 { | 1081 { |
1149 VideoPlayer *v1; // esi@1 | |
1150 int v2; // edi@1 | |
1151 unsigned __int8 v3; // bl@1 | |
1152 int v4; // edi@1 | |
1153 char Source[32]; // [sp+Ch] [bp-40h]@1 | 1082 char Source[32]; // [sp+Ch] [bp-40h]@1 |
1154 | 1083 |
1155 v1 = this; | |
1156 v2 = this->dword_0000A0; | |
1157 v3 = LOBYTE(this->bLoopPlaying); | |
1158 strcpy(Source, this->pCurrentMovieName); | 1084 strcpy(Source, this->pCurrentMovieName); |
1159 Unload(); | 1085 Unload(); |
1160 v4 = v2 - 1; | 1086 if ( this->dword_0000A0 == 1 ) |
1161 if ( v4 ) | 1087 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); |
1162 { | 1088 else if ( this->dword_0000A0 == 2 ) |
1163 if ( v4 == 1 ) | 1089 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); |
1164 OpenGlobalMovie(Source, v3, 1); | |
1165 } | |
1166 else | 1090 else |
1167 { | 1091 __debugbreak(); |
1168 OpenHouseMovie(Source, v3); | |
1169 } | |
1170 } | 1092 } |
1171 | 1093 |
1172 //----- (004BF8F6) -------------------------------------------------------- | 1094 //----- (004BF8F6) -------------------------------------------------------- |
1173 void VideoPlayer::PlayDeathMovie() | 1095 void VideoPlayer::PlayDeathMovie() |
1174 { | 1096 { |