Mercurial > mm7
annotate VideoPlayer.cpp @ 2336:d6887ee81068
header file include cleanup
author | Grumpy7 |
---|---|
date | Wed, 02 Apr 2014 23:21:34 +0200 |
parents | ddb803517a48 |
children | 182effc4b0ee |
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 | 2 |
2336 | 3 #include "mm7_unsorted_subs.h" |
0 | 4 #include "Bink_Smacker.h" |
5 | |
1262 | 6 #include "mm7_data.h" |
1016 | 7 #include "CShow.h" |
8 #include "Mouse.h" | |
9 | |
0 | 10 #include "VideoPlayer.h" |
11 #include "AudioPlayer.h" | |
12 #include "Game.h" | |
13 #include "Render.h" | |
14 #include "Party.h" | |
15 #include "GUIWindow.h" | |
2044 | 16 #include "Timer.h" |
0 | 17 #include "Log.h" |
1253 | 18 #include "texts.h" |
1299 | 19 #include "UI\UIHouses.h" |
0 | 20 |
21 | |
22 VideoPlayer *pVideoPlayer = nullptr; | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 #pragma comment(lib, "Version.lib") | |
31 bool GetDllVersion(const wchar_t *pDllName, uint *pMajor, uint *pMinor) | |
32 { | |
33 uint uVersionSize = GetFileVersionInfoSizeW(pDllName, nullptr); | |
34 void *pVersionData = HeapAlloc(GetProcessHeap(), 0, uVersionSize); | |
35 { | |
36 GetFileVersionInfoW(pDllName, 0, uVersionSize, pVersionData); | |
37 | |
38 VS_FIXEDFILEINFO *pInfo = nullptr; | |
39 UINT uInfoSize = 0; | |
40 VerQueryValueW(pVersionData, L"\\", (void **)&pInfo, &uInfoSize); | |
41 | |
42 if (!pMajor || !pMinor) | |
43 { | |
44 HeapFree(GetProcessHeap(), 0, pVersionData); | |
45 return false; | |
46 } | |
47 *pMajor = pInfo->dwFileVersionMS; | |
48 *pMinor = pInfo->dwFileVersionLS; | |
49 } | |
50 HeapFree(GetProcessHeap(), 0, pVersionData); | |
51 return true; | |
52 } | |
53 | |
54 | |
55 // 3.15.1.0: | |
56 // 3 15 1 0 | |
57 // 0x0003000F00010000 | |
58 unsigned __int64 uBinkVersion; | |
59 | |
60 | |
61 | |
62 | |
63 | |
1459 | 64 bool BinkLockBuffer(struct _BINKBUF *_this); |
65 void BinkUnlockBuffer(struct _BINKBUF *_this); | |
0 | 66 |
67 //----- (004BFE2D) -------------------------------------------------------- | |
1802 | 68 _BINKBUF *VideoPlayer::CreateBinkBuffer(unsigned int uWidth, unsigned int uHeight, char a4) |
0 | 69 { |
70 _BINKBUF *v5; // esi@3 | |
2334 | 71 // HRESULT v6; // eax@5 |
0 | 72 IDirectDrawSurface *v7; // eax@6 |
2334 | 73 // HRESULT v8; // eax@9 |
0 | 74 DDSURFACEDESC2 v11; // [sp+Ch] [bp-108h]@7 |
2334 | 75 // DDSURFACEDESC Dst; // [sp+88h] [bp-8Ch]@3 |
0 | 76 IDirectDrawSurface4 *v15; // [sp+108h] [bp-Ch]@7 |
2334 | 77 // IDirectDrawSurface2 *a2; // [sp+10Ch] [bp-8h]@3 |
0 | 78 |
2152 | 79 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
80 //pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
0 | 81 { |
82 v15 = 0; | |
83 | |
84 if (uBinkVersion == 0x0001000500150000) | |
85 { | |
86 v5 = new _BINKBUF_1_5_21_0; | |
87 memset(v5, 0, sizeof(_BINKBUF_1_5_21_0)); | |
88 } | |
89 else if (uBinkVersion == 0x0003000000000000) | |
90 { | |
91 v5 = new _BINKBUF_3_0_0_0; | |
92 memset(v5, 0, sizeof(_BINKBUF_3_0_0_0)); | |
93 } | |
1802 | 94 else __debugbreak(); |
0 | 95 |
2218 | 96 memset(&v11, 0, 0x7C); |
0 | 97 v11.dwSize = 124; |
2218 | 98 v11.dwWidth = uWidth; |
99 v11.dwFlags = 0x1007; // DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | |
100 v11.ddsCaps.dwCaps = 0x4040; // DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | |
0 | 101 v11.dwHeight = uHeight; |
102 *(_QWORD *)&v11.ddpfPixelFormat.dwSize = 0x400000020ui64;// DDPF_FOURCC | |
2218 | 103 v11.ddpfPixelFormat.dwFourCC = 0x32595559; |
2151 | 104 if (FAILED(pRenderer->pDirectDraw4->CreateSurface(&v11, &v15, 0))) |
0 | 105 { |
106 memset(&v11.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT)); | |
107 | |
108 v11.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
109 v11.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; | |
110 | |
1980 | 111 long hr = pRenderer->pDirectDraw4->CreateSurface(&v11, &v15, 0); |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
112 ErrD3D(hr); |
0 | 113 } |
114 v5->uWidth = v11.dwWidth; | |
115 v5->uHeight = v11.dwHeight; | |
116 v5->uBinkDDSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)v15); | |
117 v5->field_38 = 0; | |
118 v7 = (IDirectDrawSurface *)v15; | |
119 } | |
2152 | 120 /*else |
0 | 121 { |
122 v4 = 0; | |
123 a2 = 0; | |
124 | |
125 | |
126 if (uBinkVersion == 0x0001000500150000) | |
127 { | |
128 v5 = new _BINKBUF_1_5_21_0; | |
129 memset(v5, 0, sizeof(_BINKBUF_1_5_21_0)); | |
130 } | |
131 else if (uBinkVersion == 0x0003000000000000) | |
132 { | |
133 v5 = new _BINKBUF_3_0_0_0; | |
134 memset(v5, 0, sizeof(_BINKBUF_3_0_0_0)); | |
135 } | |
1802 | 136 else __debugbreak(); |
0 | 137 |
138 memset(&Dst, 0, 0x6Cu); | |
139 Dst.dwSize = 108; | |
2218 | 140 Dst.dwWidth = uWidth; |
0 | 141 Dst.dwFlags = 4103; |
142 Dst.ddsCaps.dwCaps = 16448; | |
143 Dst.dwHeight = uHeight; | |
144 Dst.ddpfPixelFormat.dwSize = 32; | |
145 Dst.ddpfPixelFormat.dwFlags = 4; | |
146 Dst.ddpfPixelFormat.dwFourCC = 844715353; | |
2151 | 147 if (FAILED(pRenderer->pDirectDraw2->CreateSurface(&Dst, (LPDIRECTDRAWSURFACE *)&a2, 0))) |
0 | 148 { |
149 memset(&Dst.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT)); | |
150 | |
151 Dst.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
152 Dst.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; | |
153 | |
1980 | 154 long hr = pRenderer->pDirectDraw2->CreateSurface(&Dst, (LPDIRECTDRAWSURFACE *)&a2, 0); |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
155 ErrD3D(hr); |
0 | 156 } |
157 v5->uWidth = Dst.dwWidth; | |
158 v5->uHeight = Dst.dwHeight; | |
159 v5->uBinkDDSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)a2); | |
160 v5->field_38 = 0; | |
161 v7 = (IDirectDrawSurface *)a2; | |
2152 | 162 }*/ |
0 | 163 v5->pTargetDDrawSurface = v7; |
1802 | 164 v5->hWnd = window->GetApiHandle(); |
2218 | 165 v5->field_4C = 0; |
166 v5->field_68 = 0; | |
167 v5->field_5C = 0; | |
168 v5->field_74 = a4 & 0x1F; | |
0 | 169 v5->field_78 = 1; |
1802 | 170 v5->target_width = GetSystemMetrics(SM_CXSCREEN); |
171 v5->target_height = GetSystemMetrics(SM_CYSCREEN); | |
0 | 172 v5->field_2C = 16; |
1802 | 173 |
174 RECT Rect; | |
175 GetWindowRect(window->GetApiHandle(), &Rect); | |
176 v5->field_8 = window->GetWidth(); | |
177 v5->field_C = window->GetHeight(); | |
0 | 178 v5->field_1C = Rect.left; |
179 v5->field_20 = Rect.top; | |
2218 | 180 Rect.left = 0; |
181 Rect.top = 0; | |
1802 | 182 ClientToScreen(window->GetApiHandle(), (POINT *)&Rect); |
0 | 183 v5->field_1C = Rect.left - v5->field_1C; |
184 v5->field_20 = Rect.top - v5->field_20; | |
1802 | 185 GetClientRect(window->GetApiHandle(), &Rect); |
0 | 186 v5->field_30 = v5->field_8 - Rect.right; |
187 v5->field_34 = v5->field_C - Rect.bottom; | |
188 v5->field_8 = v5->uWidth + v5->field_30; | |
189 v5->field_C = v5->uHeight + v5->field_34; | |
2218 | 190 BinkBufferSetOffset(v5, 0, 0); |
0 | 191 BinkBufferSetScale(v5, v5->uWidth, v5->uHeight); |
192 return v5; | |
193 } | |
194 | |
195 | |
196 //----- (004C0133) -------------------------------------------------------- | |
197 bool BinkLockBuffer(_BINKBUF *_this) | |
198 { | |
2334 | 199 // IDirectDrawSurface *v2; // edi@5 |
0 | 200 IDirectDrawSurface4 *v6; // edi@11 |
201 | |
2152 | 202 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) |
0 | 203 { |
2132 | 204 DDSURFACEDESC2 v8; // [sp+Ch] [bp-7Ch]@4 |
0 | 205 if ( _this->pTargetDDrawSurface ) |
206 { | |
2132 | 207 memset(&v8, 0, 0x7C); |
0 | 208 v8.dwSize = 124; |
209 while ( 1 ) | |
210 { | |
2132 | 211 v6 = (IDirectDrawSurface4 *)_this->pTargetDDrawSurface; |
212 if ( !v6->Lock(0, &v8, 1, 0) ) | |
0 | 213 break; |
214 | |
215 if (uBinkVersion < 0x0003000000000000) | |
2218 | 216 _this->uBinkDDSurfaceType |= 0x80000000; |
0 | 217 else |
2218 | 218 _this->uBinkDDSurfaceType |= 0x4000000; |
0 | 219 |
220 if ( v6->Restore() ) | |
221 return 0; | |
222 } | |
2132 | 223 _this->pDDrawSurfaceData_ = v8.lpSurface; |
224 _this->pDDrawSurfaceData = v8.lpSurface; | |
225 _this->uDDrawSurfacePitch = v8.lPitch; | |
226 return 1; | |
0 | 227 } |
228 } | |
2152 | 229 /*else |
0 | 230 { |
2132 | 231 DDSURFACEDESC v8; // [sp+Ch] [bp-7Ch]@4 |
0 | 232 if ( _this->pTargetDDrawSurface ) |
233 { | |
234 memset(&v8.lPitch, 0, 0x6Cu); | |
235 v8.lPitch = 108; | |
236 while ( 1 ) | |
237 { | |
2132 | 238 v2 = _this->pTargetDDrawSurface; |
239 if ( !v2->Lock(0, (LPDDSURFACEDESC)&v8.lPitch, 1, 0) ) | |
0 | 240 break; |
241 | |
242 if (uBinkVersion < 0x0003000000000000) | |
243 __asm int 3; | |
244 else | |
2132 | 245 BYTE3(_this->uBinkDDSurfaceType) |= 4u; |
0 | 246 |
247 if ( v2->Restore() ) | |
248 return 0; | |
249 } | |
2132 | 250 _this->pDDrawSurfaceData_ = v8.lpSurface; |
251 _this->pDDrawSurfaceData = v8.lpSurface; | |
252 _this->uDDrawSurfacePitch = v8.dwReserved; | |
0 | 253 return 1; |
254 } | |
2152 | 255 }*/ |
0 | 256 return 1; |
257 } | |
258 | |
259 //----- (004C01FB) -------------------------------------------------------- | |
260 void BinkUnlockBuffer(_BINKBUF *_this) | |
261 { | |
262 IDirectDrawSurface *v2; // eax@1 | |
263 | |
264 v2 = _this->pTargetDDrawSurface; | |
265 if ( v2 ) | |
266 { | |
267 v2->Unlock(0); | |
2218 | 268 _this->uDDrawSurfacePitch = 0; |
269 _this->pDDrawSurfaceData = 0; | |
0 | 270 |
271 if (uBinkVersion < 0x0003000000000000) | |
272 BYTE3(_this->uBinkDDSurfaceType) &= 0x7F; | |
273 else | |
274 BYTE3(_this->uBinkDDSurfaceType) &= 0xFB; | |
275 } | |
276 } | |
277 //----- (004BF794) -------------------------------------------------------- | |
2290 | 278 void ShowMM7IntroVideo_and_LoadingScreen() |
0 | 279 { |
280 RGBTexture tex; // [sp+Ch] [bp-30h]@1 | |
2290 | 281 unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8 |
282 unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8 | |
0 | 283 |
284 pVideoPlayer->bStopBeforeSchedule = false; | |
165 | 285 pVideoPlayer->pResetflag = 0; |
2290 | 286 bGameoverLoop = true; |
256 | 287 if (!bNoVideo) |
0 | 288 { |
289 pRenderer->PresentBlackScreen(); | |
290 if ( !pVideoPlayer->bStopBeforeSchedule ) | |
2290 | 291 PlayFullscreenMovie(MOVIE_Intro, true); |
0 | 292 } |
2334 | 293 // char pContainerName[64]; |
2278 | 294 |
2290 | 295 tex.Load("mm6title.pcx", 2); |
0 | 296 pRenderer->BeginScene(); |
297 pRenderer->DrawTextureRGB(0, 0, &tex); | |
298 free(tex.pPixels); | |
299 tex.pPixels = 0; | |
762 | 300 |
2290 | 301 //LoadFonts_and_DrawCopyrightWindow(); |
302 DrawMM7CopyrightWindow(); | |
762 | 303 |
0 | 304 pRenderer->EndScene(); |
305 pRenderer->Present(); | |
1004 | 306 |
307 #ifndef _DEBUG | |
308 Sleep(1500); // let the copyright window stay for a while | |
309 #endif | |
310 | |
2290 | 311 if (!bNoSound && pAudioPlayer->hAILRedbook ) |
0 | 312 { |
313 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0)); | |
314 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
2218 | 315 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS); |
0 | 316 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); |
2290 | 317 } |
318 bGameoverLoop = false; | |
0 | 319 } |
320 | |
321 //----- (004BE70E) -------------------------------------------------------- | |
1802 | 322 void VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4) |
0 | 323 { |
324 int v4; // ebp@1 | |
325 const char *pName; // edi@1 | |
326 MSG Msg; // [sp+Ch] [bp-1Ch]@12 | |
2218 | 327 |
0 | 328 v4 = a2; |
329 pName = pMovieName; | |
2061 | 330 if ( !(dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO)) ) |
0 | 331 { |
332 if ( a2 == 2 ) | |
333 v4 = 0; | |
334 ShowCursor(0); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
335 OpenGlobalMovie(pName, 0, ScreenSizeFlag); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
336 bPlayingMovie = 1; |
2218 | 337 field_44 = v4; |
2154 | 338 //if ( pRenderer->pRenderD3D ) |
0 | 339 { |
340 pRenderer->ClearTarget(0); | |
341 } | |
2154 | 342 /* else |
0 | 343 { |
344 pRenderer->BeginScene(); | |
345 pRenderer->ClearTarget(0); | |
346 pRenderer->EndScene(); | |
2154 | 347 }*/ |
151 | 348 pCurrentScreen = SCREEN_VIDEO; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
349 |
2218 | 350 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
351 RECT rc_client; | |
352 GetClientRect(hwnd, &rc_client); | |
353 int client_width = rc_client.right - rc_client.left, | |
354 client_height = rc_client.bottom - rc_client.top; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
355 |
2218 | 356 HDC dc = GetDC(hwnd); |
357 HDC back_dc = CreateCompatibleDC(dc); | |
358 HBITMAP back_bmp; | |
359 SelectObject(back_dc, back_bmp = CreateCompatibleBitmap(dc, client_width, client_height)); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
360 |
2218 | 361 while (true) |
362 { | |
363 if ( pVideoPlayer->bStopBeforeSchedule ) | |
364 break; | |
365 while (PeekMessageA(&Msg, hwnd, 0, 0, PM_REMOVE)) | |
366 { | |
367 if (Msg.message == 18) | |
368 Game_DeinitializeAndTerminate(0); | |
369 if (Msg.message == 15) | |
370 break; | |
371 TranslateMessage(&Msg); | |
372 DispatchMessageA(&Msg); | |
373 } | |
374 GUI_MainMenuMessageProc(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
375 |
2218 | 376 if (pMovie->Stopped()) |
377 break; | |
378 char *image = pPlayer->DoFrame(); | |
379 if (image) | |
380 { | |
381 // draw to hwnd | |
382 BITMAPINFO bmi; | |
383 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
384 bmi.bmiHeader.biWidth = client_width; | |
385 bmi.bmiHeader.biHeight = -client_height; | |
386 bmi.bmiHeader.biPlanes = 1; | |
387 bmi.bmiHeader.biBitCount = 32; | |
388 bmi.bmiHeader.biCompression = BI_RGB; | |
389 bmi.bmiHeader.biSizeImage = 0; | |
390 bmi.bmiHeader.biXPelsPerMeter = 0; | |
391 bmi.bmiHeader.biYPelsPerMeter = 0; | |
392 bmi.bmiHeader.biClrUsed = 0; | |
393 bmi.bmiHeader.biClrImportant = 0; | |
394 GetDIBits(back_dc, back_bmp, 0, client_height, 0, &bmi, DIB_RGB_COLORS); | |
395 SetDIBits(back_dc, back_bmp, 0, client_height, image, &bmi, DIB_RGB_COLORS); | |
396 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
|
397 |
2218 | 398 delete[] image; |
399 } | |
400 if (pVideoPlayer->bStopBeforeSchedule == 1) | |
401 Sleep(1000); | |
402 } | |
403 pVideoPlayer->Unload(); | |
404 /* | |
0 | 405 if ( pVideoPlayer->uMovieFormat == 2 ) |
406 { | |
407 if ( pVideoPlayer->pBinkMovie ) | |
408 { | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
409 //pVideoPlayer->BinkDrawFrame(v4, ScreenSizeFlag); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
410 |
0 | 411 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
412 } |
0 | 413 if ( pVideoPlayer->bStopBeforeSchedule == 1 ) |
414 Sleep(0x3E8u); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
415 }*/ |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
416 /* |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
417 if ( pVideoPlayer->uMovieFormat == 1 ) |
0 | 418 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
419 if ( pVideoPlayer->pSmackerMovie ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
420 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
421 pVideoPlayer->SmackDrawFrame(v4, ScreenSizeFlag); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
422 while ( pVideoPlayer->pSmackerMovie ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
423 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
424 if ( pVideoPlayer->bStopBeforeSchedule ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
425 break; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
426 while ( PeekMessageW(&Msg, 0, 0, 0, 1) ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
427 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
428 if (Msg.message == WM_QUIT) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
429 Game_DeinitializeAndTerminate(0); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
430 if (Msg.message == WM_PAINT) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
431 break; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
432 TranslateMessage(&Msg); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
433 DispatchMessageW(&Msg); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
434 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
435 GUI_MainMenuMessageProc(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
436 if ( !pVideoPlayer->pSmackerMovie ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
437 break; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
438 if ( !SmackWait(pVideoPlayer->pSmackerMovie) && !pVideoPlayer->bStopBeforeSchedule ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
439 pVideoPlayer->SmackDrawFrame(v4, ScreenSizeFlag); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
440 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
441 } |
0 | 442 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
443 */ |
227 | 444 if (a4 == 1) |
151 | 445 pCurrentScreen = SCREEN_GAME; |
0 | 446 pVideoPlayer->bPlayingMovie = 0; |
447 ShowCursor(1); | |
151 | 448 if ( pCurrentScreen == SCREEN_VIDEO ) |
449 pCurrentScreen = SCREEN_GAME; | |
0 | 450 } |
451 } | |
452 | |
453 //----- (004BE95A) -------------------------------------------------------- | |
454 unsigned int VideoPlayer::SmackCheckSurfaceFromat() | |
455 { | |
456 DDPIXELFORMAT a2; // [sp+0h] [bp-20h]@1 | |
457 | |
458 a2.dwSize = 32; | |
459 a2.dwFlags = 64; | |
460 pRenderer->GetTargetPixelFormat(&a2); | |
2070 | 461 if (a2.dwRGBBitCount == 32) |
462 return SMACKBUFFER565; | |
0 | 463 if ( a2.dwRGBBitCount != 8 ) |
464 { | |
465 if ( a2.dwRBitMask == 0xF800 ) | |
466 { | |
467 if ( a2.dwGBitMask == 0x7E0 && a2.dwBBitMask == 0x1F ) | |
1035 | 468 return SMACKBUFFER565; |
0 | 469 } |
470 else | |
471 { | |
472 if ( a2.dwRBitMask == 0x7C00 | |
473 && a2.dwGBitMask == 0x3E0 | |
474 && a2.dwBBitMask == 0x1F ) | |
1035 | 475 return SMACKBUFFER555; |
0 | 476 } |
477 MessageBoxA(0, "Unsupported pixel format.", "Smacker Error", 0); | |
478 } | |
479 return 0; | |
480 } | |
481 | |
482 //----- (004BE9D8) -------------------------------------------------------- | |
1802 | 483 void VideoPlayer::Initialize(OSWindow *target_window) |
0 | 484 { |
485 DWORD NumberOfBytesRead; // [sp+10h] [bp-4h]@9 | |
486 | |
1802 | 487 window = target_window; |
488 | |
0 | 489 uint uBinkVersionMajor = -1, |
490 uBinkVersionMinor = -1; | |
491 GetDllVersion(L"BINKW32.DLL", &uBinkVersionMajor, &uBinkVersionMinor); | |
492 uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor; | |
493 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
494 strcpy(pTmpBuf.data(), "anims\\might7.vid"); |
2218 | 495 hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 496 if ( hMightVid == INVALID_HANDLE_VALUE ) |
497 { | |
1217 | 498 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
|
499 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 500 return; |
501 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
502 strcpy(pTmpBuf.data(), "anims\\magic7.vid"); |
2218 | 503 hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 504 if ( hMagicVid == INVALID_HANDLE_VALUE ) |
505 { | |
506 if ( !bCanLoadFromCD ) | |
2218 | 507 { |
1217 | 508 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
|
509 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 510 return; |
2218 | 511 } |
1217 | 512 sprintf(pTmpBuf2.data(), "%c:\\%s", (unsigned __int8)cMM7GameCDDriveLetter, pTmpBuf.data()); |
2218 | 513 hMagicVid = CreateFileA(pTmpBuf2.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 514 if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE ) |
515 { | |
2218 | 516 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
|
517 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 518 return; |
519 } | |
520 } | |
521 ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0); | |
522 ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0); | |
523 pMagicVideoHeaders = 0; | |
524 pMightVideoHeaders = 0; | |
1583 | 525 pMightVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMightVideoHeaders + 2); |
526 pMagicVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMagicVideoHeaders + 2); | |
0 | 527 ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0); |
528 ReadFile(hMagicVid, pMagicVideoHeaders, 44 * uNumMagicVideoHeaders, &NumberOfBytesRead, 0); | |
529 } | |
530 | |
531 //----- (004BEB41) -------------------------------------------------------- | |
532 void VideoPlayer::Prepare() | |
533 { | |
534 pEventTimer->Pause(); | |
535 if ( pAudioPlayer->hAILRedbook ) | |
536 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
1802 | 537 |
538 bStopBeforeSchedule = false; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
539 bBufferLoaded = 1; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
540 /* |
1802 | 541 pSmackerMovie = 0; |
542 pSmackerBuffer = 0; | |
543 pBinkMovie = 0; | |
544 pBinkBuffer = 0; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
545 */ |
1802 | 546 bPlayingMovie = false; |
547 bFirstFrame = false; | |
548 bUsingSmackerMMX = SmackUseMMX(1); | |
0 | 549 BinkSetSoundSystem(BinkOpenMiles, pAudioPlayer->hDigDriver); |
2152 | 550 uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer4); |
0 | 551 } |
552 | |
553 //----- (004BEBD7) -------------------------------------------------------- | |
554 void VideoPlayer::Unload() | |
555 { | |
1802 | 556 //_BINK *pBinkMovie; // eax@1 |
557 //_BINKBUF *pBinkBuffer; // eax@3 | |
558 //_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
|
559 /* |
0 | 560 if ( pBinkMovie ) |
561 { | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
562 //BinkPause(pBinkMovie, 1); |
0 | 563 Sleep(300); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
564 //BinkClose(pBinkMovie); |
1802 | 565 pBinkMovie = 0; |
0 | 566 } |
1802 | 567 |
0 | 568 if ( pBinkBuffer ) |
569 { | |
570 pBinkBuffer->pTargetDDrawSurface->Release(); | |
1802 | 571 pBinkBuffer->pTargetDDrawSurface = 0; |
572 free(pBinkBuffer); | |
573 pBinkBuffer = 0; | |
0 | 574 } |
1802 | 575 |
0 | 576 if ( pSmackerMovie ) |
577 { | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
578 //SmackSoundOnOff(pSmackerMovie, 0); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
579 //SmackClose(pSmackerMovie); |
1802 | 580 pSmackerMovie = 0; |
0 | 581 } |
1802 | 582 if ( pSmackerBuffer ) |
0 | 583 { |
1802 | 584 SmackBufferClose(pSmackerBuffer); |
585 pSmackerBuffer = 0; | |
0 | 586 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
587 */ |
1802 | 588 if ( pSmackMovieBlit ) |
0 | 589 { |
1802 | 590 SmackBlitClose(pSmackMovieBlit); |
591 pSmackMovieBlit = 0; | |
0 | 592 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
593 bBufferLoaded = 0; |
1802 | 594 uMovieFormat = 0; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
595 uMovieFormatSwapped = 0; |
1802 | 596 memset(pCurrentMovieName, 0, 0x40); |
0 | 597 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop ) |
598 AIL_redbook_resume(pAudioPlayer->hAILRedbook); | |
599 pEventTimer->Resume(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
600 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
601 if (pMovie) |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
602 { |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
603 delete pMovie; |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
604 pMovie = nullptr; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
605 } |
0 | 606 } |
607 | |
608 //----- (004BECD5) -------------------------------------------------------- | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
609 /* |
0 | 610 void VideoPlayer::FastForwardToFrame(unsigned int uDstFrameNum) |
611 { | |
612 VideoPlayer *v2; // esi@1 | |
613 unsigned int v3; // eax@1 | |
614 | |
615 v2 = this; | |
616 v3 = this->uMovieFormat; | |
617 if ( v3 == 2 ) | |
618 { | |
619 if (uDstFrameNum) | |
620 { | |
621 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame : | |
622 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame : | |
623 nullptr; | |
624 while (*pCurrentFrame < uDstFrameNum) | |
625 { | |
626 BinkDoFrame(pBinkMovie); | |
627 BinkNextFrame(pBinkMovie); | |
628 } | |
629 } | |
630 } | |
631 else | |
632 { | |
633 if ( v3 != 1 ) | |
634 return; | |
635 SmackSoundOnOff(this->pSmackerMovie, 0); | |
636 if (uDstFrameNum) | |
637 { | |
638 while ( v2->pSmackerMovie->FrameNum < uDstFrameNum) | |
639 { | |
640 SmackDoFrame(v2->pSmackerMovie); | |
641 SmackNextFrame(v2->pSmackerMovie); | |
642 } | |
643 } | |
644 } | |
645 Unload(); | |
646 } | |
647 | |
648 | |
649 //----- (004BED4F) -------------------------------------------------------- | |
1802 | 650 void VideoPlayer::BinkDrawFrame(int a3, int a4) |
0 | 651 { |
652 //VideoPlayer *v4; // esi@1 | |
653 _BINKBUF *v5; // eax@5 | |
654 LONG v6; // edx@6 | |
655 int v7; // ecx@6 | |
656 LONG v8; // edx@6 | |
657 struct tagRECT a3a; // [sp+8h] [bp-20h]@10 | |
658 struct tagRECT a1; // [sp+18h] [bp-10h]@6 | |
659 | |
660 //v4 = this; | |
661 if ( this->pBinkMovie && this->pBinkBuffer ) | |
662 { | |
663 BinkDoFrame(pBinkMovie); | |
664 BinkGetRects(pBinkMovie, pBinkBuffer->uBinkDDSurfaceType); | |
665 if ( BinkLockBuffer(pBinkBuffer) ) | |
666 { | |
667 BinkCopyToBuffer(pBinkMovie, pBinkBuffer->pDDrawSurfaceData, pBinkBuffer->uDDrawSurfacePitch, pBinkBuffer->uHeight, | |
668 0, 0, pBinkBuffer->uBinkDDSurfaceType); | |
669 BinkUnlockBuffer(pBinkBuffer); | |
670 } | |
671 v5 = pBinkBuffer; | |
672 if ( pRenderer->bWindowMode ) | |
673 { | |
674 v6 = v5->uRectX; | |
675 a1.left = v6; | |
676 a1.top = v5->uRectY; | |
677 v7 = v6 + v5->uWidth; | |
678 a1.right = v6 + v5->uWidth; | |
679 v8 = a1.top + v5->uHeight; | |
680 } | |
681 else | |
682 { | |
683 a1.left = 0; | |
684 a1.top = 0; | |
685 v7 = v5->uWidth; | |
686 a1.right = v5->uWidth; | |
687 v8 = v5->uHeight; | |
688 } | |
689 a1.bottom = v8; | |
690 if ( a4 ) | |
691 { | |
692 a1.right = v5->uWidth + v7; | |
693 a1.bottom = v5->uHeight + v8; | |
694 } | |
695 a3a.left = 0; | |
696 a3a.top = 0; | |
697 a3a.right = v5->uWidth; | |
698 a3a.bottom = v5->uHeight; | |
699 pRenderer->BltToFront(&a1, v5->pTargetDDrawSurface, &a3a, 0x1000000u); | |
700 | |
701 | |
702 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame : | |
703 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame: | |
704 nullptr; | |
705 int *pNumFrames = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uNumFrames : | |
706 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uNumFrames : | |
707 nullptr; | |
708 | |
709 if (*pCurrentFrame != *pNumFrames - 1 || bLoopPlaying) | |
710 BinkNextFrame(pBinkMovie); | |
711 else | |
712 Unload(); | |
713 } | |
714 } | |
715 | |
716 | |
717 | |
718 //----- (004BEE6B) -------------------------------------------------------- | |
1802 | 719 void VideoPlayer::SmackDrawFrame(int a3, int a4) |
0 | 720 { |
721 VideoPlayer *v4; // esi@1 | |
722 _SMACK *v5; // eax@3 | |
723 unsigned int v6; // eax@5 | |
724 char v7; // zf@5 | |
725 int v8; // eax@11 | |
726 _SMACK *v9; // eax@13 | |
727 _SMACK *v10; // eax@16 | |
728 _SMACK *v11; // eax@20 | |
729 unsigned int v12; // [sp-1Ch] [bp-34h]@7 | |
730 LONG v13; // [sp-18h] [bp-30h]@7 | |
731 LONG v14; // [sp-14h] [bp-2Ch]@7 | |
732 signed int v15; // [sp-10h] [bp-28h]@7 | |
733 signed int v16; // [sp-Ch] [bp-24h]@7 | |
734 signed int v17; // [sp-8h] [bp-20h]@7 | |
735 struct tagPOINT Point; // [sp+8h] [bp-10h]@7 | |
736 unsigned short *pOutSurface; // [sp+10h] [bp-8h]@5 | |
737 unsigned int uPixelsPerRow; // [sp+14h] [bp-4h]@5 | |
738 | |
739 v4 = this; | |
1802 | 740 if ( !pRenderer->bWindowMode || window->Focused()) |
0 | 741 { |
742 v5 = v4->pSmackerMovie; | |
743 if ( v5->NewPalette ) | |
744 SmackBlitSetPalette(v4->pSmackMovieBlit, v5->Palette, v5->PalType); | |
745 SmackDoFrame(v4->pSmackerMovie); | |
746 pRenderer->LockFrontBuffer((void **)&pOutSurface, &uPixelsPerRow); | |
747 v6 = 2 * uPixelsPerRow; | |
748 v7 = v4->bFirstFrame == 0; | |
749 uPixelsPerRow *= 2; | |
750 if ( !v7 ) | |
751 { | |
752 if ( pRenderer->bWindowMode ) | |
753 { | |
754 Point.y = 0; | |
755 Point.x = 0; | |
1802 | 756 ClientToScreen(window->GetApiHandle(), &Point); |
0 | 757 v17 = -1; |
758 v16 = 480; | |
759 v15 = 640; | |
760 v14 = Point.y; | |
761 v13 = Point.x; | |
762 v12 = uPixelsPerRow; | |
763 } | |
764 else | |
765 { | |
766 v17 = -1; | |
767 v16 = 480; | |
768 v15 = 640; | |
769 v14 = 0; | |
770 v13 = 0; | |
771 v12 = v6; | |
772 } | |
773 SmackBlitClear(v4->pSmackMovieBlit, pOutSurface, v12, v13, v14, v15, v16, v17); | |
774 v4->bFirstFrame = 0; | |
775 } | |
776 pRenderer->RestoreFrontBuffer(); | |
777 if ( pRenderer->bWindowMode ) | |
778 { | |
779 Point.y = 0; | |
780 Point.x = 0; | |
1802 | 781 ClientToScreen(window->GetApiHandle(), &Point); |
0 | 782 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); |
783 if ( a4 ) | |
784 { | |
785 while ( v8 ) | |
786 { | |
787 v9 = v4->pSmackerMovie; | |
788 SmackBlit( | |
789 v4->pSmackMovieBlit, | |
790 pOutSurface, | |
791 uPixelsPerRow, | |
792 v9->LastRectx + Point.x / 2, | |
793 a3 + v9->LastRecty + Point.y / 2, | |
794 v4->pSomeSmackerBuffer, | |
795 v9->Width, | |
796 v9->LastRectx, | |
797 v9->LastRecty, | |
798 v9->LastRectw, | |
799 v9->LastRecth); | |
800 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); | |
801 } | |
802 } | |
803 else | |
804 { | |
805 while ( v8 ) | |
806 { | |
807 v10 = v4->pSmackerMovie; | |
808 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, Point.x + v10->LastRectx, a3 + Point.y + v10->LastRecty, | |
809 v4->pSomeSmackerBuffer, v10->Width, v10->LastRectx, v10->LastRecty, v10->LastRectw, v10->LastRecth); | |
810 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); | |
811 } | |
812 } | |
813 } | |
814 else | |
815 { | |
816 while ( SmackToBufferRect(v4->pSmackerMovie, 0) ) | |
817 { | |
818 v11 = v4->pSmackerMovie; | |
819 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, v11->LastRectx, a3 + v11->LastRecty, v4->pSomeSmackerBuffer, | |
820 v11->Width, v11->LastRectx, v11->LastRecty, v11->LastRectw, v11->LastRecth); | |
821 } | |
822 } | |
823 pRenderer->UnlockFrontBuffer(); | |
824 if ( v4->pSmackerMovie->FrameNum != v4->pSmackerMovie->Frames - 1 || v4->bLoopPlaying ) | |
825 SmackNextFrame(v4->pSmackerMovie); | |
826 else | |
827 Unload(); | |
828 } | |
829 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
830 */ |
1802 | 831 void VideoPlayer::_inlined_in_463149() |
832 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
833 /* |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
834 if ( pSmackMovie && !SmackWait(pSmackerMovie) ) |
1802 | 835 { |
836 pRenderer->BeginScene(); | |
837 pMouse->DrawCursorToTarget(); | |
838 SmackUpdatePalette(); | |
2216 | 839 pMouse->ReadCursorWithItem(); |
1802 | 840 pRenderer->EndScene(); |
841 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
842 else if ( pBinkMovie && !BinkWait(pBinkMovie) ) |
1802 | 843 { |
844 pRenderer->BeginScene(); | |
845 pMouse->DrawCursorToTarget(); | |
846 BinkUpdatePalette(); | |
2216 | 847 pMouse->ReadCursorWithItem(); |
1802 | 848 pRenderer->EndScene(); |
849 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
850 */ |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
851 if (pMovie) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
852 { |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
853 pRenderer->BeginScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
854 pMouse->DrawCursorToTarget(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
855 UpdatePalette(); |
2216 | 856 pMouse->ReadCursorWithItem(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
857 pRenderer->EndScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
858 } |
1802 | 859 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
860 //auto pixels = new unsigned short[640 * 480]; |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
861 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
862 void VideoPlayer::UpdatePalette() |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
863 { |
2218 | 864 Log::Warning(L"smacker"); |
865 | |
866 pRenderer->BeginScene(); | |
867 if (pMovie->Stopped())//âèäåî çàâåðøåíî/ïåðåçàãðóçêà | |
868 { | |
2222 | 869 int width = game_viewport_width; |
870 int height = game_viewport_height; | |
2218 | 871 delete pMovie; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
872 |
2218 | 873 SetFilePointer(hVidFile, uOffset, nullptr, FILE_BEGIN); |
0 | 874 |
2218 | 875 pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, width, height); |
876 } | |
877 else | |
878 { | |
2221 | 879 char *image = pPlayer->DoFrame(); |
2222 | 880 int image_array[460 * 344];//game_viewport_width * game_viewport_height |
2218 | 881 if (image) |
882 { | |
2222 | 883 memcpy(image_array, image, sizeof (image_array)); |
2223 | 884 for (unsigned int y = 8; y < 8 + game_viewport_height; ++y)//êîîðäèíàòû ìåñòîïîëîæåíèÿ âèäåîðîëèêà |
2221 | 885 { |
886 for (unsigned int x = 8; x < 8 + game_viewport_width; ++x) | |
887 { | |
2222 | 888 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + x + y * pRenderer->uTargetSurfacePitch; |
889 *p = image_array[((x - 8) + ((y - 8)*game_viewport_width))]; | |
2221 | 890 } |
891 } | |
2218 | 892 delete[] image; |
893 } | |
894 } | |
895 pRenderer->EndScene(); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
896 } |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
897 /* |
0 | 898 //----- (004BF08B) -------------------------------------------------------- |
1802 | 899 void VideoPlayer::SmackUpdatePalette() |
0 | 900 { |
2069 | 901 //VideoPlayer *v2; // esi@1 |
0 | 902 unsigned __int16 *v3; // ebx@1 |
903 unsigned int v4; // edi@1 | |
904 unsigned int v5; // eax@1 | |
2069 | 905 //_SMACK *v6; // eax@1 |
0 | 906 |
2070 | 907 Log::Warning(L"smacker"); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
908 |
0 | 909 pRenderer->BeginScene(); |
2069 | 910 |
911 v3 = pixels;//pRenderer->pTargetSurface; | |
912 v4 = 640;//pRenderer->uTargetSurfacePitch; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
913 v5 = SmackCheckSurfaceFromat(); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
914 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
915 SmackToBuffer(pSmackerMovie, 8, 8, 2 * v4, pRenderer->field_14, v3, v5); |
2069 | 916 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
917 |
2070 | 918 for (unsigned int y = 8; y < 8 + pSmackerMovie->Height; ++y) |
2069 | 919 for (unsigned int x = 8; x < 8 + pSmackerMovie->Width; ++x) |
920 { | |
921 pRenderer->WritePixel16(x, y, pixels[x + y * 640]); | |
922 } | |
2125 | 923 //delete [] pixels; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
924 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
925 //v6 = pSmackerMovie; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
926 while (true) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
927 { |
2125 | 928 if ( pSmackerMovie->NewPalette ) |
0 | 929 { |
2125 | 930 SmackBufferNewPalette(pSmackerBuffer, pSmackerMovie->Palette, (pSmackerMovie->PalType)); |
0 | 931 SmackColorRemapWithTrans( |
2125 | 932 pSmackerMovie, |
933 pSmackerBuffer->Palette, | |
934 pSmackerBuffer->MaxPalColors, | |
935 pSmackerBuffer->PalType, | |
0 | 936 1000); |
937 } | |
2069 | 938 SmackDoFrame(pSmackerMovie); |
939 if ( pSmackerMovie->FrameNum != pSmackerMovie->Frames - 1 || bLoopPlaying ) | |
940 SmackNextFrame(pSmackerMovie); | |
0 | 941 else |
942 Unload(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
943 |
0 | 944 pRenderer->EndScene(); |
945 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
946 */ |
0 | 947 |
948 | |
949 | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
950 /* |
0 | 951 //----- (004BF141) -------------------------------------------------------- |
952 _BINK *VideoPlayer::OpenBink(const char *pName) | |
953 { | |
954 //VideoPlayer *v2; // esi@1 | |
955 signed int v3; // edi@1 | |
956 int v4; // ebx@2 | |
957 signed int v5; // edi@5 | |
958 int v6; // ebx@6 | |
959 HANDLE v8; // [sp-8h] [bp-18h]@10 | |
960 unsigned int v9; // [sp-4h] [bp-14h]@10 | |
961 | |
962 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
963 if (!_stricmp(pName, pMightVideoHeaders[i].pVideoName)) |
0 | 964 { |
965 SetFilePointer(hMightVid, pMightVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); | |
966 | |
967 if (uBinkVersion < 0x0003000000000000) | |
968 return BinkOpen(hMightVid, 0x8800000); | |
969 else | |
970 return BinkOpen(hMightVid, 0x82000000); | |
971 } | |
972 | |
973 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
974 if (!_stricmp(pName, pMagicVideoHeaders[i].pVideoName)) |
0 | 975 { |
976 SetFilePointer(hMagicVid, pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); | |
977 | |
2125 | 978 if (uBinkVersion < 0x0003000000000000) |
979 return BinkOpen(hMagicVid, BINKNOTHREADEDIO | BINKFILEHANDLE);//0x8800000); | |
980 else | |
981 return BinkOpen(hMagicVid, BINKIOPROCESSOR | BINKCOPYALL);//0x82000000); | |
0 | 982 } |
983 | |
984 return nullptr; | |
985 } | |
986 //----- (004BF1E6) -------------------------------------------------------- | |
987 _SMACK *VideoPlayer::OpenSmack(const char *pFilename) | |
988 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
989 if ( this->uNumMightVideoHeaders ) |
0 | 990 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
991 for ( uint i = 0; i < (signed int)this->uNumMightVideoHeaders; ++i) |
0 | 992 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
993 if ( !_stricmp(this->pMightVideoHeaders[i].pVideoName, pFilename) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
994 { |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
995 SetFilePointer(this->hMightVid, this->pMightVideoHeaders[i].uFileOffset, 0, 0); |
2082 | 996 return SmackOpen(this->hMightVid, SMACKTRACK2|SMACKTRACK1|SMACKFILEHANDLE|SMACKLOADEXTRA|SMACKNEEDVOLUME, -1);//0x7140, |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
997 } |
0 | 998 } |
999 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1000 if ( this->uNumMagicVideoHeaders ) |
0 | 1001 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1002 for ( uint i = 0; i < (signed int)this->uNumMagicVideoHeaders; ++i ) |
0 | 1003 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1004 if ( !_stricmp(this->pMagicVideoHeaders[i].pVideoName, pFilename) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1005 { |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1006 SetFilePointer(this->hMagicVid, this->pMagicVideoHeaders[i].uFileOffset, 0, 0); |
2079 | 1007 return SmackOpen(this->hMagicVid, SMACKTRACK2|SMACKTRACK1|SMACKFILEHANDLE|SMACKLOADEXTRA|SMACKNEEDVOLUME, -1); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1008 } |
0 | 1009 } |
1010 } | |
1011 return 0; | |
1012 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1013 */ |
0 | 1014 //----- (004BF28F) -------------------------------------------------------- |
898 | 1015 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) |
0 | 1016 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1017 if (!this->bBufferLoaded) |
0 | 1018 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1019 //Prepare(); |
2218 | 1020 pEventTimer->Pause(); |
1021 if (pAudioPlayer->hAILRedbook) | |
1022 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1023 |
2218 | 1024 bStopBeforeSchedule = false; |
1025 bBufferLoaded = 1; | |
1026 /* | |
1027 pSmackerMovie = 0; | |
1028 pSmackerBuffer = 0; | |
1029 pBinkMovie = 0; | |
1030 pBinkBuffer = 0; | |
1031 */ | |
1032 bPlayingMovie = false; | |
1033 bFirstFrame = false; | |
1034 bUsingSmackerMMX = SmackUseMMX(1); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1035 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1036 this->bLoopPlaying = a3_1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1037 if ( LOBYTE(this->field_104) == 1 ) |
0 | 1038 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1039 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); |
0 | 1040 return; |
1041 } | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1042 |
2218 | 1043 LoadMovie(pMovieName); |
1044 /* | |
1045 this->pSmackerMovie = OpenSmack(Str2); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1046 if ( !this->pSmackerMovie ) |
0 | 1047 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1048 this->Unload(); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
1049 sprintf(pTmpBuf.data(), "Can't load %s", &Str2); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1050 MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937", 0); |
898 | 1051 return; |
0 | 1052 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1053 */ |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1054 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1055 /* |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1056 this->pSmackerBuffer = (_SMACKBUF *)SmackBufferOpen(window->GetApiHandle(), 4, LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height), LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height)); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1057 if ( this->pSmackerBuffer ) |
0 | 1058 { |
1059 pRenderer->BeginScene(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1060 SmackToBuffer(this->pSmackerMovie, 8, 8, 2 * pRenderer->uTargetSurfacePitch, pRenderer->field_14, pRenderer->pTargetSurface, SmackCheckSurfaceFromat()); |
0 | 1061 pRenderer->EndScene(); |
1062 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1063 SmackVolumePan(this->pSmackerMovie, 1040384, (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0), 32767); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1064 */ |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1065 |
0 | 1066 } |
1067 } | |
1068 | |
1069 //----- (004BF3F9) -------------------------------------------------------- | |
1070 bool VideoPlayer::AnyMovieLoaded() | |
1071 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1072 return pMovie;// pSmackerMovie || pBinkMovie; |
0 | 1073 } |
1074 | |
1075 //----- (004BF411) -------------------------------------------------------- | |
898 | 1076 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) |
0 | 1077 { |
2334 | 1078 // unsigned int v10; // eax@11 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1079 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1080 if (!this->bBufferLoaded) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1081 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1082 //Prepare(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1083 pEventTimer->Pause(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1084 if (pAudioPlayer->hAILRedbook) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1085 AIL_redbook_pause(pAudioPlayer->hAILRedbook); |
0 | 1086 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1087 bStopBeforeSchedule = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1088 bBufferLoaded = 1; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1089 /* |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1090 pSmackerMovie = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1091 pSmackerBuffer = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1092 pBinkMovie = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1093 pBinkBuffer = 0; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1094 */ |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1095 bPlayingMovie = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1096 bFirstFrame = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1097 bUsingSmackerMMX = SmackUseMMX(1); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1098 this->bLoopPlaying = bLoop; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1099 LoadMovie(pFilename); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1100 return; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1101 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1102 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1103 /* |
0 | 1104 sprintf(pVideoName, "%s.bik", pFilename); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1105 this->pBinkMovie = OpenBink(pVideoName); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1106 if ( this->pBinkMovie ) |
0 | 1107 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1108 this->uMovieFormat = 2; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1109 strcpy(this->pCurrentMovieName, pFilename); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1110 pBinkMovie = this->pBinkMovie; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1111 this->uMovieFormatSwapped = 1; |
0 | 1112 if ( pBinkMovie ) |
1802 | 1113 this->pBinkBuffer = CreateBinkBuffer(pBinkMovie->uWidth, pBinkMovie->uHeight, 0); |
0 | 1114 } |
1115 else | |
1116 { | |
1117 Unload(); | |
898 | 1118 sprintfex(pVideoName, "%s.smk", pFilename); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1119 this->pSmackerMovie = OpenSmack(pVideoName); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1120 if ( !this->pSmackerMovie ) |
0 | 1121 { |
1122 Unload(); | |
1123 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename); | |
1124 MessageBoxA(0, pVideoName, "Smacker Error", 0); | |
1125 return; | |
1126 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1127 this->uMovieFormat = 1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1128 strcpy(this->pCurrentMovieName, pFilename); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1129 this->uMovieFormatSwapped = 2; |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1130 this->pSomeSmackerBuffer = (char *)malloc(this->pSmackerMovie->Width * this->pSmackerMovie->Height); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1131 if ( !this->pSomeSmackerBuffer ) |
0 | 1132 { |
1133 Unload(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1134 sprintf(pVideoName, "Can't allocate memory for buffer"); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1135 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
0 | 1136 return; |
1137 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1138 SmackToBuffer(this->pSmackerMovie, 0, 0, this->pSmackerMovie->Width, this->pSmackerMovie->Height, this->pSomeSmackerBuffer, 0); |
1035 | 1139 |
1140 v10 = SmackCheckSurfaceFromat(); | |
0 | 1141 if ( a4 ) |
1142 { | |
1035 | 1143 v10 |= SMACKBLIT2X; |
1144 | |
1145 if (uCPUSpeed >= 165 ) | |
1146 v10 |= SMACKBLIT2XSMOOTHING; | |
0 | 1147 else |
1035 | 1148 Log::Warning(L"Smacker seems to use lower resolution because it thinks CPU is slow"); |
0 | 1149 } |
1035 | 1150 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1151 this->pSmackMovieBlit = SmackBlitOpen(v10); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1152 if ( !this->pSmackMovieBlit ) |
0 | 1153 { |
1154 Unload(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1155 sprintf(pVideoName, "Failed to open Blit API"); |
0 | 1156 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1157 return; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1158 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1159 }*/ |
0 | 1160 } |
1161 } | |
1162 | |
1163 | |
1164 //----- (004BF5B2) -------------------------------------------------------- | |
1165 void VideoPlayer::_4BF5B2() | |
1166 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1167 //__debugbreak(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1168 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1169 /*if ( this->uMovieFormat == 2 ) |
0 | 1170 { |
1171 BinkGoto(pBinkMovie, 1, 0); | |
1172 BinkDoFrame(pBinkMovie); | |
1173 BinkNextFrame(pBinkMovie); | |
1174 } | |
1175 else | |
1176 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1177 if ( this->uMovieFormat != 1 ) |
0 | 1178 return; |
1179 SmackGoto(pSmackerMovie, 1); | |
1180 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1181 { | |
1182 SmackDoFrame(pSmackerMovie); | |
1183 SmackNextFrame(pSmackerMovie); | |
1184 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1185 }*/ |
0 | 1186 pMouse->_469E24(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1187 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pMovie)//!this->pSmackerMovie ) |
0 | 1188 { |
2218 | 1189 bGameoverLoop = true; |
1919 | 1190 HouseDialogPressCloseBtn(); |
336 | 1191 window_SpeakInHouse->Release(); |
2218 | 1192 pParty->uFlags &= 0xFFFFFFFD; |
481 | 1193 if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) |
0 | 1194 { |
388 | 1195 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
|
1196 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0); |
2218 | 1197 window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1, 0x31, "", 0); |
1198 window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2, 0x32, "", 0); | |
1199 window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3, 0x33, "", 0); | |
1200 window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4, 0x34, "", 0); | |
0 | 1201 } |
1202 bGameoverLoop = 0; | |
1203 } | |
1204 } | |
1205 | |
1206 //----- (004BF73A) -------------------------------------------------------- | |
898 | 1207 void VideoPlayer::SelectMovieType() |
0 | 1208 { |
1209 char Source[32]; // [sp+Ch] [bp-40h]@1 | |
1210 | |
1211 strcpy(Source, this->pCurrentMovieName); | |
1212 Unload(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1213 if ( this->uMovieFormatSwapped == 1 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1214 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1215 else if ( this->uMovieFormatSwapped == 2 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1216 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); |
0 | 1217 else |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1218 __debugbreak(); |
0 | 1219 } |
1220 | |
1221 //----- (004BF8F6) -------------------------------------------------------- | |
1222 void VideoPlayer::PlayDeathMovie() | |
1223 { | |
1224 bStopBeforeSchedule = 0; | |
165 | 1225 pResetflag = 0; |
1397 | 1226 PlayFullscreenMovie(MOVIE_Death, true); |
1227 //pGame->pCShow->PlayMovie(MOVIE_Death, 1); | |
1262 | 1228 } |
1229 | |
1230 //----- (004BE6F5) -------------------------------------------------------- | |
1231 VideoPlayer::VideoPlayer() : | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1232 bBufferLoaded(0), |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1233 //pBinkMovie(nullptr), pBinkBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1234 //pSmackerMovie(nullptr), pSmackerBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1235 pSmackMovieBlit(nullptr) |
1262 | 1236 { |
1237 //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame); | |
1238 bStopBeforeSchedule = false; | |
1239 pResetflag = 0; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1240 pPlayer = new MultimediaPlayer(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1241 pPlayer->Initialize(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1242 pMovie = nullptr; |
1262 | 1243 //pBinkMovie = nullptr; |
1244 } | |
2134 | 1245 |
1246 bool MultimediaPlayer::libavcodec_initialized = false; | |
1247 | |
1248 void MultimediaPlayer::Logger(void *, int, const char *format, va_list args) | |
1249 { | |
2218 | 1250 char msg[1024]; |
1251 vsprintf(msg, format, args); | |
2134 | 1252 |
2218 | 1253 DWORD w; |
1254 WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), msg, lstrlenA(msg), &w, nullptr); | |
2134 | 1255 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1256 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1257 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
|
1258 { |
2218 | 1259 HANDLE stream = (HANDLE)opaque; |
1260 //int numBytes = stream->read((char*)buf, buf_size); | |
1261 int numBytes; | |
1262 ReadFile(stream, (char *)buf, buf_size, (LPDWORD)&numBytes, NULL); | |
1263 return numBytes; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1264 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1265 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1266 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
|
1267 { |
2218 | 1268 if (whence == AVSEEK_SIZE) |
1269 return pVideoPlayer->uSize; | |
1270 HANDLE h = (HANDLE)opaque; | |
1271 LARGE_INTEGER li; | |
1272 li.QuadPart = offset; | |
1273 | |
1274 if (!SetFilePointerEx(h, li, (PLARGE_INTEGER)&li, FILE_BEGIN)) | |
1275 return -1; | |
1276 return li.QuadPart; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1277 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1278 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1279 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
|
1280 { |
2218 | 1281 char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2 |
1282 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
|
1283 |
2218 | 1284 sprintf(pVideoNameBik, "%s.bik", pFilename); |
1285 sprintf(pVideoNameSmk, "%s.smk", pFilename); | |
1286 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
1287 { | |
1288 //no BIK in MightVid | |
1289 /* | |
1290 if (!_stricmp(pVideoNameBik, pMightVideoHeaders[i].pVideoName)) | |
1291 { | |
1292 hVidFile = hMightVid; | |
1293 uOffset = pMightVideoHeaders[i].uFileOffset; | |
1294 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
1295 this->uMovieFormat = 2; | |
1296 this->uMovieFormatSwapped = 1; | |
1297 } | |
1298 */ | |
1299 if (!_stricmp(pVideoNameSmk, pMightVideoHeaders[i].pVideoName)) | |
1300 { | |
1301 hVidFile = hMightVid; | |
1302 uOffset = pMightVideoHeaders[i].uFileOffset; | |
1303 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
1304 this->uMovieFormat = 1; | |
1305 this->uMovieFormatSwapped = 2; | |
1306 } | |
1307 } | |
1308 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
1309 { | |
1310 if (!_stricmp(pVideoNameBik, pMagicVideoHeaders[i].pVideoName)) | |
1311 { | |
1312 hVidFile = hMagicVid; | |
1313 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
1314 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
1315 this->uMovieFormat = 2; | |
1316 this->uMovieFormatSwapped = 1; | |
1317 } | |
1318 if (!_stricmp(pVideoNameSmk, pMagicVideoHeaders[i].pVideoName)) | |
1319 { | |
1320 hVidFile = hMagicVid; | |
1321 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
1322 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
1323 this->uMovieFormat = 1; | |
1324 this->uMovieFormatSwapped = 2; | |
1325 } | |
1326 } | |
1327 if (!hVidFile) | |
1328 { | |
1329 Unload(); | |
1330 MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0); | |
1331 return; | |
1332 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1333 |
2218 | 1334 SetFilePointer(hVidFile, uOffset, 0, FILE_BEGIN); |
1335 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
|
1336 |
2218 | 1337 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
1338 RECT rc_client; | |
1339 GetClientRect(hwnd, &rc_client); | |
1340 int client_width = rc_client.right - rc_client.left, | |
1341 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
|
1342 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1343 |
2218 | 1344 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
|
1345 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1346 } |