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