ThirteenAG / WidescreenFixesPack

Plugins to make or improve widescreen resolutions support in games, add more features and fix bugs.
https://thirteenag.github.io/wfp
MIT License
2.26k stars 214 forks source link

Hitman Codename 47 Widescreen fix #1024

Open Kappa971 opened 2 years ago

Kappa971 commented 2 years ago

Hi and thanks for your widescreen fixes! As the title suggests, Hitman Codename 47 doesn't have a decent widescreen fix, it only has one that only works in DirectX 7 with all the problems of the case on new versions of Windows (unable to limit FPS). Hitman 2, 3 and blood money are in better shape than Codename 47 (although their fixes aren't as advanced as yours). Only if this is possible, otherwise I close the issue. Thanks :)

Kappa971 commented 1 year ago

Is this in the plans in the future? Otherwise I think I can close this issue (even if it is not the best to play this game in the current conditions).

I thank you for your work.

MIvanchev commented 1 year ago

@Kappa971 why not just set the resolution you want in hitman.ini?

Kappa971 commented 1 year ago

@Kappa971 why not just set the resolution you want in hitman.ini?

Because the vertical fov is reduced compared to 4:3 resolutions

MIvanchev commented 1 year ago

Any other issues like stretched GUI or something like that?

MIvanchev commented 1 year ago

@Kappa971 I will run it in the debugger and experiment a little because I'm soon releasing a fix for another issue with the game, maybe I can patch that too.

Kappa971 commented 1 year ago

Any other issues like stretched GUI or something like that?

I don't remember if the game HUD is stretched horizontally without nemesis2000's widescreen fix but I guess so. The HUD however becomes very small (but still readable) in 1080p.

The game works in DirectX 7 and this is a problem because vsync/fps limiter doesn't work, it only works in borderless full screen and I can't force anti-aliasing otherwise it "breaks" the game text. No problem with OpenGL renderer but there is no Widescreen fix for OpenGL.

This is the version of the game (it should be the latest) b192: scr1

MIvanchev commented 1 year ago

Yeah, the latest is b192, it's what I'm working with. Alright, I'll have a look :)

MIvanchev commented 1 year ago

@Kappa971 I just release this https://github.com/MIvanchev/HitmanC47TimingFix, feel free to test if it helps with the timing issues in the D3D7 renderer ;) Meanwhile I'm on the OpenGL widescreen fix.

Kappa971 commented 1 year ago

@Kappa971 I just release this https://github.com/MIvanchev/HitmanC47TimingFix, feel free to test if it helps with the timing issues in the D3D7 renderer ;)

I once played this game in DirectX 7 on my old 60hz monitor (now I have a 144hz freesync monitor, I should limit the game to 60fps but it doesn't work in DirectX 7 games) and I don't remember noticing any issues in-game (except the antialiasing, and the small menu/hud). Does this patch allow me to play over 60 fps without running into strange bugs?

Meanwhile I'm on the OpenGL widescreen fix.

Fantastico! thanks @MIvanchev. Even without the above patch, with OpenGL I could finally play in widescreen, force anti-aliasing from the video card control panel and limit the fps to 60 (according to the PCGamingWiki site this is necessary), but if your patch fixes this too it would be perfect (however Hitman 2, Contract and Blood Money also need the 60 fps limit, but luckily they are DirectX 8 games and you just need to use the d3d8to9 wrapper).

EDIT Anyway it doesn't work: scr1 scr2

MIvanchev commented 1 year ago

@Kappa971 is this the Steam version? I haven't been able to test with it yet because I don't use Steam. Is there a way to contact you privately?

Does this patch allow me to play over 60 fps without running into strange bugs?

Yes, the problems of the game are related to the way the timing information is extracted and handled. This is what the patch fixes, the FPS limiting is only treating the symptoms. With the patch you can play at whatever FPS you like because the game scales down the frame time as if running on 45 FPS.

ThirteenAG commented 1 year ago

@MIvanchev can you check scarface? It uses Query* already, but at high fps, animations have higher speed than they should.

MIvanchev commented 1 year ago

@ThirteenAG I'll check it out but I'll need some time :) Actually the Query*functions weren't the sole cause in Hitman, it's the delta time computation that's lacking and I suppose it's the same thing here. I'll get back to you, I see you already fixed some issues in the game.

ThirteenAG commented 1 year ago

Yeah, check around 0x456A25, it has a call to QueryPerformanceFrequency, and the return value affects some speeds. But I don't quite understand what is needed to be done further.

Kappa971 commented 1 year ago

@Kappa971 is this the Steam version? I haven't been able to test with it yet because I don't use Steam. Is there a way to contact you privately?

It is a European CD version, with English, Italian (what I use), German, French and Spanish. I can share the executable or other necessary dll files (Which?).

MIvanchev commented 1 year ago

I'd need the system.dll but let me see whether I can do without. Stay tuned, thanks for your help @Kappa971 !!

Kappa971 commented 1 year ago

This is the executable and the System.dll file: Hitman C47 exe+system.dll.zip

It's been a while since I installed this game, I think I haven't applied any official patches, I think this CD is already updated to the latest version (and it has no DRM??)

MIvanchev commented 1 year ago

@Kappa971 can you try patcher-other.exe from here https://ci.appveyor.com/project/MIvanchev/hitmanc47timingfix/builds/45177388/artifacts.

Kappa971 commented 1 year ago

