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