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