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