Mercurial > mm7
annotate VideoPlayer.cpp @ 2278:0cd17b0d36c2
MMT_MainMenu
author | Ritor1 |
---|---|
date | Fri, 14 Mar 2014 17:59:06 +0600 |
parents | aff7a7b072b7 |
children | a01d3cf9ff83 |
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 } | |
2278 | 305 char pContainerName[64]; |
306 | |
307 sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx"); | |
308 tex.LoadPCXFile(pContainerName, 0); | |
309 //tex.Load("MMTTITLE.pcx", 2); | |
0 | 310 pRenderer->BeginScene(); |
311 pRenderer->DrawTextureRGB(0, 0, &tex); | |
312 free(tex.pPixels); | |
313 tex.pPixels = 0; | |
762 | 314 |
315 LoadFonts_and_DrawCopyrightWindow(); | |
316 | |
0 | 317 pRenderer->EndScene(); |
318 pRenderer->Present(); | |
1004 | 319 |
320 #ifndef _DEBUG | |
321 Sleep(1500); // let the copyright window stay for a while | |
322 #endif | |
323 | |
0 | 324 if (!bNoSound && pAudioPlayer->hAILRedbook ) |
325 { | |
326 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0)); | |
327 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
2218 | 328 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS); |
0 | 329 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); |
330 } | |
331 bGameoverLoop = 0; | |
332 } | |
333 | |
334 //----- (004BE70E) -------------------------------------------------------- | |
1802 | 335 void VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4) |
0 | 336 { |
337 int v4; // ebp@1 | |
338 const char *pName; // edi@1 | |
339 MSG Msg; // [sp+Ch] [bp-1Ch]@12 | |
2218 | 340 |
0 | 341 v4 = a2; |
342 pName = pMovieName; | |
2061 | 343 if ( !(dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO)) ) |
0 | 344 { |
345 if ( a2 == 2 ) | |
346 v4 = 0; | |
347 ShowCursor(0); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
348 OpenGlobalMovie(pName, 0, ScreenSizeFlag); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
349 bPlayingMovie = 1; |
2218 | 350 field_44 = v4; |
2154 | 351 //if ( pRenderer->pRenderD3D ) |
0 | 352 { |
353 pRenderer->ClearTarget(0); | |
354 } | |
2154 | 355 /* else |
0 | 356 { |
357 pRenderer->BeginScene(); | |
358 pRenderer->ClearTarget(0); | |
359 pRenderer->EndScene(); | |
2154 | 360 }*/ |
151 | 361 pCurrentScreen = SCREEN_VIDEO; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
362 |
2218 | 363 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
364 RECT rc_client; | |
365 GetClientRect(hwnd, &rc_client); | |
366 int client_width = rc_client.right - rc_client.left, | |
367 client_height = rc_client.bottom - rc_client.top; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
368 |
2218 | 369 HDC dc = GetDC(hwnd); |
370 HDC back_dc = CreateCompatibleDC(dc); | |
371 HBITMAP back_bmp; | |
372 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
|
373 |
2218 | 374 while (true) |
375 { | |
376 if ( pVideoPlayer->bStopBeforeSchedule ) | |
377 break; | |
378 while (PeekMessageA(&Msg, hwnd, 0, 0, PM_REMOVE)) | |
379 { | |
380 if (Msg.message == 18) | |
381 Game_DeinitializeAndTerminate(0); | |
382 if (Msg.message == 15) | |
383 break; | |
384 TranslateMessage(&Msg); | |
385 DispatchMessageA(&Msg); | |
386 } | |
387 GUI_MainMenuMessageProc(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
388 |
2218 | 389 if (pMovie->Stopped()) |
390 break; | |
391 char *image = pPlayer->DoFrame(); | |
392 if (image) | |
393 { | |
394 // draw to hwnd | |
395 BITMAPINFO bmi; | |
396 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
397 bmi.bmiHeader.biWidth = client_width; | |
398 bmi.bmiHeader.biHeight = -client_height; | |
399 bmi.bmiHeader.biPlanes = 1; | |
400 bmi.bmiHeader.biBitCount = 32; | |
401 bmi.bmiHeader.biCompression = BI_RGB; | |
402 bmi.bmiHeader.biSizeImage = 0; | |
403 bmi.bmiHeader.biXPelsPerMeter = 0; | |
404 bmi.bmiHeader.biYPelsPerMeter = 0; | |
405 bmi.bmiHeader.biClrUsed = 0; | |
406 bmi.bmiHeader.biClrImportant = 0; | |
407 GetDIBits(back_dc, back_bmp, 0, client_height, 0, &bmi, DIB_RGB_COLORS); | |
408 SetDIBits(back_dc, back_bmp, 0, client_height, image, &bmi, DIB_RGB_COLORS); | |
409 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
|
410 |
2218 | 411 delete[] image; |
412 } | |
413 if (pVideoPlayer->bStopBeforeSchedule == 1) | |
414 Sleep(1000); | |
415 } | |
416 pVideoPlayer->Unload(); | |
417 /* | |
0 | 418 if ( pVideoPlayer->uMovieFormat == 2 ) |
419 { | |
420 if ( pVideoPlayer->pBinkMovie ) | |
421 { | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
422 //pVideoPlayer->BinkDrawFrame(v4, ScreenSizeFlag); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
423 |
0 | 424 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
425 } |
0 | 426 if ( pVideoPlayer->bStopBeforeSchedule == 1 ) |
427 Sleep(0x3E8u); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
428 }*/ |
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 if ( pVideoPlayer->uMovieFormat == 1 ) |
0 | 431 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
432 if ( pVideoPlayer->pSmackerMovie ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
433 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
434 pVideoPlayer->SmackDrawFrame(v4, ScreenSizeFlag); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
435 while ( pVideoPlayer->pSmackerMovie ) |
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 ( pVideoPlayer->bStopBeforeSchedule ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
438 break; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
439 while ( PeekMessageW(&Msg, 0, 0, 0, 1) ) |
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 if (Msg.message == WM_QUIT) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
442 Game_DeinitializeAndTerminate(0); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
443 if (Msg.message == WM_PAINT) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
444 break; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
445 TranslateMessage(&Msg); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
446 DispatchMessageW(&Msg); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
447 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
448 GUI_MainMenuMessageProc(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
449 if ( !pVideoPlayer->pSmackerMovie ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
450 break; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
451 if ( !SmackWait(pVideoPlayer->pSmackerMovie) && !pVideoPlayer->bStopBeforeSchedule ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
452 pVideoPlayer->SmackDrawFrame(v4, ScreenSizeFlag); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
453 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
454 } |
0 | 455 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
456 */ |
227 | 457 if (a4 == 1) |
151 | 458 pCurrentScreen = SCREEN_GAME; |
0 | 459 pVideoPlayer->bPlayingMovie = 0; |
460 ShowCursor(1); | |
151 | 461 if ( pCurrentScreen == SCREEN_VIDEO ) |
462 pCurrentScreen = SCREEN_GAME; | |
0 | 463 } |
464 } | |
465 | |
466 //----- (004BE95A) -------------------------------------------------------- | |
467 unsigned int VideoPlayer::SmackCheckSurfaceFromat() | |
468 { | |
469 DDPIXELFORMAT a2; // [sp+0h] [bp-20h]@1 | |
470 | |
471 a2.dwSize = 32; | |
472 a2.dwFlags = 64; | |
473 pRenderer->GetTargetPixelFormat(&a2); | |
2070 | 474 if (a2.dwRGBBitCount == 32) |
475 return SMACKBUFFER565; | |
0 | 476 if ( a2.dwRGBBitCount != 8 ) |
477 { | |
478 if ( a2.dwRBitMask == 0xF800 ) | |
479 { | |
480 if ( a2.dwGBitMask == 0x7E0 && a2.dwBBitMask == 0x1F ) | |
1035 | 481 return SMACKBUFFER565; |
0 | 482 } |
483 else | |
484 { | |
485 if ( a2.dwRBitMask == 0x7C00 | |
486 && a2.dwGBitMask == 0x3E0 | |
487 && a2.dwBBitMask == 0x1F ) | |
1035 | 488 return SMACKBUFFER555; |
0 | 489 } |
490 MessageBoxA(0, "Unsupported pixel format.", "Smacker Error", 0); | |
491 } | |
492 return 0; | |
493 } | |
494 | |
495 //----- (004BE9D8) -------------------------------------------------------- | |
1802 | 496 void VideoPlayer::Initialize(OSWindow *target_window) |
0 | 497 { |
498 DWORD NumberOfBytesRead; // [sp+10h] [bp-4h]@9 | |
499 | |
1802 | 500 window = target_window; |
501 | |
0 | 502 uint uBinkVersionMajor = -1, |
503 uBinkVersionMinor = -1; | |
504 GetDllVersion(L"BINKW32.DLL", &uBinkVersionMajor, &uBinkVersionMinor); | |
505 uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor; | |
506 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
507 strcpy(pTmpBuf.data(), "anims\\might7.vid"); |
2218 | 508 hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 509 if ( hMightVid == INVALID_HANDLE_VALUE ) |
510 { | |
1217 | 511 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
|
512 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 513 return; |
514 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
515 strcpy(pTmpBuf.data(), "anims\\magic7.vid"); |
2218 | 516 hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 517 if ( hMagicVid == INVALID_HANDLE_VALUE ) |
518 { | |
519 if ( !bCanLoadFromCD ) | |
2218 | 520 { |
1217 | 521 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
|
522 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 523 return; |
2218 | 524 } |
1217 | 525 sprintf(pTmpBuf2.data(), "%c:\\%s", (unsigned __int8)cMM7GameCDDriveLetter, pTmpBuf.data()); |
2218 | 526 hMagicVid = CreateFileA(pTmpBuf2.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 527 if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE ) |
528 { | |
2218 | 529 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
|
530 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 531 return; |
532 } | |
533 } | |
534 ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0); | |
535 ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0); | |
536 pMagicVideoHeaders = 0; | |
537 pMightVideoHeaders = 0; | |
1583 | 538 pMightVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMightVideoHeaders + 2); |
539 pMagicVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMagicVideoHeaders + 2); | |
0 | 540 ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0); |
541 ReadFile(hMagicVid, pMagicVideoHeaders, 44 * uNumMagicVideoHeaders, &NumberOfBytesRead, 0); | |
542 } | |
543 | |
544 //----- (004BEB41) -------------------------------------------------------- | |
545 void VideoPlayer::Prepare() | |
546 { | |
547 pEventTimer->Pause(); | |
548 if ( pAudioPlayer->hAILRedbook ) | |
549 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
1802 | 550 |
551 bStopBeforeSchedule = false; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
552 bBufferLoaded = 1; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
553 /* |
1802 | 554 pSmackerMovie = 0; |
555 pSmackerBuffer = 0; | |
556 pBinkMovie = 0; | |
557 pBinkBuffer = 0; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
558 */ |
1802 | 559 bPlayingMovie = false; |
560 bFirstFrame = false; | |
561 bUsingSmackerMMX = SmackUseMMX(1); | |
0 | 562 BinkSetSoundSystem(BinkOpenMiles, pAudioPlayer->hDigDriver); |
2152 | 563 uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer4); |
0 | 564 } |
565 | |
566 //----- (004BEBD7) -------------------------------------------------------- | |
567 void VideoPlayer::Unload() | |
568 { | |
1802 | 569 //_BINK *pBinkMovie; // eax@1 |
570 //_BINKBUF *pBinkBuffer; // eax@3 | |
571 //_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
|
572 /* |
0 | 573 if ( pBinkMovie ) |
574 { | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
575 //BinkPause(pBinkMovie, 1); |
0 | 576 Sleep(300); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
577 //BinkClose(pBinkMovie); |
1802 | 578 pBinkMovie = 0; |
0 | 579 } |
1802 | 580 |
0 | 581 if ( pBinkBuffer ) |
582 { | |
583 pBinkBuffer->pTargetDDrawSurface->Release(); | |
1802 | 584 pBinkBuffer->pTargetDDrawSurface = 0; |
585 free(pBinkBuffer); | |
586 pBinkBuffer = 0; | |
0 | 587 } |
1802 | 588 |
0 | 589 if ( pSmackerMovie ) |
590 { | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
591 //SmackSoundOnOff(pSmackerMovie, 0); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
592 //SmackClose(pSmackerMovie); |
1802 | 593 pSmackerMovie = 0; |
0 | 594 } |
1802 | 595 if ( pSmackerBuffer ) |
0 | 596 { |
1802 | 597 SmackBufferClose(pSmackerBuffer); |
598 pSmackerBuffer = 0; | |
0 | 599 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
600 */ |
1802 | 601 if ( pSmackMovieBlit ) |
0 | 602 { |
1802 | 603 SmackBlitClose(pSmackMovieBlit); |
604 pSmackMovieBlit = 0; | |
0 | 605 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
606 bBufferLoaded = 0; |
1802 | 607 uMovieFormat = 0; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
608 uMovieFormatSwapped = 0; |
1802 | 609 memset(pCurrentMovieName, 0, 0x40); |
0 | 610 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop ) |
611 AIL_redbook_resume(pAudioPlayer->hAILRedbook); | |
612 pEventTimer->Resume(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
613 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
614 if (pMovie) |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
615 { |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
616 delete pMovie; |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
617 pMovie = nullptr; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
618 } |
0 | 619 } |
620 | |
621 //----- (004BECD5) -------------------------------------------------------- | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
622 /* |
0 | 623 void VideoPlayer::FastForwardToFrame(unsigned int uDstFrameNum) |
624 { | |
625 VideoPlayer *v2; // esi@1 | |
626 unsigned int v3; // eax@1 | |
627 | |
628 v2 = this; | |
629 v3 = this->uMovieFormat; | |
630 if ( v3 == 2 ) | |
631 { | |
632 if (uDstFrameNum) | |
633 { | |
634 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame : | |
635 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame : | |
636 nullptr; | |
637 while (*pCurrentFrame < uDstFrameNum) | |
638 { | |
639 BinkDoFrame(pBinkMovie); | |
640 BinkNextFrame(pBinkMovie); | |
641 } | |
642 } | |
643 } | |
644 else | |
645 { | |
646 if ( v3 != 1 ) | |
647 return; | |
648 SmackSoundOnOff(this->pSmackerMovie, 0); | |
649 if (uDstFrameNum) | |
650 { | |
651 while ( v2->pSmackerMovie->FrameNum < uDstFrameNum) | |
652 { | |
653 SmackDoFrame(v2->pSmackerMovie); | |
654 SmackNextFrame(v2->pSmackerMovie); | |
655 } | |
656 } | |
657 } | |
658 Unload(); | |
659 } | |
660 | |
661 | |
662 //----- (004BED4F) -------------------------------------------------------- | |
1802 | 663 void VideoPlayer::BinkDrawFrame(int a3, int a4) |
0 | 664 { |
665 //VideoPlayer *v4; // esi@1 | |
666 _BINKBUF *v5; // eax@5 | |
667 LONG v6; // edx@6 | |
668 int v7; // ecx@6 | |
669 LONG v8; // edx@6 | |
670 struct tagRECT a3a; // [sp+8h] [bp-20h]@10 | |
671 struct tagRECT a1; // [sp+18h] [bp-10h]@6 | |
672 | |
673 //v4 = this; | |
674 if ( this->pBinkMovie && this->pBinkBuffer ) | |
675 { | |
676 BinkDoFrame(pBinkMovie); | |
677 BinkGetRects(pBinkMovie, pBinkBuffer->uBinkDDSurfaceType); | |
678 if ( BinkLockBuffer(pBinkBuffer) ) | |
679 { | |
680 BinkCopyToBuffer(pBinkMovie, pBinkBuffer->pDDrawSurfaceData, pBinkBuffer->uDDrawSurfacePitch, pBinkBuffer->uHeight, | |
681 0, 0, pBinkBuffer->uBinkDDSurfaceType); | |
682 BinkUnlockBuffer(pBinkBuffer); | |
683 } | |
684 v5 = pBinkBuffer; | |
685 if ( pRenderer->bWindowMode ) | |
686 { | |
687 v6 = v5->uRectX; | |
688 a1.left = v6; | |
689 a1.top = v5->uRectY; | |
690 v7 = v6 + v5->uWidth; | |
691 a1.right = v6 + v5->uWidth; | |
692 v8 = a1.top + v5->uHeight; | |
693 } | |
694 else | |
695 { | |
696 a1.left = 0; | |
697 a1.top = 0; | |
698 v7 = v5->uWidth; | |
699 a1.right = v5->uWidth; | |
700 v8 = v5->uHeight; | |
701 } | |
702 a1.bottom = v8; | |
703 if ( a4 ) | |
704 { | |
705 a1.right = v5->uWidth + v7; | |
706 a1.bottom = v5->uHeight + v8; | |
707 } | |
708 a3a.left = 0; | |
709 a3a.top = 0; | |
710 a3a.right = v5->uWidth; | |
711 a3a.bottom = v5->uHeight; | |
712 pRenderer->BltToFront(&a1, v5->pTargetDDrawSurface, &a3a, 0x1000000u); | |
713 | |
714 | |
715 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame : | |
716 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame: | |
717 nullptr; | |
718 int *pNumFrames = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uNumFrames : | |
719 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uNumFrames : | |
720 nullptr; | |
721 | |
722 if (*pCurrentFrame != *pNumFrames - 1 || bLoopPlaying) | |
723 BinkNextFrame(pBinkMovie); | |
724 else | |
725 Unload(); | |
726 } | |
727 } | |
728 | |
729 | |
730 | |
731 //----- (004BEE6B) -------------------------------------------------------- | |
1802 | 732 void VideoPlayer::SmackDrawFrame(int a3, int a4) |
0 | 733 { |
734 VideoPlayer *v4; // esi@1 | |
735 _SMACK *v5; // eax@3 | |
736 unsigned int v6; // eax@5 | |
737 char v7; // zf@5 | |
738 int v8; // eax@11 | |
739 _SMACK *v9; // eax@13 | |
740 _SMACK *v10; // eax@16 | |
741 _SMACK *v11; // eax@20 | |
742 unsigned int v12; // [sp-1Ch] [bp-34h]@7 | |
743 LONG v13; // [sp-18h] [bp-30h]@7 | |
744 LONG v14; // [sp-14h] [bp-2Ch]@7 | |
745 signed int v15; // [sp-10h] [bp-28h]@7 | |
746 signed int v16; // [sp-Ch] [bp-24h]@7 | |
747 signed int v17; // [sp-8h] [bp-20h]@7 | |
748 struct tagPOINT Point; // [sp+8h] [bp-10h]@7 | |
749 unsigned short *pOutSurface; // [sp+10h] [bp-8h]@5 | |
750 unsigned int uPixelsPerRow; // [sp+14h] [bp-4h]@5 | |
751 | |
752 v4 = this; | |
1802 | 753 if ( !pRenderer->bWindowMode || window->Focused()) |
0 | 754 { |
755 v5 = v4->pSmackerMovie; | |
756 if ( v5->NewPalette ) | |
757 SmackBlitSetPalette(v4->pSmackMovieBlit, v5->Palette, v5->PalType); | |
758 SmackDoFrame(v4->pSmackerMovie); | |
759 pRenderer->LockFrontBuffer((void **)&pOutSurface, &uPixelsPerRow); | |
760 v6 = 2 * uPixelsPerRow; | |
761 v7 = v4->bFirstFrame == 0; | |
762 uPixelsPerRow *= 2; | |
763 if ( !v7 ) | |
764 { | |
765 if ( pRenderer->bWindowMode ) | |
766 { | |
767 Point.y = 0; | |
768 Point.x = 0; | |
1802 | 769 ClientToScreen(window->GetApiHandle(), &Point); |
0 | 770 v17 = -1; |
771 v16 = 480; | |
772 v15 = 640; | |
773 v14 = Point.y; | |
774 v13 = Point.x; | |
775 v12 = uPixelsPerRow; | |
776 } | |
777 else | |
778 { | |
779 v17 = -1; | |
780 v16 = 480; | |
781 v15 = 640; | |
782 v14 = 0; | |
783 v13 = 0; | |
784 v12 = v6; | |
785 } | |
786 SmackBlitClear(v4->pSmackMovieBlit, pOutSurface, v12, v13, v14, v15, v16, v17); | |
787 v4->bFirstFrame = 0; | |
788 } | |
789 pRenderer->RestoreFrontBuffer(); | |
790 if ( pRenderer->bWindowMode ) | |
791 { | |
792 Point.y = 0; | |
793 Point.x = 0; | |
1802 | 794 ClientToScreen(window->GetApiHandle(), &Point); |
0 | 795 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); |
796 if ( a4 ) | |
797 { | |
798 while ( v8 ) | |
799 { | |
800 v9 = v4->pSmackerMovie; | |
801 SmackBlit( | |
802 v4->pSmackMovieBlit, | |
803 pOutSurface, | |
804 uPixelsPerRow, | |
805 v9->LastRectx + Point.x / 2, | |
806 a3 + v9->LastRecty + Point.y / 2, | |
807 v4->pSomeSmackerBuffer, | |
808 v9->Width, | |
809 v9->LastRectx, | |
810 v9->LastRecty, | |
811 v9->LastRectw, | |
812 v9->LastRecth); | |
813 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); | |
814 } | |
815 } | |
816 else | |
817 { | |
818 while ( v8 ) | |
819 { | |
820 v10 = v4->pSmackerMovie; | |
821 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, Point.x + v10->LastRectx, a3 + Point.y + v10->LastRecty, | |
822 v4->pSomeSmackerBuffer, v10->Width, v10->LastRectx, v10->LastRecty, v10->LastRectw, v10->LastRecth); | |
823 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); | |
824 } | |
825 } | |
826 } | |
827 else | |
828 { | |
829 while ( SmackToBufferRect(v4->pSmackerMovie, 0) ) | |
830 { | |
831 v11 = v4->pSmackerMovie; | |
832 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, v11->LastRectx, a3 + v11->LastRecty, v4->pSomeSmackerBuffer, | |
833 v11->Width, v11->LastRectx, v11->LastRecty, v11->LastRectw, v11->LastRecth); | |
834 } | |
835 } | |
836 pRenderer->UnlockFrontBuffer(); | |
837 if ( v4->pSmackerMovie->FrameNum != v4->pSmackerMovie->Frames - 1 || v4->bLoopPlaying ) | |
838 SmackNextFrame(v4->pSmackerMovie); | |
839 else | |
840 Unload(); | |
841 } | |
842 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
843 */ |
1802 | 844 void VideoPlayer::_inlined_in_463149() |
845 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
846 /* |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
847 if ( pSmackMovie && !SmackWait(pSmackerMovie) ) |
1802 | 848 { |
849 pRenderer->BeginScene(); | |
850 pMouse->DrawCursorToTarget(); | |
851 SmackUpdatePalette(); | |
2216 | 852 pMouse->ReadCursorWithItem(); |
1802 | 853 pRenderer->EndScene(); |
854 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
855 else if ( pBinkMovie && !BinkWait(pBinkMovie) ) |
1802 | 856 { |
857 pRenderer->BeginScene(); | |
858 pMouse->DrawCursorToTarget(); | |
859 BinkUpdatePalette(); | |
2216 | 860 pMouse->ReadCursorWithItem(); |
1802 | 861 pRenderer->EndScene(); |
862 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
863 */ |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
864 if (pMovie) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
865 { |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
866 pRenderer->BeginScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
867 pMouse->DrawCursorToTarget(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
868 UpdatePalette(); |
2216 | 869 pMouse->ReadCursorWithItem(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
870 pRenderer->EndScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
871 } |
1802 | 872 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
873 //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
|
874 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
875 void VideoPlayer::UpdatePalette() |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
876 { |
2218 | 877 Log::Warning(L"smacker"); |
878 | |
879 pRenderer->BeginScene(); | |
880 if (pMovie->Stopped())//âèäåî çàâåðøåíî/ïåðåçàãðóçêà | |
881 { | |
2222 | 882 int width = game_viewport_width; |
883 int height = game_viewport_height; | |
2218 | 884 delete pMovie; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
885 |
2218 | 886 SetFilePointer(hVidFile, uOffset, nullptr, FILE_BEGIN); |
0 | 887 |
2218 | 888 pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, width, height); |
889 } | |
890 else | |
891 { | |
2221 | 892 char *image = pPlayer->DoFrame(); |
2222 | 893 int image_array[460 * 344];//game_viewport_width * game_viewport_height |
2218 | 894 if (image) |
895 { | |
2222 | 896 memcpy(image_array, image, sizeof (image_array)); |
2223 | 897 for (unsigned int y = 8; y < 8 + game_viewport_height; ++y)//êîîðäèíàòû ìåñòîïîëîæåíèÿ âèäåîðîëèêà |
2221 | 898 { |
899 for (unsigned int x = 8; x < 8 + game_viewport_width; ++x) | |
900 { | |
2222 | 901 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + x + y * pRenderer->uTargetSurfacePitch; |
902 *p = image_array[((x - 8) + ((y - 8)*game_viewport_width))]; | |
2221 | 903 } |
904 } | |
2218 | 905 delete[] image; |
906 } | |
907 } | |
908 pRenderer->EndScene(); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
909 } |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
910 /* |
0 | 911 //----- (004BF08B) -------------------------------------------------------- |
1802 | 912 void VideoPlayer::SmackUpdatePalette() |
0 | 913 { |
2069 | 914 //VideoPlayer *v2; // esi@1 |
0 | 915 unsigned __int16 *v3; // ebx@1 |
916 unsigned int v4; // edi@1 | |
917 unsigned int v5; // eax@1 | |
2069 | 918 //_SMACK *v6; // eax@1 |
0 | 919 |
2070 | 920 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
|
921 |
0 | 922 pRenderer->BeginScene(); |
2069 | 923 |
924 v3 = pixels;//pRenderer->pTargetSurface; | |
925 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
|
926 v5 = SmackCheckSurfaceFromat(); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
927 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
928 SmackToBuffer(pSmackerMovie, 8, 8, 2 * v4, pRenderer->field_14, v3, v5); |
2069 | 929 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
930 |
2070 | 931 for (unsigned int y = 8; y < 8 + pSmackerMovie->Height; ++y) |
2069 | 932 for (unsigned int x = 8; x < 8 + pSmackerMovie->Width; ++x) |
933 { | |
934 pRenderer->WritePixel16(x, y, pixels[x + y * 640]); | |
935 } | |
2125 | 936 //delete [] pixels; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
937 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
938 //v6 = pSmackerMovie; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
939 while (true) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
940 { |
2125 | 941 if ( pSmackerMovie->NewPalette ) |
0 | 942 { |
2125 | 943 SmackBufferNewPalette(pSmackerBuffer, pSmackerMovie->Palette, (pSmackerMovie->PalType)); |
0 | 944 SmackColorRemapWithTrans( |
2125 | 945 pSmackerMovie, |
946 pSmackerBuffer->Palette, | |
947 pSmackerBuffer->MaxPalColors, | |
948 pSmackerBuffer->PalType, | |
0 | 949 1000); |
950 } | |
2069 | 951 SmackDoFrame(pSmackerMovie); |
952 if ( pSmackerMovie->FrameNum != pSmackerMovie->Frames - 1 || bLoopPlaying ) | |
953 SmackNextFrame(pSmackerMovie); | |
0 | 954 else |
955 Unload(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
956 |
0 | 957 pRenderer->EndScene(); |
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 |
961 | |
962 | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
963 /* |
0 | 964 //----- (004BF141) -------------------------------------------------------- |
965 _BINK *VideoPlayer::OpenBink(const char *pName) | |
966 { | |
967 //VideoPlayer *v2; // esi@1 | |
968 signed int v3; // edi@1 | |
969 int v4; // ebx@2 | |
970 signed int v5; // edi@5 | |
971 int v6; // ebx@6 | |
972 HANDLE v8; // [sp-8h] [bp-18h]@10 | |
973 unsigned int v9; // [sp-4h] [bp-14h]@10 | |
974 | |
975 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
976 if (!_stricmp(pName, pMightVideoHeaders[i].pVideoName)) |
0 | 977 { |
978 SetFilePointer(hMightVid, pMightVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); | |
979 | |
980 if (uBinkVersion < 0x0003000000000000) | |
981 return BinkOpen(hMightVid, 0x8800000); | |
982 else | |
983 return BinkOpen(hMightVid, 0x82000000); | |
984 } | |
985 | |
986 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
987 if (!_stricmp(pName, pMagicVideoHeaders[i].pVideoName)) |
0 | 988 { |
989 SetFilePointer(hMagicVid, pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); | |
990 | |
2125 | 991 if (uBinkVersion < 0x0003000000000000) |
992 return BinkOpen(hMagicVid, BINKNOTHREADEDIO | BINKFILEHANDLE);//0x8800000); | |
993 else | |
994 return BinkOpen(hMagicVid, BINKIOPROCESSOR | BINKCOPYALL);//0x82000000); | |
0 | 995 } |
996 | |
997 return nullptr; | |
998 } | |
999 //----- (004BF1E6) -------------------------------------------------------- | |
1000 _SMACK *VideoPlayer::OpenSmack(const char *pFilename) | |
1001 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1002 if ( this->uNumMightVideoHeaders ) |
0 | 1003 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1004 for ( uint i = 0; i < (signed int)this->uNumMightVideoHeaders; ++i) |
0 | 1005 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1006 if ( !_stricmp(this->pMightVideoHeaders[i].pVideoName, pFilename) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1007 { |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1008 SetFilePointer(this->hMightVid, this->pMightVideoHeaders[i].uFileOffset, 0, 0); |
2082 | 1009 return SmackOpen(this->hMightVid, SMACKTRACK2|SMACKTRACK1|SMACKFILEHANDLE|SMACKLOADEXTRA|SMACKNEEDVOLUME, -1);//0x7140, |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1010 } |
0 | 1011 } |
1012 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1013 if ( this->uNumMagicVideoHeaders ) |
0 | 1014 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1015 for ( uint i = 0; i < (signed int)this->uNumMagicVideoHeaders; ++i ) |
0 | 1016 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1017 if ( !_stricmp(this->pMagicVideoHeaders[i].pVideoName, pFilename) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1018 { |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1019 SetFilePointer(this->hMagicVid, this->pMagicVideoHeaders[i].uFileOffset, 0, 0); |
2079 | 1020 return SmackOpen(this->hMagicVid, SMACKTRACK2|SMACKTRACK1|SMACKFILEHANDLE|SMACKLOADEXTRA|SMACKNEEDVOLUME, -1); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1021 } |
0 | 1022 } |
1023 } | |
1024 return 0; | |
1025 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1026 */ |
0 | 1027 //----- (004BF28F) -------------------------------------------------------- |
898 | 1028 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) |
0 | 1029 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1030 if (!this->bBufferLoaded) |
0 | 1031 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1032 //Prepare(); |
2218 | 1033 pEventTimer->Pause(); |
1034 if (pAudioPlayer->hAILRedbook) | |
1035 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1036 |
2218 | 1037 bStopBeforeSchedule = false; |
1038 bBufferLoaded = 1; | |
1039 /* | |
1040 pSmackerMovie = 0; | |
1041 pSmackerBuffer = 0; | |
1042 pBinkMovie = 0; | |
1043 pBinkBuffer = 0; | |
1044 */ | |
1045 bPlayingMovie = false; | |
1046 bFirstFrame = false; | |
1047 bUsingSmackerMMX = SmackUseMMX(1); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1048 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1049 this->bLoopPlaying = a3_1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1050 if ( LOBYTE(this->field_104) == 1 ) |
0 | 1051 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1052 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); |
0 | 1053 return; |
1054 } | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1055 |
2218 | 1056 LoadMovie(pMovieName); |
1057 /* | |
1058 this->pSmackerMovie = OpenSmack(Str2); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1059 if ( !this->pSmackerMovie ) |
0 | 1060 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1061 this->Unload(); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
1062 sprintf(pTmpBuf.data(), "Can't load %s", &Str2); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1063 MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937", 0); |
898 | 1064 return; |
0 | 1065 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1066 */ |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1067 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1068 /* |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1069 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
|
1070 if ( this->pSmackerBuffer ) |
0 | 1071 { |
1072 pRenderer->BeginScene(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1073 SmackToBuffer(this->pSmackerMovie, 8, 8, 2 * pRenderer->uTargetSurfacePitch, pRenderer->field_14, pRenderer->pTargetSurface, SmackCheckSurfaceFromat()); |
0 | 1074 pRenderer->EndScene(); |
1075 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1076 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
|
1077 */ |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1078 |
0 | 1079 } |
1080 } | |
1081 | |
1082 //----- (004BF3F9) -------------------------------------------------------- | |
1083 bool VideoPlayer::AnyMovieLoaded() | |
1084 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1085 return pMovie;// pSmackerMovie || pBinkMovie; |
0 | 1086 } |
1087 | |
1088 //----- (004BF411) -------------------------------------------------------- | |
898 | 1089 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) |
0 | 1090 { |
1091 unsigned int v10; // eax@11 | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1092 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1093 if (!this->bBufferLoaded) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1094 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1095 //Prepare(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1096 pEventTimer->Pause(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1097 if (pAudioPlayer->hAILRedbook) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1098 AIL_redbook_pause(pAudioPlayer->hAILRedbook); |
0 | 1099 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1100 bStopBeforeSchedule = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1101 bBufferLoaded = 1; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1102 /* |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1103 pSmackerMovie = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1104 pSmackerBuffer = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1105 pBinkMovie = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1106 pBinkBuffer = 0; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1107 */ |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1108 bPlayingMovie = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1109 bFirstFrame = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1110 bUsingSmackerMMX = SmackUseMMX(1); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1111 this->bLoopPlaying = bLoop; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1112 LoadMovie(pFilename); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1113 return; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1114 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1115 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1116 /* |
0 | 1117 sprintf(pVideoName, "%s.bik", pFilename); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1118 this->pBinkMovie = OpenBink(pVideoName); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1119 if ( this->pBinkMovie ) |
0 | 1120 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1121 this->uMovieFormat = 2; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1122 strcpy(this->pCurrentMovieName, pFilename); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1123 pBinkMovie = this->pBinkMovie; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1124 this->uMovieFormatSwapped = 1; |
0 | 1125 if ( pBinkMovie ) |
1802 | 1126 this->pBinkBuffer = CreateBinkBuffer(pBinkMovie->uWidth, pBinkMovie->uHeight, 0); |
0 | 1127 } |
1128 else | |
1129 { | |
1130 Unload(); | |
898 | 1131 sprintfex(pVideoName, "%s.smk", pFilename); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1132 this->pSmackerMovie = OpenSmack(pVideoName); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1133 if ( !this->pSmackerMovie ) |
0 | 1134 { |
1135 Unload(); | |
1136 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename); | |
1137 MessageBoxA(0, pVideoName, "Smacker Error", 0); | |
1138 return; | |
1139 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1140 this->uMovieFormat = 1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1141 strcpy(this->pCurrentMovieName, pFilename); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1142 this->uMovieFormatSwapped = 2; |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1143 this->pSomeSmackerBuffer = (char *)malloc(this->pSmackerMovie->Width * this->pSmackerMovie->Height); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1144 if ( !this->pSomeSmackerBuffer ) |
0 | 1145 { |
1146 Unload(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1147 sprintf(pVideoName, "Can't allocate memory for buffer"); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1148 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
0 | 1149 return; |
1150 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1151 SmackToBuffer(this->pSmackerMovie, 0, 0, this->pSmackerMovie->Width, this->pSmackerMovie->Height, this->pSomeSmackerBuffer, 0); |
1035 | 1152 |
1153 v10 = SmackCheckSurfaceFromat(); | |
0 | 1154 if ( a4 ) |
1155 { | |
1035 | 1156 v10 |= SMACKBLIT2X; |
1157 | |
1158 if (uCPUSpeed >= 165 ) | |
1159 v10 |= SMACKBLIT2XSMOOTHING; | |
0 | 1160 else |
1035 | 1161 Log::Warning(L"Smacker seems to use lower resolution because it thinks CPU is slow"); |
0 | 1162 } |
1035 | 1163 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1164 this->pSmackMovieBlit = SmackBlitOpen(v10); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1165 if ( !this->pSmackMovieBlit ) |
0 | 1166 { |
1167 Unload(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1168 sprintf(pVideoName, "Failed to open Blit API"); |
0 | 1169 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1170 return; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1171 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1172 }*/ |
0 | 1173 } |
1174 } | |
1175 | |
1176 | |
1177 //----- (004BF5B2) -------------------------------------------------------- | |
1178 void VideoPlayer::_4BF5B2() | |
1179 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1180 //__debugbreak(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1181 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1182 /*if ( this->uMovieFormat == 2 ) |
0 | 1183 { |
1184 BinkGoto(pBinkMovie, 1, 0); | |
1185 BinkDoFrame(pBinkMovie); | |
1186 BinkNextFrame(pBinkMovie); | |
1187 } | |
1188 else | |
1189 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1190 if ( this->uMovieFormat != 1 ) |
0 | 1191 return; |
1192 SmackGoto(pSmackerMovie, 1); | |
1193 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1194 { | |
1195 SmackDoFrame(pSmackerMovie); | |
1196 SmackNextFrame(pSmackerMovie); | |
1197 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1198 }*/ |
0 | 1199 pMouse->_469E24(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1200 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pMovie)//!this->pSmackerMovie ) |
0 | 1201 { |
2218 | 1202 bGameoverLoop = true; |
1919 | 1203 HouseDialogPressCloseBtn(); |
336 | 1204 window_SpeakInHouse->Release(); |
2218 | 1205 pParty->uFlags &= 0xFFFFFFFD; |
481 | 1206 if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) |
0 | 1207 { |
388 | 1208 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
|
1209 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0); |
2218 | 1210 window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1, 0x31, "", 0); |
1211 window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2, 0x32, "", 0); | |
1212 window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3, 0x33, "", 0); | |
1213 window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4, 0x34, "", 0); | |
0 | 1214 } |
1215 bGameoverLoop = 0; | |
1216 } | |
1217 } | |
1218 | |
1219 //----- (004BF73A) -------------------------------------------------------- | |
898 | 1220 void VideoPlayer::SelectMovieType() |
0 | 1221 { |
1222 char Source[32]; // [sp+Ch] [bp-40h]@1 | |
1223 | |
1224 strcpy(Source, this->pCurrentMovieName); | |
1225 Unload(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1226 if ( this->uMovieFormatSwapped == 1 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1227 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1228 else if ( this->uMovieFormatSwapped == 2 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1229 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); |
0 | 1230 else |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1231 __debugbreak(); |
0 | 1232 } |
1233 | |
1234 //----- (004BF8F6) -------------------------------------------------------- | |
1235 void VideoPlayer::PlayDeathMovie() | |
1236 { | |
1237 bStopBeforeSchedule = 0; | |
165 | 1238 pResetflag = 0; |
1397 | 1239 PlayFullscreenMovie(MOVIE_Death, true); |
1240 //pGame->pCShow->PlayMovie(MOVIE_Death, 1); | |
1262 | 1241 } |
1242 | |
1243 //----- (004BE6F5) -------------------------------------------------------- | |
1244 VideoPlayer::VideoPlayer() : | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1245 bBufferLoaded(0), |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1246 //pBinkMovie(nullptr), pBinkBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1247 //pSmackerMovie(nullptr), pSmackerBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1248 pSmackMovieBlit(nullptr) |
1262 | 1249 { |
1250 //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame); | |
1251 bStopBeforeSchedule = false; | |
1252 pResetflag = 0; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1253 pPlayer = new MultimediaPlayer(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1254 pPlayer->Initialize(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1255 pMovie = nullptr; |
1262 | 1256 //pBinkMovie = nullptr; |
1257 } | |
2134 | 1258 |
1259 bool MultimediaPlayer::libavcodec_initialized = false; | |
1260 | |
1261 void MultimediaPlayer::Logger(void *, int, const char *format, va_list args) | |
1262 { | |
2218 | 1263 char msg[1024]; |
1264 vsprintf(msg, format, args); | |
2134 | 1265 |
2218 | 1266 DWORD w; |
1267 WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), msg, lstrlenA(msg), &w, nullptr); | |
2134 | 1268 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1269 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1270 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
|
1271 { |
2218 | 1272 HANDLE stream = (HANDLE)opaque; |
1273 //int numBytes = stream->read((char*)buf, buf_size); | |
1274 int numBytes; | |
1275 ReadFile(stream, (char *)buf, buf_size, (LPDWORD)&numBytes, NULL); | |
1276 return numBytes; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1277 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1278 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1279 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
|
1280 { |
2218 | 1281 if (whence == AVSEEK_SIZE) |
1282 return pVideoPlayer->uSize; | |
1283 HANDLE h = (HANDLE)opaque; | |
1284 LARGE_INTEGER li; | |
1285 li.QuadPart = offset; | |
1286 | |
1287 if (!SetFilePointerEx(h, li, (PLARGE_INTEGER)&li, FILE_BEGIN)) | |
1288 return -1; | |
1289 return li.QuadPart; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1290 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1291 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1292 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
|
1293 { |
2218 | 1294 char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2 |
1295 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
|
1296 |
2218 | 1297 sprintf(pVideoNameBik, "%s.bik", pFilename); |
1298 sprintf(pVideoNameSmk, "%s.smk", pFilename); | |
1299 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
1300 { | |
1301 //no BIK in MightVid | |
1302 /* | |
1303 if (!_stricmp(pVideoNameBik, pMightVideoHeaders[i].pVideoName)) | |
1304 { | |
1305 hVidFile = hMightVid; | |
1306 uOffset = pMightVideoHeaders[i].uFileOffset; | |
1307 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
1308 this->uMovieFormat = 2; | |
1309 this->uMovieFormatSwapped = 1; | |
1310 } | |
1311 */ | |
1312 if (!_stricmp(pVideoNameSmk, pMightVideoHeaders[i].pVideoName)) | |
1313 { | |
1314 hVidFile = hMightVid; | |
1315 uOffset = pMightVideoHeaders[i].uFileOffset; | |
1316 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
1317 this->uMovieFormat = 1; | |
1318 this->uMovieFormatSwapped = 2; | |
1319 } | |
1320 } | |
1321 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
1322 { | |
1323 if (!_stricmp(pVideoNameBik, pMagicVideoHeaders[i].pVideoName)) | |
1324 { | |
1325 hVidFile = hMagicVid; | |
1326 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
1327 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
1328 this->uMovieFormat = 2; | |
1329 this->uMovieFormatSwapped = 1; | |
1330 } | |
1331 if (!_stricmp(pVideoNameSmk, pMagicVideoHeaders[i].pVideoName)) | |
1332 { | |
1333 hVidFile = hMagicVid; | |
1334 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
1335 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
1336 this->uMovieFormat = 1; | |
1337 this->uMovieFormatSwapped = 2; | |
1338 } | |
1339 } | |
1340 if (!hVidFile) | |
1341 { | |
1342 Unload(); | |
1343 MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0); | |
1344 return; | |
1345 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1346 |
2218 | 1347 SetFilePointer(hVidFile, uOffset, 0, FILE_BEGIN); |
1348 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
|
1349 |
2218 | 1350 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
1351 RECT rc_client; | |
1352 GetClientRect(hwnd, &rc_client); | |
1353 int client_width = rc_client.right - rc_client.left, | |
1354 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
|
1355 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1356 |
2218 | 1357 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
|
1358 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1359 } |