VOGONS


Black Fullscreen videos with dgVoodoo2 (case : Resident Evil 2)

Topic actions

  • This topic is locked. You cannot reply or edit posts.

First post, by xcomcmdr

User metadata
Rank Oldbie
Rank
Oldbie

Hello,

I have a problem :
Resident Evil 2 on some hardware displays black boxes around background objects on some screens near the end of the game
Sometimes it's even in front of the player character.

It doesn't happen on all hardware (on a eeePC with an AMD GPU it doesn't happen), but so far happens on every PC with nVidia hardware.

Now, to be able to run the game I use DDRawCompat otherwise it won't start.
On Windows 10, I have to had admin mode on top of that.
But most importantly, I tried every value possible for the "Display Driver" value (value stored inside HKLM\Software\Wow6432Node\CAPCOM\RESIDENT EVIL 2\), and 0xe (which is "Rendition V2200" in the game's CD launcher) is what I use. There's around 15 different values possible, but only a few work. And when they work, they all have the same behavior (apart from software mode, which is value 0x5 and 0x7).

But anyway, I have the dgVodooo patch for this game (applied on the French release I have).
However, videos don't show with dgVodooo, even in windowed mode.
I have managed sometimes to have the game run in a tiny window, and then the videos will display in an even smaller window. It works that way, but it's difficult to see anything.

So, bascially, I have three options :
1.Wait for dgVoodoo2 to support fullscreen (VfW ?) video playback on games such as this one. I'm not impatient, the black boxes problem isn't present for 80% of the game and it doesn't prevent the player from finishing the game.

Besides, if one enables software mode the problem goes away. But so does the smooth rendering of 3D objects from when hardware acceleration is enabled.

But I wonder if "vfW fullscreen" (if the game uses VfW to render videos, which I'm not even sure) a planned feature ? And if help (mainly testing) would be welcome by Dege ?

2.Find a way around the problem. But I don't know what to do. I had the idea of some sort of VfW -> DirectShow Wrapper, like Gulikoza did years ago with it's MCI -> DirectShow wrapper for Wing Commander 4.
But I don't know at all if that's doable. I looked around and it utterly confused me.

Oh, playing a file with DirectShow seems simple enough. At least, according to the documentation's sample. But it's the "what calls to wrap and how" that seems to be the hardest part.

For example :
- Media Foundation seems to have replaced DirectShow (which replaced VfW, which replaced MCI... Long story, ain't it ?). But the documentation is nowhere to be found, and the SDK samples seem to have been removed.
- If I run RESIDENT EVIL 2 with API Monitor it seems to use... DirectShow interfaces, like iGraphBuilder:RenderFIle. So if dgVooodoo needs a game to use DirectShow for videos to work, why does RE2 seems to use DirectShow ? Does Windows wraps the calls ? And why then it doesn't show ? Are there other requirements ?
- To compare, I tried Resident Evil 3 with dgVoodoo2. The videos worked fine. It seems to use functions from MSACSM32.DLL like acmStreamOpen. Are they DirectShow interfaces too ?
- On top of that, I never even used DirectShow / VfW APIs. They seem utterly complicated.

And finally, option 3) Use software rendering. But the 3D models become ugly.

Anyway, thank you for reading this far. I don't know if this post will have replies, but I'd like to say once again how much I love dgvoodoo2 :
- It fixed Commander & Conquer : Tiberian Sun (yes there is the CnCNet patch and their own wrapper, but I wanted to play without the CD without losing the video cutscenes, and the good ol' NOCD + dgVoodoo2 combo made it come true)
- It fixed Tlon : A Misty Story (an obscure game, with malformed AVI files that I had to fix with ABC AVI Tag Editor). It doesn't run on Windows XP, but it does run on Vista/Seven/10 thanks to dgVoodoo2. 😀
- It fixed Drakan ! Especially the fullscrreen mode.
- It fixed MechWarrior 3 ! I love that game !
- And of course, it fixed the mighty Metal Gear Solid (once the executable was patched) 😀
And countless other games. 😁

Thanks for reading !
(Oh, and I can try to provide screenshots of this small problem if you'd like)

Last edited by xcomcmdr on 2017-03-13, 21:48. Edited 3 times in total.

Reply 1 of 11, by xcomcmdr

User metadata
Rank Oldbie
Rank
Oldbie

I realize I forgot to add some informations :

- I use dgVoodoo 2.53
- The Intel Indeo 5 codec has been added to the registry (and the videos show up with DDrawCompat)
- Converting the videos so they use another video format (MPEG-4 ASP or Cinepak) does not change anything.

Any help or pointers would be grealty appreciated.

Reply 3 of 11, by xcomcmdr

User metadata
Rank Oldbie
Rank
Oldbie

Thanks Dege for your answer.

Could you elaborate on this issue ?

What would you suggest as a solution ?

Right now I was trying this :
- Inject a library into the game with EasyHook (that works)
- So that I know when the game tries to load an AVI file with a local hook on CreateFileA
- Then, try to render it with either Media Foundation (hard) or MPC-HC in slave mode (way easier) (slave mode : tell MPC-HC to use the game's window by giving it the game's window handle)
- Wait for MPC-HC / MF to finish, and then resume the game by returning a 1-frame replaced "empty" AVI file (if I return a non-existing path instead when the game calls my fake CreateFileA, the game opens the right file anyways. 😮')
(the real movie files have been moved in the folder(s) PLO\REALZMOVIES and PL1\REALZMOVIES)

But I don't know if it's stupd or not. I never even used GDI, DirectDraw, DirectShow, in my code.

edit : If only the game would accept Alt-Tab without crashing, or if I could display another window/program in front of it (which is essentially the same thing now that I think about it...). I would be able to pause the game, make MPC-HC play the file, and then return to the game.

I already used EasyHook in other projetcs. Mainly, to make games not use their CDs (simply because it's way easier than modifying the game with OllyDbg. A few looks with API Monitor, and things get started. 😁 ), but all the rest (Media Foundation, GDI, ...) are new to me.
The cloest I've been to GDI/GDI+ is that I used Windows Forms (Win32/GDI+ wrapper in .NET) for years, so I know it's limitations (for LOB applications anyway), but that's about it.

Anyway, enough about my soapbox.

Yes I tried wundowed mode, sadly either the game is tiny, or the videos are, or both. I would have been fine with some borderless 640x480 mode for example. I tried stuff with DXWND but the instant I use it the game crashes.

Frankly I can live with the few big black bars that popup on some background elements near the end of the game (and on top of that, it seems to not happen with AMD GPUs. Really strange...)

It's not game breaking or anything, but I'm very curious about it. 😀

Last edited by xcomcmdr on 2017-03-30, 06:23. Edited 1 time in total.

Reply 4 of 11, by xcomcmdr

User metadata
Rank Oldbie
Rank
Oldbie

I noticed something... Silly me...

With dgvoodoo 2.53 and the patched-for-dgvoodoo2 executables, I can Alt-Tab just fine. No black screen or crash.

As usual, dgVoodoo2 fixes Alt-Tab. 😎

Now hooking CreateFileA to get the path of the AVI file (I mean .BIN-but-really-.AVI files) in order to try and play it with MPC-HC, and then returning to the game, which will play a 1-frame "empty" file instead and finally return to the game itself, seems possible...

Reply 5 of 11, by xcomcmdr

User metadata
Rank Oldbie
Rank
Oldbie

Main code :

public static IntPtr CreateFileHookMethod(
[MarshalAs(UnmanagedType.LPStr)] string filename,
[MarshalAs(UnmanagedType.U4)] FileAccess access,
[MarshalAs(UnmanagedType.U4)] FileShare share,
IntPtr securityAttributes,
[MarshalAs(UnmanagedType.U4)] FileMode creationDisposition,
[MarshalAs(UnmanagedType.U4)] FileAttributes flagsAndAttributes,
IntPtr templateFile)
{

if (filename.ToUpper().Contains("ZMOVIE") == true)
{
string realPath = GetRealAVIFileName(filename);

string mpchcPath = Path.Combine(_workingDir, "mpc-hc-portable\\MPC-HCPortable.exe");

string args = String.Format("{0}{1}{2} /play /close /fullscreen /nocrashreporter /slave {3}", '"', realPath, '"', Process.GetCurrentProcess().MainWindowHandle.ToString());

Process playerProcess = new Process();

var playerStartInfo = new ProcessStartInfo(mpchcPath);

playerStartInfo.Arguments = args;

playerProcess.EnableRaisingEvents = true;

playerProcess.StartInfo = playerStartInfo;

bool started = playerProcess.Start();

if(started)
{
playerProcess.WaitForExit();
}

SetForegroundWindow(Process.GetCurrentProcess().MainWindowHandle);

return CreateFile(
filename,
access,
share,
securityAttributes,
creationDisposition,
flagsAndAttributes,
templateFile);
}
return CreateFile(
filename,
access,
share,
securityAttributes,
creationDisposition,
flagsAndAttributes,
templateFile);
}

It works. 😀

Remaining problems :
1.Switching processes make the screen go back to 1920x1080 (from 640x480), and while it does that the beginning of each video cannot be seen. And some videos are quite short.
2.One can still exit and otherwise interact with the external player. I'll use something else (another program, maybe a COM Windows Media Player Control in a WinForms window or something like that)
3.Subtitles. They are normally displayed by the game, on top of the video rendering. Not a big problem, I can copy them to .srt files and render them that way in MPC-HC or something else.

I'll try to use the game window and do the render in that window, or at least avoid a display mode change. But I'm still happy the game can play videos while using dgVoodoo now. Or rather, that it doesn't crash thanks to dgVoodoo2, even when I add my clumsy EasyHook/C#/Win32 hack on top.

That means a whole lot of solutions are possible. At least, I think. 😀

Reply 6 of 11, by xcomcmdr

User metadata
Rank Oldbie
Rank
Oldbie

So I tried Media Foundation through Media Foundation .NET

It works, but the main problem is that the screen is still black while playing, as I suspected.

I guess I need to create another in-procces window, without trigering a display mode change. I failed the second part this morning, even when my new window had the same size as the old one.

Any tips regarding Win32 windows and display mode change rules ?

(In the meantime, I'll try to create a Win32 wndow with the same parameters as the game does, and set the previous window as it's owner and parent, and search on MSDN).

Reply 7 of 11, by xcomcmdr

User metadata
Rank Oldbie
Rank
Oldbie

Here's the solution I have right now thanks to the fact that dgVooodoo2 fixes Alt-Tabing with this game (among other things 😀 )
1.With EasyHook, catch the call to CreaeFileA which tries to open the AVI File
2.Render it in another window (a WPF Window) with WPFMediaKit
3.Return to the game once the video has finished playing

(the video has previously been converted to WMV with ffmpeg because Intel Indeo tend to not work with Media Foundation / WPFMediaKit)

Limits of this solution :
1.It uses re-encoded video files. While the result is transparent quality-wise, I'd rather avoid the loss of video and audio quality (because WMV/WMA are destructive formats)
2.I still need to make the subtitles appear again in the videos. I plan to use hardsubs. The hard part is to use the "font" that the game uses.
3.Returning to the game without it deciding to use a 320x200 window instead of 640x480 fullscreen once a video has been rendered is tricky
4.Switching windows triggers a display mode change, with a wait time while the screen is busy switching (ie. there's a black screen for a short while). Rght now I wait 1 second before playing the file.

So I'm looking at a crazy alternative : replacing the GDI calls with Direct2D calls. Crazy because I never wrote a wrapper.

Here's what seems promising :
Direct2D and GDI Interoperability Overview

This topic describes how to use Direct2D and GDI together. There are two ways to combine Direct2D with GDI: you can write GDI content to a Direct2D GDI-compatible render target, or you can write Direct2D content to a GDI Device Context (DC).

I'm not sure at all if I understand (my understanding of all this is superficial), but would writing Direct2D content to a "Direct2D GDI-compatible render target" fix this video rendering problem ? Or does the GDI-compatible DC need to be replaced with a Direct2D device context ?

(Also, sorry if yuu already tried this and I bring nothing new ^^' )
edit : other link of interest : Video rendering with Direct2D (CodeProject)

Reply 8 of 11, by Dege

User metadata
Rank l33t
Rank
l33t

GDI interop is an old issue with dgVoodoo2, I'm planning to do something with it because any other solution is a pain.
(If I remember correctly D2D can only draw to a GDI surface in software mode, but, integrating it into dgVoodoo would really be a pain and inefficient. 😀)

Reply 9 of 11, by xcomcmdr

User metadata
Rank Oldbie
Rank
Oldbie

GDI interop is an old issue with dgVoodoo2, I'm planning to do something with it because any other solution is a pain.

That's jolly good news ! If you need testing, or even some funds, I'm here ! 😀

(If I remember correctly D2D can only draw to a GDI surface in software mode, but, integrating it into dgVoodoo would really be a pain and inefficient. 😀)

Yep, upon further reading about Direct2D, anything else seemed more simple. Or at least, result in less code.

Also, I tried to use the game's main window handle instead, with Media Foundation (which seems to use EVRPresenter, therefore Direct3D), but I had nothing but sound.
All around, this game is a pain to fix. Not as much as RE1, but very close.

Reply 10 of 11, by FoodPoisoning

User metadata
Rank Newbie
Rank
Newbie

I come from the future inform people who might have this problem with old games not running cutscenes correctly.

I was trying to play the original Resident Evil 2 PC port made in 1998 and had an issue with cutscenes not running video, only audio. I randomly found a Steam community thread(this one, in case anyone wants to thank the person https://steamcommunity.com/app/356500/discuss … 93392908045242/ ), where the person said to download and install Codinstl here http://www.cucusoft.com/codec.asp

I did it and it worked. Hope people in the future can find this thread as well.

Reply 11 of 11, by DosFreak

User metadata
Rank l33t++
Rank
l33t++

We'd rather have people from the present that create their own threads and use the software they should be using. The Indeo codec is what should be used not some random BS because people randomly search for things without taking the time to find what they actually need.....

Closed.

How To Ask Questions The Smart Way
Make your games work offline