Mercurial > mm7
annotate VideoPlayer.cpp @ 1805:830f196a69ea
WinXP fix
author | Nomad |
---|---|
date | Mon, 07 Oct 2013 13:00:53 +0200 |
parents | 633f81bb3ae7 |
children | 140ca8123384 |
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" | |
19 #include "Time.h" | |
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 | |
120 auto 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 | |
164 auto 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(); | |
1397 | 312 PlayFullscreenMovie(MOVIE_3DOLogo, true); |
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; | |
365 if ( !(dword_6BE364_game_settings_1 & 0x44) ) | |
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); | |
461 if ( a2.dwRGBBitCount != 8 ) | |
462 { | |
463 if ( a2.dwRBitMask == 0xF800 ) | |
464 { | |
465 if ( a2.dwGBitMask == 0x7E0 && a2.dwBBitMask == 0x1F ) | |
1035 | 466 return SMACKBUFFER565; |
0 | 467 } |
468 else | |
469 { | |
470 if ( a2.dwRBitMask == 0x7C00 | |
471 && a2.dwGBitMask == 0x3E0 | |
472 && a2.dwBBitMask == 0x1F ) | |
1035 | 473 return SMACKBUFFER555; |
0 | 474 } |
475 MessageBoxA(0, "Unsupported pixel format.", "Smacker Error", 0); | |
476 } | |
477 return 0; | |
478 } | |
479 | |
480 //----- (004BE9D8) -------------------------------------------------------- | |
1802 | 481 void VideoPlayer::Initialize(OSWindow *target_window) |
0 | 482 { |
483 DWORD NumberOfBytesRead; // [sp+10h] [bp-4h]@9 | |
484 | |
1802 | 485 window = target_window; |
486 | |
0 | 487 uint uBinkVersionMajor = -1, |
488 uBinkVersionMinor = -1; | |
489 GetDllVersion(L"BINKW32.DLL", &uBinkVersionMajor, &uBinkVersionMinor); | |
490 uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor; | |
491 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
492 strcpy(pTmpBuf.data(), "anims\\might7.vid"); |
0 | 493 hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0); |
494 if ( hMightVid == INVALID_HANDLE_VALUE ) | |
495 { | |
1217 | 496 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
|
497 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 498 return; |
499 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
500 strcpy(pTmpBuf.data(), "anims\\magic7.vid"); |
0 | 501 hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0); |
502 if ( hMagicVid == INVALID_HANDLE_VALUE ) | |
503 { | |
504 if ( !bCanLoadFromCD ) | |
505 { | |
1217 | 506 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
|
507 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 508 return; |
509 } | |
1217 | 510 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
|
511 hMagicVid = CreateFileA(pTmpBuf2.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0); |
0 | 512 if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE ) |
513 { | |
1217 | 514 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
|
515 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 516 return; |
517 } | |
518 } | |
519 ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0); | |
520 ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0); | |
521 pMagicVideoHeaders = 0; | |
522 pMightVideoHeaders = 0; | |
1583 | 523 pMightVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMightVideoHeaders + 2); |
524 pMagicVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMagicVideoHeaders + 2); | |
0 | 525 ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0); |
526 ReadFile(hMagicVid, pMagicVideoHeaders, 44 * uNumMagicVideoHeaders, &NumberOfBytesRead, 0); | |
527 } | |
528 | |
529 //----- (004BEB41) -------------------------------------------------------- | |
530 void VideoPlayer::Prepare() | |
531 { | |
532 pEventTimer->Pause(); | |
533 if ( pAudioPlayer->hAILRedbook ) | |
534 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
1802 | 535 |
536 bStopBeforeSchedule = false; | |
537 field_54 = 1; | |
538 pSmackerMovie = 0; | |
539 pSmackerBuffer = 0; | |
540 pBinkMovie = 0; | |
541 pBinkBuffer = 0; | |
542 bPlayingMovie = false; | |
543 bFirstFrame = false; | |
544 bUsingSmackerMMX = SmackUseMMX(1); | |
0 | 545 BinkSetSoundSystem(BinkOpenMiles, pAudioPlayer->hDigDriver); |
1802 | 546 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5) |
547 uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer4); | |
0 | 548 else |
1802 | 549 uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer2); |
0 | 550 } |
551 | |
552 | |
553 //----- (004BEBD7) -------------------------------------------------------- | |
554 void VideoPlayer::Unload() | |
555 { | |
1802 | 556 //_BINK *pBinkMovie; // eax@1 |
557 //_BINKBUF *pBinkBuffer; // eax@3 | |
558 //_SMACK *pSmackerMovie; // eax@5 | |
0 | 559 |
560 if ( pBinkMovie ) | |
561 { | |
562 BinkPause(pBinkMovie, 1); | |
563 Sleep(300); | |
1802 | 564 BinkClose(pBinkMovie); |
565 pBinkMovie = 0; | |
0 | 566 } |
1802 | 567 |
0 | 568 if ( pBinkBuffer ) |
569 { | |
570 pBinkBuffer->pTargetDDrawSurface->Release(); | |
1802 | 571 pBinkBuffer->pTargetDDrawSurface = 0; |
572 free(pBinkBuffer); | |
573 pBinkBuffer = 0; | |
0 | 574 } |
1802 | 575 |
0 | 576 if ( pSmackerMovie ) |
577 { | |
578 SmackSoundOnOff(pSmackerMovie, 0); | |
1802 | 579 SmackClose(pSmackerMovie); |
580 pSmackerMovie = 0; | |
0 | 581 } |
1802 | 582 if ( pSmackerBuffer ) |
0 | 583 { |
1802 | 584 SmackBufferClose(pSmackerBuffer); |
585 pSmackerBuffer = 0; | |
0 | 586 } |
1802 | 587 if ( pSmackMovieBlit ) |
0 | 588 { |
1802 | 589 SmackBlitClose(pSmackMovieBlit); |
590 pSmackMovieBlit = 0; | |
0 | 591 } |
1802 | 592 field_54 = 0; |
593 uMovieFormat = 0; | |
594 dword_0000A0 = 0; | |
595 memset(pCurrentMovieName, 0, 0x40); | |
0 | 596 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop ) |
597 AIL_redbook_resume(pAudioPlayer->hAILRedbook); | |
598 pEventTimer->Resume(); | |
599 } | |
600 | |
601 //----- (004BECD5) -------------------------------------------------------- | |
602 void VideoPlayer::FastForwardToFrame(unsigned int uDstFrameNum) | |
603 { | |
604 VideoPlayer *v2; // esi@1 | |
605 unsigned int v3; // eax@1 | |
606 | |
607 v2 = this; | |
608 v3 = this->uMovieFormat; | |
609 if ( v3 == 2 ) | |
610 { | |
611 if (uDstFrameNum) | |
612 { | |
613 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame : | |
614 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame : | |
615 nullptr; | |
616 while (*pCurrentFrame < uDstFrameNum) | |
617 { | |
618 BinkDoFrame(pBinkMovie); | |
619 BinkNextFrame(pBinkMovie); | |
620 } | |
621 } | |
622 } | |
623 else | |
624 { | |
625 if ( v3 != 1 ) | |
626 return; | |
627 SmackSoundOnOff(this->pSmackerMovie, 0); | |
628 if (uDstFrameNum) | |
629 { | |
630 while ( v2->pSmackerMovie->FrameNum < uDstFrameNum) | |
631 { | |
632 SmackDoFrame(v2->pSmackerMovie); | |
633 SmackNextFrame(v2->pSmackerMovie); | |
634 } | |
635 } | |
636 } | |
637 Unload(); | |
638 } | |
639 | |
640 | |
641 //----- (004BED4F) -------------------------------------------------------- | |
1802 | 642 void VideoPlayer::BinkDrawFrame(int a3, int a4) |
0 | 643 { |
644 //VideoPlayer *v4; // esi@1 | |
645 _BINKBUF *v5; // eax@5 | |
646 LONG v6; // edx@6 | |
647 int v7; // ecx@6 | |
648 LONG v8; // edx@6 | |
649 struct tagRECT a3a; // [sp+8h] [bp-20h]@10 | |
650 struct tagRECT a1; // [sp+18h] [bp-10h]@6 | |
651 | |
652 //v4 = this; | |
653 if ( this->pBinkMovie && this->pBinkBuffer ) | |
654 { | |
655 BinkDoFrame(pBinkMovie); | |
656 BinkGetRects(pBinkMovie, pBinkBuffer->uBinkDDSurfaceType); | |
657 if ( BinkLockBuffer(pBinkBuffer) ) | |
658 { | |
659 BinkCopyToBuffer(pBinkMovie, pBinkBuffer->pDDrawSurfaceData, pBinkBuffer->uDDrawSurfacePitch, pBinkBuffer->uHeight, | |
660 0, 0, pBinkBuffer->uBinkDDSurfaceType); | |
661 BinkUnlockBuffer(pBinkBuffer); | |
662 } | |
663 v5 = pBinkBuffer; | |
664 if ( pRenderer->bWindowMode ) | |
665 { | |
666 v6 = v5->uRectX; | |
667 a1.left = v6; | |
668 a1.top = v5->uRectY; | |
669 v7 = v6 + v5->uWidth; | |
670 a1.right = v6 + v5->uWidth; | |
671 v8 = a1.top + v5->uHeight; | |
672 } | |
673 else | |
674 { | |
675 a1.left = 0; | |
676 a1.top = 0; | |
677 v7 = v5->uWidth; | |
678 a1.right = v5->uWidth; | |
679 v8 = v5->uHeight; | |
680 } | |
681 a1.bottom = v8; | |
682 if ( a4 ) | |
683 { | |
684 a1.right = v5->uWidth + v7; | |
685 a1.bottom = v5->uHeight + v8; | |
686 } | |
687 a3a.left = 0; | |
688 a3a.top = 0; | |
689 a3a.right = v5->uWidth; | |
690 a3a.bottom = v5->uHeight; | |
691 pRenderer->BltToFront(&a1, v5->pTargetDDrawSurface, &a3a, 0x1000000u); | |
692 | |
693 | |
694 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame : | |
695 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame: | |
696 nullptr; | |
697 int *pNumFrames = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uNumFrames : | |
698 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uNumFrames : | |
699 nullptr; | |
700 | |
701 if (*pCurrentFrame != *pNumFrames - 1 || bLoopPlaying) | |
702 BinkNextFrame(pBinkMovie); | |
703 else | |
704 Unload(); | |
705 } | |
706 } | |
707 | |
708 | |
709 | |
710 //----- (004BEE6B) -------------------------------------------------------- | |
1802 | 711 void VideoPlayer::SmackDrawFrame(int a3, int a4) |
0 | 712 { |
713 VideoPlayer *v4; // esi@1 | |
714 _SMACK *v5; // eax@3 | |
715 unsigned int v6; // eax@5 | |
716 char v7; // zf@5 | |
717 int v8; // eax@11 | |
718 _SMACK *v9; // eax@13 | |
719 _SMACK *v10; // eax@16 | |
720 _SMACK *v11; // eax@20 | |
721 unsigned int v12; // [sp-1Ch] [bp-34h]@7 | |
722 LONG v13; // [sp-18h] [bp-30h]@7 | |
723 LONG v14; // [sp-14h] [bp-2Ch]@7 | |
724 signed int v15; // [sp-10h] [bp-28h]@7 | |
725 signed int v16; // [sp-Ch] [bp-24h]@7 | |
726 signed int v17; // [sp-8h] [bp-20h]@7 | |
727 struct tagPOINT Point; // [sp+8h] [bp-10h]@7 | |
728 unsigned short *pOutSurface; // [sp+10h] [bp-8h]@5 | |
729 unsigned int uPixelsPerRow; // [sp+14h] [bp-4h]@5 | |
730 | |
731 v4 = this; | |
1802 | 732 if ( !pRenderer->bWindowMode || window->Focused()) |
0 | 733 { |
734 v5 = v4->pSmackerMovie; | |
735 if ( v5->NewPalette ) | |
736 SmackBlitSetPalette(v4->pSmackMovieBlit, v5->Palette, v5->PalType); | |
737 SmackDoFrame(v4->pSmackerMovie); | |
738 pRenderer->LockFrontBuffer((void **)&pOutSurface, &uPixelsPerRow); | |
739 v6 = 2 * uPixelsPerRow; | |
740 v7 = v4->bFirstFrame == 0; | |
741 uPixelsPerRow *= 2; | |
742 if ( !v7 ) | |
743 { | |
744 if ( pRenderer->bWindowMode ) | |
745 { | |
746 Point.y = 0; | |
747 Point.x = 0; | |
1802 | 748 ClientToScreen(window->GetApiHandle(), &Point); |
0 | 749 v17 = -1; |
750 v16 = 480; | |
751 v15 = 640; | |
752 v14 = Point.y; | |
753 v13 = Point.x; | |
754 v12 = uPixelsPerRow; | |
755 } | |
756 else | |
757 { | |
758 v17 = -1; | |
759 v16 = 480; | |
760 v15 = 640; | |
761 v14 = 0; | |
762 v13 = 0; | |
763 v12 = v6; | |
764 } | |
765 SmackBlitClear(v4->pSmackMovieBlit, pOutSurface, v12, v13, v14, v15, v16, v17); | |
766 v4->bFirstFrame = 0; | |
767 } | |
768 pRenderer->RestoreFrontBuffer(); | |
769 if ( pRenderer->bWindowMode ) | |
770 { | |
771 Point.y = 0; | |
772 Point.x = 0; | |
1802 | 773 ClientToScreen(window->GetApiHandle(), &Point); |
0 | 774 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); |
775 if ( a4 ) | |
776 { | |
777 while ( v8 ) | |
778 { | |
779 v9 = v4->pSmackerMovie; | |
780 SmackBlit( | |
781 v4->pSmackMovieBlit, | |
782 pOutSurface, | |
783 uPixelsPerRow, | |
784 v9->LastRectx + Point.x / 2, | |
785 a3 + v9->LastRecty + Point.y / 2, | |
786 v4->pSomeSmackerBuffer, | |
787 v9->Width, | |
788 v9->LastRectx, | |
789 v9->LastRecty, | |
790 v9->LastRectw, | |
791 v9->LastRecth); | |
792 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); | |
793 } | |
794 } | |
795 else | |
796 { | |
797 while ( v8 ) | |
798 { | |
799 v10 = v4->pSmackerMovie; | |
800 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, Point.x + v10->LastRectx, a3 + Point.y + v10->LastRecty, | |
801 v4->pSomeSmackerBuffer, v10->Width, v10->LastRectx, v10->LastRecty, v10->LastRectw, v10->LastRecth); | |
802 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); | |
803 } | |
804 } | |
805 } | |
806 else | |
807 { | |
808 while ( SmackToBufferRect(v4->pSmackerMovie, 0) ) | |
809 { | |
810 v11 = v4->pSmackerMovie; | |
811 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, v11->LastRectx, a3 + v11->LastRecty, v4->pSomeSmackerBuffer, | |
812 v11->Width, v11->LastRectx, v11->LastRecty, v11->LastRectw, v11->LastRecth); | |
813 } | |
814 } | |
815 pRenderer->UnlockFrontBuffer(); | |
816 if ( v4->pSmackerMovie->FrameNum != v4->pSmackerMovie->Frames - 1 || v4->bLoopPlaying ) | |
817 SmackNextFrame(v4->pSmackerMovie); | |
818 else | |
819 Unload(); | |
820 } | |
821 } | |
1035 | 822 |
1802 | 823 void VideoPlayer::_inlined_in_463149() |
824 { | |
825 if ( pSmackerMovie && !SmackWait(pSmackerMovie) ) | |
826 { | |
827 pRenderer->BeginScene(); | |
828 pMouse->DrawCursorToTarget(); | |
829 SmackUpdatePalette(); | |
830 pMouse->_469EA4(); | |
831 pRenderer->EndScene(); | |
832 } | |
833 else if ( pBinkMovie && !BinkWait(pBinkMovie) ) | |
834 { | |
835 pRenderer->BeginScene(); | |
836 pMouse->DrawCursorToTarget(); | |
837 BinkUpdatePalette(); | |
838 pMouse->_469EA4(); | |
839 pRenderer->EndScene(); | |
840 } | |
841 } | |
0 | 842 |
843 //----- (004BF08B) -------------------------------------------------------- | |
1802 | 844 void VideoPlayer::SmackUpdatePalette() |
0 | 845 { |
846 VideoPlayer *v2; // esi@1 | |
847 unsigned __int16 *v3; // ebx@1 | |
848 unsigned int v4; // edi@1 | |
849 unsigned int v5; // eax@1 | |
850 _SMACK *v6; // eax@1 | |
851 | |
852 v2 = this; | |
853 pRenderer->BeginScene(); | |
854 v3 = pRenderer->pTargetSurface; | |
855 v4 = pRenderer->uTargetSurfacePitch; | |
856 v5 = SmackCheckSurfaceFromat(); | |
857 SmackToBuffer(v2->pSmackerMovie, 8, 8, 2 * v4, pRenderer->field_14, v3, v5); | |
858 v6 = v2->pSmackerMovie; | |
859 if ( v6->NewPalette ) | |
860 { | |
861 SmackBufferNewPalette((long)pSmackerBuffer, (long)v6->Palette, LOWORD(v6->PalType)); | |
862 SmackColorRemapWithTrans( | |
863 (long)pSmackerMovie, | |
864 (long)pSmackerBuffer->Palette, | |
865 (long)pSmackerBuffer->MaxPalColors, | |
866 (long)pSmackerBuffer->PalType, | |
867 1000); | |
868 } | |
869 SmackDoFrame(v2->pSmackerMovie); | |
870 if ( v2->pSmackerMovie->FrameNum != v2->pSmackerMovie->Frames - 1 || v2->bLoopPlaying ) | |
871 SmackNextFrame(v2->pSmackerMovie); | |
872 else | |
873 Unload(); | |
874 pRenderer->EndScene(); | |
875 } | |
876 | |
877 | |
878 | |
879 | |
880 | |
881 //----- (004BF141) -------------------------------------------------------- | |
882 _BINK *VideoPlayer::OpenBink(const char *pName) | |
883 { | |
884 //VideoPlayer *v2; // esi@1 | |
885 signed int v3; // edi@1 | |
886 int v4; // ebx@2 | |
887 signed int v5; // edi@5 | |
888 int v6; // ebx@6 | |
889 HANDLE v8; // [sp-8h] [bp-18h]@10 | |
890 unsigned int v9; // [sp-4h] [bp-14h]@10 | |
891 | |
892 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
893 if (!_stricmp(pName, pMightVideoHeaders[i].pVideoName)) |
0 | 894 { |
895 SetFilePointer(hMightVid, pMightVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); | |
896 | |
897 if (uBinkVersion < 0x0003000000000000) | |
898 return BinkOpen(hMightVid, 0x8800000); | |
899 else | |
900 return BinkOpen(hMightVid, 0x82000000); | |
901 } | |
902 | |
903 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
904 if (!_stricmp(pName, pMagicVideoHeaders[i].pVideoName)) |
0 | 905 { |
906 SetFilePointer(hMagicVid, pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); | |
907 | |
908 if (uBinkVersion < 0x0003000000000000) | |
909 return BinkOpen(hMagicVid, 0x8800000); | |
910 else | |
911 return BinkOpen(hMagicVid, 0x82000000); | |
912 } | |
913 | |
914 return nullptr; | |
915 } | |
916 //----- (004BF1E6) -------------------------------------------------------- | |
917 _SMACK *VideoPlayer::OpenSmack(const char *pFilename) | |
918 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
919 if ( this->uNumMightVideoHeaders ) |
0 | 920 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
921 for ( uint i = 0; i < (signed int)this->uNumMightVideoHeaders; ++i) |
0 | 922 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
923 if ( !_stricmp(this->pMightVideoHeaders[i].pVideoName, pFilename) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
924 { |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
925 SetFilePointer(this->hMightVid, this->pMightVideoHeaders[i].uFileOffset, 0, 0); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
926 return SmackOpen(this->hMightVid, 0x7140, -1); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
927 } |
0 | 928 } |
929 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
930 if ( this->uNumMagicVideoHeaders ) |
0 | 931 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
932 for ( uint i = 0; i < (signed int)this->uNumMagicVideoHeaders; ++i ) |
0 | 933 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
934 if ( !_stricmp(this->pMagicVideoHeaders[i].pVideoName, pFilename) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
935 { |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
936 SetFilePointer(this->hMagicVid, this->pMagicVideoHeaders[i].uFileOffset, 0, 0); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
937 return SmackOpen(this->hMagicVid, 0x7140, -1); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
938 } |
0 | 939 } |
940 } | |
941 return 0; | |
942 } | |
943 | |
944 //----- (004BF28F) -------------------------------------------------------- | |
898 | 945 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) |
0 | 946 { |
947 if ( !this->field_54 ) | |
948 { | |
949 Prepare(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
950 this->bLoopPlaying = a3_1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
951 if ( LOBYTE(this->field_104) == 1 ) |
0 | 952 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
953 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); |
0 | 954 return; |
955 } | |
898 | 956 sprintfex(Str2, "%s.smk", pMovieName); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
957 this->pSmackerMovie = OpenSmack(Str2); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
958 if ( !this->pSmackerMovie ) |
0 | 959 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
960 this->Unload(); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
961 sprintf(pTmpBuf.data(), "Can't load %s", &Str2); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
962 MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937", 0); |
898 | 963 return; |
0 | 964 } |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
965 this->uMovieFormat = 1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
966 strcpy(this->pCurrentMovieName, (const char *)pMovieName); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
967 this->dword_0000A0 = 1; |
1802 | 968 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
|
969 if ( this->pSmackerBuffer ) |
0 | 970 { |
971 pRenderer->BeginScene(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
972 SmackToBuffer(this->pSmackerMovie, 8, 8, 2 * pRenderer->uTargetSurfacePitch, pRenderer->field_14, pRenderer->pTargetSurface, SmackCheckSurfaceFromat()); |
0 | 973 pRenderer->EndScene(); |
974 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
975 SmackVolumePan(this->pSmackerMovie, 1040384, (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0), 32767); |
0 | 976 } |
977 } | |
978 | |
979 //----- (004BF3F9) -------------------------------------------------------- | |
980 bool VideoPlayer::AnyMovieLoaded() | |
981 { | |
982 return pSmackerMovie || pBinkMovie; | |
983 } | |
984 | |
985 //----- (004BF411) -------------------------------------------------------- | |
898 | 986 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) |
0 | 987 { |
988 unsigned int v10; // eax@11 | |
989 char pVideoName[120]; // [sp+Ch] [bp-28h]@2 | |
990 | |
991 if ( !this->field_54 ) | |
992 { | |
993 Prepare(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
994 this->bLoopPlaying = bLoop; |
0 | 995 sprintf(pVideoName, "%s.bik", pFilename); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
996 this->pBinkMovie = OpenBink(pVideoName); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
997 if ( this->pBinkMovie ) |
0 | 998 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
999 this->uMovieFormat = 2; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1000 strcpy(this->pCurrentMovieName, pFilename); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1001 pBinkMovie = this->pBinkMovie; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1002 this->dword_0000A0 = 1; |
0 | 1003 if ( pBinkMovie ) |
1802 | 1004 this->pBinkBuffer = CreateBinkBuffer(pBinkMovie->uWidth, pBinkMovie->uHeight, 0); |
0 | 1005 } |
1006 else | |
1007 { | |
1008 Unload(); | |
898 | 1009 sprintfex(pVideoName, "%s.smk", pFilename); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1010 this->pSmackerMovie = OpenSmack(pVideoName); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1011 if ( !this->pSmackerMovie ) |
0 | 1012 { |
1013 Unload(); | |
1014 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename); | |
1015 MessageBoxA(0, pVideoName, "Smacker Error", 0); | |
1016 return; | |
1017 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1018 this->uMovieFormat = 1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1019 strcpy(this->pCurrentMovieName, pFilename); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1020 this->dword_0000A0 = 2; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1021 this->pSomeSmackerBuffer = (char *)malloc(this->pSmackerMovie->Width * this->pSmackerMovie->Height); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1022 if ( !this->pSomeSmackerBuffer ) |
0 | 1023 { |
1024 Unload(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1025 sprintf(pVideoName, "Can't allocate memory for buffer"); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1026 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
0 | 1027 return; |
1028 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1029 SmackToBuffer(this->pSmackerMovie, 0, 0, this->pSmackerMovie->Width, this->pSmackerMovie->Height, this->pSomeSmackerBuffer, 0); |
1035 | 1030 |
1031 v10 = SmackCheckSurfaceFromat(); | |
0 | 1032 if ( a4 ) |
1033 { | |
1035 | 1034 v10 |= SMACKBLIT2X; |
1035 | |
1036 if (uCPUSpeed >= 165 ) | |
1037 v10 |= SMACKBLIT2XSMOOTHING; | |
0 | 1038 else |
1035 | 1039 Log::Warning(L"Smacker seems to use lower resolution because it thinks CPU is slow"); |
0 | 1040 } |
1035 | 1041 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1042 this->pSmackMovieBlit = SmackBlitOpen(v10); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1043 if ( !this->pSmackMovieBlit ) |
0 | 1044 { |
1045 Unload(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1046 sprintf(pVideoName, "Failed to open Blit API"); |
0 | 1047 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1048 return; | |
1049 } | |
1050 } | |
1051 } | |
1052 } | |
1053 | |
1054 | |
1055 //----- (004BF5B2) -------------------------------------------------------- | |
1056 void VideoPlayer::_4BF5B2() | |
1057 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1058 if ( this->uMovieFormat == 2 ) |
0 | 1059 { |
1060 BinkGoto(pBinkMovie, 1, 0); | |
1061 BinkDoFrame(pBinkMovie); | |
1062 BinkNextFrame(pBinkMovie); | |
1063 } | |
1064 else | |
1065 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1066 if ( this->uMovieFormat != 1 ) |
0 | 1067 return; |
1068 SmackGoto(pSmackerMovie, 1); | |
1069 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1070 { | |
1071 SmackDoFrame(pSmackerMovie); | |
1072 SmackNextFrame(pSmackerMovie); | |
1073 } | |
1074 } | |
1075 pMouse->_469E24(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1076 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pSmackerMovie ) |
0 | 1077 { |
1078 bGameoverLoop = 1; | |
1079 sub_4BD8B5(); | |
336 | 1080 window_SpeakInHouse->Release(); |
0 | 1081 pParty->uFlags &= 0xFFFFFFFDu; |
481 | 1082 if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) |
0 | 1083 { |
388 | 1084 pAudioPlayer->PlaySound(SOUND_Invalid, 0, 0, -1, 0, 0, 0, 0); |
336 | 1085 window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0); |
832 | 1086 window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0); |
1087 window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0); | |
1088 window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0); | |
1089 window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0); | |
0 | 1090 } |
1091 bGameoverLoop = 0; | |
1092 } | |
1093 } | |
1094 | |
1095 //----- (004BF73A) -------------------------------------------------------- | |
898 | 1096 void VideoPlayer::SelectMovieType() |
0 | 1097 { |
1098 char Source[32]; // [sp+Ch] [bp-40h]@1 | |
1099 | |
1100 strcpy(Source, this->pCurrentMovieName); | |
1101 Unload(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1102 if ( this->dword_0000A0 == 1 ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1103 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1104 else if ( this->dword_0000A0 == 2 ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1105 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); |
0 | 1106 else |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1107 __debugbreak(); |
0 | 1108 } |
1109 | |
1110 //----- (004BF8F6) -------------------------------------------------------- | |
1111 void VideoPlayer::PlayDeathMovie() | |
1112 { | |
1113 bStopBeforeSchedule = 0; | |
165 | 1114 pResetflag = 0; |
1397 | 1115 PlayFullscreenMovie(MOVIE_Death, true); |
1116 //pGame->pCShow->PlayMovie(MOVIE_Death, 1); | |
1262 | 1117 } |
1118 | |
1119 //----- (004BE6F5) -------------------------------------------------------- | |
1120 VideoPlayer::VideoPlayer() : | |
1121 field_54(0), | |
1122 pBinkMovie(nullptr), pBinkBuffer(nullptr), | |
1123 pSmackerMovie(nullptr), pSmackerBuffer(nullptr), pSmackMovieBlit(nullptr) | |
1124 { | |
1125 //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame); | |
1126 bStopBeforeSchedule = false; | |
1127 pResetflag = 0; | |
1128 byte_F8BC0C = 0; | |
1129 //pBinkMovie = nullptr; | |
1130 } |