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