@Kappa971 can you try patcher-other.exe from here https://ci.appveyor.com/project/MIvanchev/hitmanc47timingfix/builds/45177388/artifacts.

This time the patch is applied to System.dll, but the game runs in slow motion (144 fps)

MIvanchev commented 1 year ago

Perfect, so that's 45 FPS simulated time. Maybe I need to increase to 60 to look better?

MIvanchev commented 1 year ago

@Kappa971 Take a look here how to manipulate the FPS yourself if you're feeling secure using a hex editor: https://github.com/MIvanchev/HitmanC47TimingFix#how-to-set-a-custom-fps.

Kappa971 commented 1 year ago

@Kappa971 Take a look here how to manipulate the FPS yourself if you're feeling secure using a hex editor: https://github.com/MIvanchev/HitmanC47TimingFix#how-to-set-a-custom-fps.

I tried to set 60 fps (3C in hex) in System.dll but the game works the same way in slow motion. Hitman Codename 47_45 fps.zip The video with System.dll set to 60 fps goes the same.

Can you try it with your computer? Maybe I'm doing something wrong... I want to point out that I have a 144hz monitor so the game (no limiter, it doesn't work in DirectX 7) is running at 144 fps.

MIvanchev commented 1 year ago

Can you try it with your computer? Maybe I'm doing something wrong...

I'm trying it out the whole time. This is DirectX 7, windowed mode right? Thank you so much for this!!! Can you try the OpenGL renderer without a limiter and DirectX with fullscreen? I think I have something similar in DX7 windowed but the others seem to work.

Kappa971 commented 1 year ago

I'm trying it out the whole time. This is DirectX 7, windowed mode right? Thank you so much for this!!! Can you try the OpenGL renderer without a limiter and DirectX with fullscreen? I think I have something similar in DX7 windowed but the others seem to work.

In Windows 10-11, DirectX 8 (and below) games only run in borderless fullscreen mode, so I can run Hitman C47 only in borderless fullscreen mode and it runs in slow motion with your patch. OpenGL works in exclusive fullscreen but, despite this, the game still runs in slow motion.

MIvanchev commented 1 year ago

@Kappa971 Thanks so much! I got some new leads and I'll open an issue over my project. Thank you so so much.

MIvanchev commented 1 year ago

@Kappa971 without the patch the game is too fast on DirectX, right?

Kappa971 commented 1 year ago

@Kappa971 without the patch the game is too fast on DirectX, right?

In DirectX (without your patch), I started the first level and between 144fps and 60fps I don't notice speed differences, I don't know if going further in the game I could run into serious bugs (the first time, I played this game on a 60hz monitor). According to PCGamingWiki: scr1

From our discussions on speedruning Discord: at 284 fps gravity stops working (guns start to float in air).
FPS also affects how much the camera sways and how far ragdolls fly, but 283 fps seems like the maximum limit 
after which the game utterly breaks.

This is also specified but to me it doesn't seem to be happening (AMD Ryzen 5 1600 CPU): scr2

MIvanchev commented 1 year ago

So a quick update, I have changed the patch to allow setting custom FPS value in hitman.ini. I have good leads on a general widescreen fix that will work for both DX and OpenGL, I need to extend my patcher to be able to patch multiple DLLs. I do get the floating gun bug in slow motion, i.e. Fps 5. I intend to fix it but need to find the relevant parts in the code.

P.S. The patch fixes the issues that require changing the CPU power settings so that part of PCGamingWiki is irrelevant now. Your CPU is probably running the game OK because it's TSC invariant and thus unaffected.

P.P.S. Thank you so much for your effort, it helps patch developers a lot :)

Kappa971 commented 1 year ago

P.S. The patch fixes the issues that require changing the CPU power settings so that part of PCGamingWiki is irrelevant now. Your CPU is probably running the game OK because it's TSC invariant and thus unaffected.

What's your CPU? I first played this game with an Intel Core i7 860 (1st gen) and 60hz monitor, I didn't notice any speed issues. Now I have an AMD Ryzen 1600 CPU and a 144hz monitor, starting the Hong Kong level, I don't notice speed problems at 144fps (but for safety I would have played this game with the limiter at 60fps, but as mentioned in DirectX 7 this doesn't work) .

I play on Windows (first Windows 10, now 11 even if the CPU is not supported but it works without any problem).

Here I recorded two videos (without your patch): Hitman Codename 47-vid1.zip Hitman Codename 47-vid2.zip The speed seems right to me and at the top right there is the fps counter

With your patch the game becomes extremely slow (even setting Fps 60 in hitman.ini).

P.P.S. Thank you so much for your effort, it helps patch developers a lot :)

No problem, thanks to you 🙂

MIvanchev commented 1 year ago

I have a Ryzen 3400g :)

Kappa971 commented 1 year ago

I have a Ryzen 3400g :)

It means that I was lucky to choose the right CPUs 😅

Have you seen the videos? In my opinion the game at 144 fps is running at the right speed (but even if I limit the fps to 60 in OpenGL). In this case I shouldn't need your patch, right? Because if I use it, the game runs in slow motion. For those who have a CPU that causes problems, I imagine that your patch is very useful, but unfortunately I can't test it because I don't have the same behavior as you.

MIvanchev commented 1 year ago

In this case I shouldn't need your patch, right? Because if I use it, the game runs in slow motion.

Yes, no need for the patch if the game is running good already. I've seen the videos and it runs pretty good indeed @ 144.