annotate VideoPlayer.cpp @ 2352:8a49cf25fb88

Moving zlib wrappers to separate headers
author Grumpy7
date Wed, 09 Apr 2014 21:51:06 +0200
parents d57505d3c70c
children 08c4f1799ca1
rev   line source
2253
aff7a7b072b7 adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents: 2223
diff changeset
1 #define _CRT_SECURE_NO_WARNINGS
0
Ritor1
parents:
diff changeset
2
2336
d6887ee81068 header file include cleanup
Grumpy7
parents: 2334
diff changeset
3 #include "mm7_unsorted_subs.h"
0
Ritor1
parents:
diff changeset
4 #include "Bink_Smacker.h"
Ritor1
parents:
diff changeset
5
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
6 #include "mm7_data.h"
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 898
diff changeset
7 #include "CShow.h"
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 898
diff changeset
8 #include "Mouse.h"
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 898
diff changeset
9
0
Ritor1
parents:
diff changeset
10 #include "VideoPlayer.h"
2345
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
11 #include "MediaPlayer.h"
0
Ritor1
parents:
diff changeset
12 #include "AudioPlayer.h"
Ritor1
parents:
diff changeset
13 #include "Game.h"
Ritor1
parents:
diff changeset
14 #include "Render.h"
Ritor1
parents:
diff changeset
15 #include "Party.h"
Ritor1
parents:
diff changeset
16 #include "GUIWindow.h"
2044
28cb79ae2f6f Time.h rename
Ritor1
parents: 1980
diff changeset
17 #include "Timer.h"
0
Ritor1
parents:
diff changeset
18 #include "Log.h"
1253
fac7751b2dc9 included header cleanup
Grumpy7
parents: 1217
diff changeset
19 #include "texts.h"
1299
8c2f689b5f0b folder UI
Ritor1
parents: 1262
diff changeset
20 #include "UI\UIHouses.h"
0
Ritor1
parents:
diff changeset
21
Ritor1
parents:
diff changeset
22 VideoPlayer *pVideoPlayer = nullptr;
Ritor1
parents:
diff changeset
23
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
24 #pragma comment(lib, "Version.lib")
0
Ritor1
parents:
diff changeset
25 bool GetDllVersion(const wchar_t *pDllName, uint *pMajor, uint *pMinor)
Ritor1
parents:
diff changeset
26 {
Ritor1
parents:
diff changeset
27 uint uVersionSize = GetFileVersionInfoSizeW(pDllName, nullptr);
Ritor1
parents:
diff changeset
28 void *pVersionData = HeapAlloc(GetProcessHeap(), 0, uVersionSize);
Ritor1
parents:
diff changeset
29 {
Ritor1
parents:
diff changeset
30 GetFileVersionInfoW(pDllName, 0, uVersionSize, pVersionData);
Ritor1
parents:
diff changeset
31
Ritor1
parents:
diff changeset
32 VS_FIXEDFILEINFO *pInfo = nullptr;
Ritor1
parents:
diff changeset
33 UINT uInfoSize = 0;
Ritor1
parents:
diff changeset
34 VerQueryValueW(pVersionData, L"\\", (void **)&pInfo, &uInfoSize);
Ritor1
parents:
diff changeset
35
Ritor1
parents:
diff changeset
36 if (!pMajor || !pMinor)
Ritor1
parents:
diff changeset
37 {
Ritor1
parents:
diff changeset
38 HeapFree(GetProcessHeap(), 0, pVersionData);
Ritor1
parents:
diff changeset
39 return false;
Ritor1
parents:
diff changeset
40 }
Ritor1
parents:
diff changeset
41 *pMajor = pInfo->dwFileVersionMS;
Ritor1
parents:
diff changeset
42 *pMinor = pInfo->dwFileVersionLS;
Ritor1
parents:
diff changeset
43 }
Ritor1
parents:
diff changeset
44 HeapFree(GetProcessHeap(), 0, pVersionData);
Ritor1
parents:
diff changeset
45 return true;
Ritor1
parents:
diff changeset
46 }
Ritor1
parents:
diff changeset
47
Ritor1
parents:
diff changeset
48 unsigned __int64 uBinkVersion;
Ritor1
parents:
diff changeset
49
Ritor1
parents:
diff changeset
50 //----- (004BF794) --------------------------------------------------------
2290
d65414f65bd4 add MMT.cpp and MMT.h
Ritor1
parents: 2279
diff changeset
51 void ShowMM7IntroVideo_and_LoadingScreen()
0
Ritor1
parents:
diff changeset
52 {
Ritor1
parents:
diff changeset
53 RGBTexture tex; // [sp+Ch] [bp-30h]@1
2290
d65414f65bd4 add MMT.cpp and MMT.h
Ritor1
parents: 2279
diff changeset
54 unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8
d65414f65bd4 add MMT.cpp and MMT.h
Ritor1
parents: 2279
diff changeset
55 unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8
0
Ritor1
parents:
diff changeset
56
Ritor1
parents:
diff changeset
57 pVideoPlayer->bStopBeforeSchedule = false;
165
Ritor1
parents: 151
diff changeset
58 pVideoPlayer->pResetflag = 0;
2290
d65414f65bd4 add MMT.cpp and MMT.h
Ritor1
parents: 2279
diff changeset
59 bGameoverLoop = true;
256
c5e5c5146957 -novideo command arg
Nomad
parents: 227
diff changeset
60 if (!bNoVideo)
0
Ritor1
parents:
diff changeset
61 {
Ritor1
parents:
diff changeset
62 pRenderer->PresentBlackScreen();
Ritor1
parents:
diff changeset
63 if ( !pVideoPlayer->bStopBeforeSchedule )
2290
d65414f65bd4 add MMT.cpp and MMT.h
Ritor1
parents: 2279
diff changeset
64 PlayFullscreenMovie(MOVIE_Intro, true);
0
Ritor1
parents:
diff changeset
65 }
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2290
diff changeset
66 // char pContainerName[64];
2278
0cd17b0d36c2 MMT_MainMenu
Ritor1
parents: 2253
diff changeset
67
2290
d65414f65bd4 add MMT.cpp and MMT.h
Ritor1
parents: 2279
diff changeset
68 tex.Load("mm6title.pcx", 2);
0
Ritor1
parents:
diff changeset
69 pRenderer->BeginScene();
Ritor1
parents:
diff changeset
70 pRenderer->DrawTextureRGB(0, 0, &tex);
Ritor1
parents:
diff changeset
71 free(tex.pPixels);
Ritor1
parents:
diff changeset
72 tex.pPixels = 0;
762
cf2fbac6edc9 Misc cleaning
Nomad
parents: 731
diff changeset
73
2290
d65414f65bd4 add MMT.cpp and MMT.h
Ritor1
parents: 2279
diff changeset
74 //LoadFonts_and_DrawCopyrightWindow();
d65414f65bd4 add MMT.cpp and MMT.h
Ritor1
parents: 2279
diff changeset
75 DrawMM7CopyrightWindow();
762
cf2fbac6edc9 Misc cleaning
Nomad
parents: 731
diff changeset
76
0
Ritor1
parents:
diff changeset
77 pRenderer->EndScene();
Ritor1
parents:
diff changeset
78 pRenderer->Present();
1004
eac5af72b614 UI cleans
Nomad
parents: 898
diff changeset
79
eac5af72b614 UI cleans
Nomad
parents: 898
diff changeset
80 #ifndef _DEBUG
eac5af72b614 UI cleans
Nomad
parents: 898
diff changeset
81 Sleep(1500); // let the copyright window stay for a while
eac5af72b614 UI cleans
Nomad
parents: 898
diff changeset
82 #endif
eac5af72b614 UI cleans
Nomad
parents: 898
diff changeset
83
2290
d65414f65bd4 add MMT.cpp and MMT.h
Ritor1
parents: 2279
diff changeset
84 if (!bNoSound && pAudioPlayer->hAILRedbook )
0
Ritor1
parents:
diff changeset
85 {
Ritor1
parents:
diff changeset
86 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
Ritor1
parents:
diff changeset
87 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
88 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS);
0
Ritor1
parents:
diff changeset
89 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS);
2290
d65414f65bd4 add MMT.cpp and MMT.h
Ritor1
parents: 2279
diff changeset
90 }
d65414f65bd4 add MMT.cpp and MMT.h
Ritor1
parents: 2279
diff changeset
91 bGameoverLoop = false;
0
Ritor1
parents:
diff changeset
92 }
Ritor1
parents:
diff changeset
93
Ritor1
parents:
diff changeset
94 //----- (004BE70E) --------------------------------------------------------
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
95 void VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4)
0
Ritor1
parents:
diff changeset
96 {
Ritor1
parents:
diff changeset
97 int v4; // ebp@1
Ritor1
parents:
diff changeset
98 MSG Msg; // [sp+Ch] [bp-1Ch]@12
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
99
0
Ritor1
parents:
diff changeset
100 v4 = a2;
2061
b2a434d65344 GAME_SETTINGS_* defines introduced
Nomad
parents: 2044
diff changeset
101 if ( !(dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO)) )
0
Ritor1
parents:
diff changeset
102 {
Ritor1
parents:
diff changeset
103 if ( a2 == 2 )
Ritor1
parents:
diff changeset
104 v4 = 0;
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
105 ShowCursor(0);//Убрать курсор
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
106 OpenGlobalMovie(pMovieName, 0, ScreenSizeFlag);
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
107 bPlayingMovie = 1;
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
108 field_44 = v4;
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
109 pRenderer->ClearTarget(0);
151
9abdd40a107b pCurrentScreen
Ritor1
parents: 4
diff changeset
110 pCurrentScreen = SCREEN_VIDEO;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
111
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
112 auto hwnd = pVideoPlayer->window->GetApiHandle();
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
113 RECT rc_client;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
114 GetClientRect(hwnd, &rc_client);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
115 int client_width = rc_client.right - rc_client.left,
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
116 client_height = rc_client.bottom - rc_client.top;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
117
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
118 HDC dc = GetDC(hwnd);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
119 HDC back_dc = CreateCompatibleDC(dc);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
120 HBITMAP back_bmp;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
121 SelectObject(back_dc, back_bmp = CreateCompatibleBitmap(dc, client_width, client_height));
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
122
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
123 DWORD t = GetTickCount();//текущее время от запуска ОС
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
124
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
125 end_current_file = false;//установить флаг конца видеоролика
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
126
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
127 while (true) //Цикл воспроизведения видеоролика
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
128 {
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
129 if ( pVideoPlayer->bStopBeforeSchedule )
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
130 break;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
131 while (PeekMessageA(&Msg, hwnd, 0, 0, PM_REMOVE))
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
132 {
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
133 if (Msg.message == 18)
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
134 Game_DeinitializeAndTerminate(0);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
135 if (Msg.message == 15)
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
136 break;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
137 TranslateMessage(&Msg);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
138 DispatchMessageA(&Msg);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
139 }
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
140
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
141 double dt = (GetTickCount() - t) / 1000.0; //изменение времени
2345
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
142 //dt = 1.0/15.0;
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
143 t = GetTickCount();
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
144
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
145 //log("dt=%.5f\n", dt);
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
146
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
147 auto image = new char[client_width * client_height * 4];
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
148
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
149 pMovie->GetNextFrame(dt, image); //получить следующий кадр
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
150
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
151 if (end_current_file)//достигнут ли конец видео?
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
152 break;
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
153
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
154 if (image)
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
155 {
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
156 // draw to hwnd
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
157 BITMAPINFO bmi;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
158 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
159 bmi.bmiHeader.biWidth = client_width;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
160 bmi.bmiHeader.biHeight = -client_height;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
161 bmi.bmiHeader.biPlanes = 1;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
162 bmi.bmiHeader.biBitCount = 32;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
163 bmi.bmiHeader.biCompression = BI_RGB;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
164 bmi.bmiHeader.biSizeImage = 0;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
165 bmi.bmiHeader.biXPelsPerMeter = 0;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
166 bmi.bmiHeader.biYPelsPerMeter = 0;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
167 bmi.bmiHeader.biClrUsed = 0;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
168 bmi.bmiHeader.biClrImportant = 0;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
169 GetDIBits(back_dc, back_bmp, 0, client_height, 0, &bmi, DIB_RGB_COLORS);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
170 SetDIBits(back_dc, back_bmp, 0, client_height, image, &bmi, DIB_RGB_COLORS);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
171 BitBlt(dc, 0, 0, client_width, client_height, back_dc, 0, 0, SRCCOPY);
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
172
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
173 delete[] image;//удалить кадр
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
174 }
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
175
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
176 GUI_MainMenuMessageProc(); //после отрисовки, т.к. иначе вылетает dt = 0.03, image - ???
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
177
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
178 if (pVideoPlayer->bStopBeforeSchedule == 1)//остановка видео
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
179 Sleep(1000); //пауза после видеоролика
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
180 }
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
181
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
182 pVideoPlayer->Unload();
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
183
227
bcd55744c2f4 Clicking background in MainMenu fix
Nomad
parents: 165
diff changeset
184 if (a4 == 1)
151
9abdd40a107b pCurrentScreen
Ritor1
parents: 4
diff changeset
185 pCurrentScreen = SCREEN_GAME;
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
186
0
Ritor1
parents:
diff changeset
187 pVideoPlayer->bPlayingMovie = 0;
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
188
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
189 ShowCursor(1);//вернуть курсор
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
190
151
9abdd40a107b pCurrentScreen
Ritor1
parents: 4
diff changeset
191 if ( pCurrentScreen == SCREEN_VIDEO )
9abdd40a107b pCurrentScreen
Ritor1
parents: 4
diff changeset
192 pCurrentScreen = SCREEN_GAME;
0
Ritor1
parents:
diff changeset
193 }
Ritor1
parents:
diff changeset
194 }
Ritor1
parents:
diff changeset
195
Ritor1
parents:
diff changeset
196 //----- (004BE9D8) --------------------------------------------------------
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
197 void VideoPlayer::Initialize(OSWindow *target_window)
0
Ritor1
parents:
diff changeset
198 {
Ritor1
parents:
diff changeset
199 DWORD NumberOfBytesRead; // [sp+10h] [bp-4h]@9
Ritor1
parents:
diff changeset
200
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
201 window = target_window;
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
202
0
Ritor1
parents:
diff changeset
203 uint uBinkVersionMajor = -1,
Ritor1
parents:
diff changeset
204 uBinkVersionMinor = -1;
Ritor1
parents:
diff changeset
205 GetDllVersion(L"BINKW32.DLL", &uBinkVersionMajor, &uBinkVersionMinor);
Ritor1
parents:
diff changeset
206 uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor;
Ritor1
parents:
diff changeset
207
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1165
diff changeset
208 strcpy(pTmpBuf.data(), "anims\\might7.vid");
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
209 hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0);
0
Ritor1
parents:
diff changeset
210 if ( hMightVid == INVALID_HANDLE_VALUE )
Ritor1
parents:
diff changeset
211 {
1217
b237a61e61d3 sprintf didn't use .data member of new arrays
Grumpy7
parents: 1205
diff changeset
212 sprintf(pTmpBuf2.data(), "Can't open file - anims\\%s.smk", pTmpBuf.data());
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1165
diff changeset
213 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0);
0
Ritor1
parents:
diff changeset
214 return;
Ritor1
parents:
diff changeset
215 }
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1165
diff changeset
216 strcpy(pTmpBuf.data(), "anims\\magic7.vid");
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
217 hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0);
0
Ritor1
parents:
diff changeset
218 if ( hMagicVid == INVALID_HANDLE_VALUE )
Ritor1
parents:
diff changeset
219 {
Ritor1
parents:
diff changeset
220 if ( !bCanLoadFromCD )
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
221 {
1217
b237a61e61d3 sprintf didn't use .data member of new arrays
Grumpy7
parents: 1205
diff changeset
222 sprintf(pTmpBuf2.data(), "Can't open file - anims\\%s.smk", pTmpBuf.data());
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1165
diff changeset
223 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0);
0
Ritor1
parents:
diff changeset
224 return;
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
225 }
1217
b237a61e61d3 sprintf didn't use .data member of new arrays
Grumpy7
parents: 1205
diff changeset
226 sprintf(pTmpBuf2.data(), "%c:\\%s", (unsigned __int8)cMM7GameCDDriveLetter, pTmpBuf.data());
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
227 hMagicVid = CreateFileA(pTmpBuf2.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0);
0
Ritor1
parents:
diff changeset
228 if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE )
Ritor1
parents:
diff changeset
229 {
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
230 sprintf(pTmpBuf2.data(), "Can't open file - %s", pTmpBuf.data());
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1165
diff changeset
231 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0);
0
Ritor1
parents:
diff changeset
232 return;
Ritor1
parents:
diff changeset
233 }
Ritor1
parents:
diff changeset
234 }
Ritor1
parents:
diff changeset
235 ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0);
Ritor1
parents:
diff changeset
236 ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0);
Ritor1
parents:
diff changeset
237 pMagicVideoHeaders = 0;
Ritor1
parents:
diff changeset
238 pMightVideoHeaders = 0;
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1459
diff changeset
239 pMightVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMightVideoHeaders + 2);
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1459
diff changeset
240 pMagicVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMagicVideoHeaders + 2);
0
Ritor1
parents:
diff changeset
241 ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0);
Ritor1
parents:
diff changeset
242 ReadFile(hMagicVid, pMagicVideoHeaders, 44 * uNumMagicVideoHeaders, &NumberOfBytesRead, 0);
Ritor1
parents:
diff changeset
243 }
Ritor1
parents:
diff changeset
244
Ritor1
parents:
diff changeset
245 //----- (004BEBD7) --------------------------------------------------------
Ritor1
parents:
diff changeset
246 void VideoPlayer::Unload()
Ritor1
parents:
diff changeset
247 {
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
248 //_BINK *pBinkMovie; // eax@1
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
249 //_BINKBUF *pBinkBuffer; // eax@3
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
250 //_SMACK *pSmackerMovie; // eax@5
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
251 /*
0
Ritor1
parents:
diff changeset
252 if ( pBinkMovie )
Ritor1
parents:
diff changeset
253 {
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
254 //BinkPause(pBinkMovie, 1);
0
Ritor1
parents:
diff changeset
255 Sleep(300);
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
256 //BinkClose(pBinkMovie);
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
257 pBinkMovie = 0;
0
Ritor1
parents:
diff changeset
258 }
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
259
0
Ritor1
parents:
diff changeset
260 if ( pBinkBuffer )
Ritor1
parents:
diff changeset
261 {
Ritor1
parents:
diff changeset
262 pBinkBuffer->pTargetDDrawSurface->Release();
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
263 pBinkBuffer->pTargetDDrawSurface = 0;
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
264 free(pBinkBuffer);
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
265 pBinkBuffer = 0;
0
Ritor1
parents:
diff changeset
266 }
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
267
0
Ritor1
parents:
diff changeset
268 if ( pSmackerMovie )
Ritor1
parents:
diff changeset
269 {
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
270 //SmackSoundOnOff(pSmackerMovie, 0);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
271 //SmackClose(pSmackerMovie);
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
272 pSmackerMovie = 0;
0
Ritor1
parents:
diff changeset
273 }
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
274 if ( pSmackerBuffer )
0
Ritor1
parents:
diff changeset
275 {
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
276 SmackBufferClose(pSmackerBuffer);
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
277 pSmackerBuffer = 0;
0
Ritor1
parents:
diff changeset
278 }
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
279 */
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
280 if ( pSmackMovieBlit )
0
Ritor1
parents:
diff changeset
281 {
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
282 SmackBlitClose(pSmackMovieBlit);
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
283 pSmackMovieBlit = 0;
0
Ritor1
parents:
diff changeset
284 }
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
285 bBufferLoaded = 0;
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
286 uMovieFormat = 0;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
287 uMovieFormatSwapped = 0;
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
288 memset(pCurrentMovieName, 0, 0x40);
0
Ritor1
parents:
diff changeset
289 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop )
Ritor1
parents:
diff changeset
290 AIL_redbook_resume(pAudioPlayer->hAILRedbook);
Ritor1
parents:
diff changeset
291 pEventTimer->Resume();
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
292
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
293 if (pMovie)
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
294 {
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
295 delete pMovie;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
296 pMovie = nullptr;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
297 }
0
Ritor1
parents:
diff changeset
298 }
Ritor1
parents:
diff changeset
299
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
300 void VideoPlayer::_inlined_in_463149()
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
301 {
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
302 if (pMovie)
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
303 {
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
304 pRenderer->BeginScene();
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
305 pMouse->DrawCursorToTarget();
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
306 UpdatePalette();
2216
3f375342de12 window->GetWidth() continue
Ritor1
parents: 2215
diff changeset
307 pMouse->ReadCursorWithItem();
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
308 pRenderer->EndScene();
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
309 }
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1583
diff changeset
310 }
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
311
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
312 void VideoPlayer::UpdatePalette()
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
313 {
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
314 Log::Warning(L"smacker");
2345
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
315 loop_current_file = true;
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
316 pRenderer->BeginScene();
2345
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
317 /*if (pMovie->Stopped())//видео завершено/перезагрузка
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
318 {
2222
66bd74aa9f5e smk video draw
Ritor1
parents: 2221
diff changeset
319 int width = game_viewport_width;
66bd74aa9f5e smk video draw
Ritor1
parents: 2221
diff changeset
320 int height = game_viewport_height;
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
321 delete pMovie;
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
322
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
323 SetFilePointer(hVidFile, uOffset, nullptr, FILE_BEGIN);
0
Ritor1
parents:
diff changeset
324
2345
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
325 //pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, width, height);
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
326 }
2345
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
327 else */
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
328 {
2345
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
329 double dt = (GetTickCount() - time_video_begin) / 1000.0;
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
330 //dt = 1.0/15.0;
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
331 time_video_begin = GetTickCount();
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
332
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
333 //log("dt=%.5f\n", dt);
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
334
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
335 auto image = new char[current_movie_width * current_movie_height * 4];
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
336
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
337 pMovie->GetNextFrame(dt, image);
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
338 Sleep(70); //Ritor1:it's my include
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
339
2222
66bd74aa9f5e smk video draw
Ritor1
parents: 2221
diff changeset
340 int image_array[460 * 344];//game_viewport_width * game_viewport_height
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
341 if (image)
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
342 {
2222
66bd74aa9f5e smk video draw
Ritor1
parents: 2221
diff changeset
343 memcpy(image_array, image, sizeof (image_array));
2223
17bc3a1eb037 LoadCursor fix
Ritor1
parents: 2222
diff changeset
344 for (unsigned int y = 8; y < 8 + game_viewport_height; ++y)//координаты местоположения видеоролика
2221
c69013c186c7 for video
Ritor1
parents: 2218
diff changeset
345 {
c69013c186c7 for video
Ritor1
parents: 2218
diff changeset
346 for (unsigned int x = 8; x < 8 + game_viewport_width; ++x)
c69013c186c7 for video
Ritor1
parents: 2218
diff changeset
347 {
2222
66bd74aa9f5e smk video draw
Ritor1
parents: 2221
diff changeset
348 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + x + y * pRenderer->uTargetSurfacePitch;
66bd74aa9f5e smk video draw
Ritor1
parents: 2221
diff changeset
349 *p = image_array[((x - 8) + ((y - 8)*game_viewport_width))];
2221
c69013c186c7 for video
Ritor1
parents: 2218
diff changeset
350 }
c69013c186c7 for video
Ritor1
parents: 2218
diff changeset
351 }
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
352 delete[] image;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
353 }
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
354 }
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
355 pRenderer->EndScene();
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
356 }
0
Ritor1
parents:
diff changeset
357
Ritor1
parents:
diff changeset
358 //----- (004BF28F) --------------------------------------------------------
898
10fa7dad1391 DrawPaperdoll clean
Ritor1
parents: 832
diff changeset
359 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1)
0
Ritor1
parents:
diff changeset
360 {
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
361 if (!this->bBufferLoaded)
0
Ritor1
parents:
diff changeset
362 {
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
363 //Prepare();
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
364 pEventTimer->Pause();
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
365 if (pAudioPlayer->hAILRedbook)
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
366 AIL_redbook_pause(pAudioPlayer->hAILRedbook);
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
367
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
368 bStopBeforeSchedule = false;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
369 bBufferLoaded = 1;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
370 bPlayingMovie = false;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
371 bFirstFrame = false;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
372 bUsingSmackerMMX = SmackUseMMX(1);
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
373
1429
c7489dd19f88 BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents: 1397
diff changeset
374 this->bLoopPlaying = a3_1;
c7489dd19f88 BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents: 1397
diff changeset
375 if ( LOBYTE(this->field_104) == 1 )
0
Ritor1
parents:
diff changeset
376 {
1429
c7489dd19f88 BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents: 1397
diff changeset
377 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0);
0
Ritor1
parents:
diff changeset
378 return;
Ritor1
parents:
diff changeset
379 }
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
380
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
381 LoadMovie(pMovieName);
2345
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
382 time_video_begin = GetTickCount();
0
Ritor1
parents:
diff changeset
383 }
Ritor1
parents:
diff changeset
384 }
Ritor1
parents:
diff changeset
385
Ritor1
parents:
diff changeset
386 //----- (004BF3F9) --------------------------------------------------------
Ritor1
parents:
diff changeset
387 bool VideoPlayer::AnyMovieLoaded()
Ritor1
parents:
diff changeset
388 {
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
389 return pMovie;// pSmackerMovie || pBinkMovie;
0
Ritor1
parents:
diff changeset
390 }
Ritor1
parents:
diff changeset
391
Ritor1
parents:
diff changeset
392 //----- (004BF411) --------------------------------------------------------
898
10fa7dad1391 DrawPaperdoll clean
Ritor1
parents: 832
diff changeset
393 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4)
0
Ritor1
parents:
diff changeset
394 {
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2290
diff changeset
395 // unsigned int v10; // eax@11
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
396
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
397 if (!this->bBufferLoaded)
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
398 {
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
399 pEventTimer->Pause();
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
400 if (pAudioPlayer->hAILRedbook)
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
401 AIL_redbook_pause(pAudioPlayer->hAILRedbook);
0
Ritor1
parents:
diff changeset
402
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
403 bStopBeforeSchedule = false;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
404 bBufferLoaded = 1;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
405 bPlayingMovie = false;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
406 bFirstFrame = false;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
407 bUsingSmackerMMX = SmackUseMMX(1);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
408 this->bLoopPlaying = bLoop;
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
409 LoadMovie(pFilename);
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
410 return;
0
Ritor1
parents:
diff changeset
411 }
Ritor1
parents:
diff changeset
412 }
Ritor1
parents:
diff changeset
413
2347
d57505d3c70c VideoPlayer cleaning
Ritor1
parents: 2345
diff changeset
414 //----- (004BF5B2) --------------------------------------------------------
0
Ritor1
parents:
diff changeset
415 void VideoPlayer::_4BF5B2()
Ritor1
parents:
diff changeset
416 {
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
417 //__debugbreak();
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
418
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
419 /*if ( this->uMovieFormat == 2 )
0
Ritor1
parents:
diff changeset
420 {
Ritor1
parents:
diff changeset
421 BinkGoto(pBinkMovie, 1, 0);
Ritor1
parents:
diff changeset
422 BinkDoFrame(pBinkMovie);
Ritor1
parents:
diff changeset
423 BinkNextFrame(pBinkMovie);
Ritor1
parents:
diff changeset
424 }
Ritor1
parents:
diff changeset
425 else
Ritor1
parents:
diff changeset
426 {
1429
c7489dd19f88 BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents: 1397
diff changeset
427 if ( this->uMovieFormat != 1 )
0
Ritor1
parents:
diff changeset
428 return;
Ritor1
parents:
diff changeset
429 SmackGoto(pSmackerMovie, 1);
Ritor1
parents:
diff changeset
430 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
Ritor1
parents:
diff changeset
431 {
Ritor1
parents:
diff changeset
432 SmackDoFrame(pSmackerMovie);
Ritor1
parents:
diff changeset
433 SmackNextFrame(pSmackerMovie);
Ritor1
parents:
diff changeset
434 }
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
435 }*/
0
Ritor1
parents:
diff changeset
436 pMouse->_469E24();
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
437 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pMovie)//!this->pSmackerMovie )
0
Ritor1
parents:
diff changeset
438 {
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
439 bGameoverLoop = true;
1919
140ca8123384 Tavern rest fix
Ritor1
parents: 1802
diff changeset
440 HouseDialogPressCloseBtn();
336
ea55d6414029 Event_proceccor preliminary
Gloval
parents: 323
diff changeset
441 window_SpeakInHouse->Release();
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
442 pParty->uFlags &= 0xFFFFFFFD;
481
5b6e2021c6fe HOUSE_ID
Ritor1
parents: 480
diff changeset
443 if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) )
0
Ritor1
parents:
diff changeset
444 {
388
d95a91011d57 AudioPlayer::PlaySound
Nomad
parents: 347
diff changeset
445 pAudioPlayer->PlaySound(SOUND_Invalid, 0, 0, -1, 0, 0, 0, 0);
2215
e9625ad08541 fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents: 2154
diff changeset
446 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0);
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
447 window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1, 0x31, "", 0);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
448 window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2, 0x32, "", 0);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
449 window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3, 0x33, "", 0);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
450 window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4, 0x34, "", 0);
0
Ritor1
parents:
diff changeset
451 }
Ritor1
parents:
diff changeset
452 bGameoverLoop = 0;
Ritor1
parents:
diff changeset
453 }
Ritor1
parents:
diff changeset
454 }
Ritor1
parents:
diff changeset
455
Ritor1
parents:
diff changeset
456 //----- (004BF73A) --------------------------------------------------------
898
10fa7dad1391 DrawPaperdoll clean
Ritor1
parents: 832
diff changeset
457 void VideoPlayer::SelectMovieType()
0
Ritor1
parents:
diff changeset
458 {
Ritor1
parents:
diff changeset
459 char Source[32]; // [sp+Ch] [bp-40h]@1
Ritor1
parents:
diff changeset
460
Ritor1
parents:
diff changeset
461 strcpy(Source, this->pCurrentMovieName);
Ritor1
parents:
diff changeset
462 Unload();
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
463 if ( this->uMovieFormatSwapped == 1 )
1429
c7489dd19f88 BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents: 1397
diff changeset
464 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying));
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
465 else if ( this->uMovieFormatSwapped == 2 )
1429
c7489dd19f88 BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents: 1397
diff changeset
466 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1);
0
Ritor1
parents:
diff changeset
467 else
1429
c7489dd19f88 BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents: 1397
diff changeset
468 __debugbreak();
0
Ritor1
parents:
diff changeset
469 }
Ritor1
parents:
diff changeset
470
Ritor1
parents:
diff changeset
471 //----- (004BF8F6) --------------------------------------------------------
Ritor1
parents:
diff changeset
472 void VideoPlayer::PlayDeathMovie()
Ritor1
parents:
diff changeset
473 {
Ritor1
parents:
diff changeset
474 bStopBeforeSchedule = 0;
165
Ritor1
parents: 151
diff changeset
475 pResetflag = 0;
1397
eb02a65e5c82 Quick Spell fixed.
Nomad
parents: 1299
diff changeset
476 PlayFullscreenMovie(MOVIE_Death, true);
eb02a65e5c82 Quick Spell fixed.
Nomad
parents: 1299
diff changeset
477 //pGame->pCShow->PlayMovie(MOVIE_Death, 1);
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
478 }
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
479
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
480 //----- (004BE6F5) --------------------------------------------------------
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
481 VideoPlayer::VideoPlayer() :
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
482 bBufferLoaded(0),
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
483 //pBinkMovie(nullptr), pBinkBuffer(nullptr),
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
484 //pSmackerMovie(nullptr), pSmackerBuffer(nullptr),
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
485 pSmackMovieBlit(nullptr)
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
486 {
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
487 //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame);
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
488 bStopBeforeSchedule = false;
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
489 pResetflag = 0;
2345
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
490 //pPlayer = new MultimediaPlayer();
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
491 //pPlayer->Initialize();
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
492 pPlayer = new Media::Player;//создаётся плеер
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
493 pMovie = nullptr;
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
494 //pBinkMovie = nullptr;
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
495 }
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 2132
diff changeset
496
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
497 int VideoPlayer::readFunction(void* opaque, uint8_t* buf, int buf_size)
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
498 {
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
499 HANDLE stream = (HANDLE)opaque;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
500 //int numBytes = stream->read((char*)buf, buf_size);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
501 int numBytes;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
502 ReadFile(stream, (char *)buf, buf_size, (LPDWORD)&numBytes, NULL);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
503 return numBytes;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
504 }
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
505
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
506 int64_t VideoPlayer::seekFunction(void* opaque, int64_t offset, int whence)
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
507 {
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
508 if (whence == AVSEEK_SIZE)
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
509 return pVideoPlayer->uSize;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
510 HANDLE h = (HANDLE)opaque;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
511 LARGE_INTEGER li;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
512 li.QuadPart = offset;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
513
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
514 if (!SetFilePointerEx(h, li, (PLARGE_INTEGER)&li, FILE_BEGIN))
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
515 return -1;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
516 return li.QuadPart;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
517 }
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
518
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
519 void VideoPlayer::LoadMovie(const char * pFilename)
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
520 {
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
521 char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
522 char pVideoNameSmk[120]; // [sp+Ch] [bp-28h]@2
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
523
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
524 sprintf(pVideoNameBik, "%s.bik", pFilename);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
525 sprintf(pVideoNameSmk, "%s.smk", pFilename);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
526 for (uint i = 0; i < uNumMightVideoHeaders; ++i)
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
527 {
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
528 //no BIK in MightVid
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
529 /*
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
530 if (!_stricmp(pVideoNameBik, pMightVideoHeaders[i].pVideoName))
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
531 {
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
532 hVidFile = hMightVid;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
533 uOffset = pMightVideoHeaders[i].uFileOffset;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
534 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
535 this->uMovieFormat = 2;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
536 this->uMovieFormatSwapped = 1;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
537 }
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
538 */
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
539 if (!_stricmp(pVideoNameSmk, pMightVideoHeaders[i].pVideoName))
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
540 {
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
541 hVidFile = hMightVid;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
542 uOffset = pMightVideoHeaders[i].uFileOffset;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
543 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
544 this->uMovieFormat = 1;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
545 this->uMovieFormatSwapped = 2;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
546 }
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
547 }
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
548 for (uint i = 0; i < uNumMagicVideoHeaders; ++i)
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
549 {
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
550 if (!_stricmp(pVideoNameBik, pMagicVideoHeaders[i].pVideoName))
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
551 {
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
552 hVidFile = hMagicVid;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
553 uOffset = pMagicVideoHeaders[i].uFileOffset;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
554 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
555 this->uMovieFormat = 2;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
556 this->uMovieFormatSwapped = 1;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
557 }
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
558 if (!_stricmp(pVideoNameSmk, pMagicVideoHeaders[i].pVideoName))
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
559 {
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
560 hVidFile = hMagicVid;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
561 uOffset = pMagicVideoHeaders[i].uFileOffset;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
562 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
563 this->uMovieFormat = 1;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
564 this->uMovieFormatSwapped = 2;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
565 }
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
566 }
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
567 if (!hVidFile)
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
568 {
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
569 Unload();
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
570 MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
571 return;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
572 }
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
573
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
574 SetFilePointer(hVidFile, uOffset, 0, FILE_BEGIN);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
575 strcpy(this->pCurrentMovieName, pFilename);
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
576
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
577 auto hwnd = pVideoPlayer->window->GetApiHandle();
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
578 RECT rc_client;
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
579 GetClientRect(hwnd, &rc_client);
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
580 int client_width = rc_client.right - rc_client.left,
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
581 client_height = rc_client.bottom - rc_client.top;
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
582
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
583
2218
e8f9a06c7bcb for video
Ritor1
parents: 2216
diff changeset
584 pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, client_width, client_height);
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
585
2345
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
586 }
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
587 void VideoPlayer::PlayAudio(const wchar_t * pFilename)
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
588 {
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
589 Media::ITrack *track = pPlayer->LoadTrack(pFilename);
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
590 track->Play();
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
591 }
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
592 void VideoPlayer::PlayMovie(const wchar_t * pFilename)
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
593 {
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
594 Media::IMovie *track = pPlayer->LoadMovie(pFilename, 640, 480, 0);
182effc4b0ee for MultimediaPlayer
Ritor1
parents: 2336
diff changeset
595 track->Play();
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
596 }