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