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.21k stars 211 forks source link

Request to support Disney's Atlantis - Trial by Fire #1517

Open arandomguysomewhere opened 4 months ago

arandomguysomewhere commented 4 months ago

Disney's Atlantis - Trial by Fire is a Lithtech game by Zombie Studios from 2001: https://www.pcgamingwiki.com/wiki/Atlantis:_The_Lost_Empire_%E2%80%93_Trial_by_Fire

I tried editing its autoexec.cfg but any widescreen resolution crashes the game even though the commands seem to include arbitrary resolution and FOV similar to the below (adding the NOLF commands also crashes the game): https://github.com/ThirteenAG/WidescreenFixesPack/issues/539

At resolutions higher than 1024x768 in 4:3 the game (e.g. 1600x1200 from the game's own menu) becomes Hor- too which is odd. Running the game under Windows 10 normally sometimes causes it to crash on startup (for example if a browser and/or media player is running), which I'm suspecting is something to do with how it takes control of the screen. If it doesn't crash on startup the game runs fine though. XP SP3 compatibility doesn't really help with crashes.

I've tried all kinds of settings, etc to get widescreen to work so I'm requesting if you could please take a look given your experience with this engine.

alphayellow1 commented 3 months ago

I managed to do it by altering one instruction in lithtech.exe, and it's responsible for the horizontal FOV. Using 800x600 ingame and forcing to 1080p in dgVoodoo2 leads to Hor+ gameplay and stretched HUD and menus. But like you said, changing the resolution to more than a certain value leads to cropped menus and HUD, which makes it unplayable. So for now, that's what I managed to do, keep the ingame resolution at 800x600 and forcing native res in dgV2. Maybe ThirteenAG is able to investigate further into the engine, and fix the HUD placement for 16:9 and wider resolutions, and also why it crashes beyond a certain resolution threshold and also during level loading screens.

LithTech Screenshot 2024 03 30 - 16 02 52 02

LithTech Screenshot 2024 03 30 - 16 04 45 62

arandomguysomewhere commented 3 months ago

Nice! Would you mind sharing your modifications? If only the HUD is stretched that's already good progress and could help get to the overall fix more easily.

alphayellow1 commented 3 months ago

Nice! Would you mind sharing your modifications? If only the HUD is stretched that's already good progress and could help get to the overall fix more easily.

Well, I can but it's a long one, hope you can follow it. This is for 16:9 though, I can say how to do for other aspect ratios, consider this as a temporary fix while ThirteenAG doesn't do a dedicated patch. Here it goes:

  1. Open lithtech.exe with OllyDbg (extract OllyDbg 2.01 from here to some folder (like Documents) and open ollydbg.exe with admin rights).
  2. After importing the exe in OllyDbg and it's fully opened, press Ctrl+G, and write 0040BD86, then press Enter.
  3. Press space and write this: "JMP 004C3B00" (without quotes).
  4. Press Enter.
  5. Then press Ctrl+G again, and type this: "004C3B00" (without quotes).
  6. Press space and write this: "MOV EAX,3FED631A" (without quotes).
  7. Press Enter.
  8. Delete the "DB 00" and write this: "MOV DWORD PTR DS:[ECX+00000198],EAX" (without quotes).
  9. Press Enter again.
  10. Delete the "DB 00" again and write: "JMP 0040BD8C" (without quotes).
  11. Press Enter.
  12. In the main window, right click "Edit>Copy all modifications to executable".
  13. Then in the small window that appears, right click on it, and click in "Save file".
  14. Save with a different name from the original exe (like lithtech(2).exe) and backup the original exe, then rename the modified executable to lithtech.exe.
  15. You're done for 16:9.
  16. To change the FOV for other aspect ratios in the modified exe, just open the modified lithtech.exe in a hex editor like HxD (download it here), then press Ctrl+G and write "000C3B00" (without quotes).
  17. The next 4 pairs of values where the cursor lands is the horizontal FOV value (in radians).
  18. Highlight those and go to the right side in the "Data inspector" tab and change the value in the "Single (float32)" row.
  19. You'll need a degrees to radians converter like this one.
  20. Put the desired FOV value in the degrees tab and press "Convert".
  21. Then copy the last result in the "Radians result:" box.
  22. Go back to HxD and paste it in that row above [Single (float32)].
  23. Press Enter and the save the file. Your new horizontal FOV will be permanently saved.
arandomguysomewhere commented 3 months ago

Thanks! I tried this out and my modified lithtech.exe has CRC32 as 9adda7e6, does it match your modifications? In OllyDbg I had to disable "Keep size" and "Fill rest with NOPs" in the assemble window (after pressing space) for the rest of the instructions to work. I found the FOV set to be fine for 16x9, were the instructions for changing the FOV optional? I have a rudimentary understanding of this so sorry if this sounds dumb but does this modification jump from one resolution change setting to force setting an FOV value in the exe?

After testing, the game looks way better with dgvoodoo upresing the resolution but the pre-existing crashes both on startup (I have to run launchme.bat several times for the game to even start) and during level loading (sometimes loading a save, sometimes during level transition) get in the way of autosaves kicking in, blocking progression. This game has rough compatibility on modern systems.

alphayellow1 commented 3 months ago

Thanks! I tried this out and my modified lithtech.exe has CRC32 as 9adda7e6, does it match your modifications? In OllyDbg I had to disable "Keep size" and "Fill rest with NOPs" in the assemble window (after pressing space) for the rest of the instructions to work. I found the FOV set to be fine for 16x9, were the instructions for changing the FOV optional? I have a rudimentary understanding of this so sorry if this sounds dumb but does this modification jump from one resolution change setting to force setting an FOV value in the exe?

After testing, the game looks way better with dgvoodoo upresing the resolution but the pre-existing crashes both on startup (I have to run launchme.bat several times for the game to even start) and during level loading (sometimes loading a save, sometimes during level transition) get in the way of autosaves kicking in, blocking progression. This game has rough compatibility on modern systems.

No, your modified file's checksum doesn't match my file's one, but you should be fine. And yes, I forgot about saying to check "Fill the rest with NOPs" and uncheck "Keep size" in the assembling window, important ones! And this tinkering in OllyDbg only changes horizontal FOV, nothing else. And no, this modification only changes the value that is passed to the address with the custom one that we added in the codecave, instead of the default value. And yeah, unfortunately, this does not fix the constant crashing during level loading or startup, that would require a much deeper dive into the engine's files, which I don't have the knowledge to do. Does this constant crashing happen even on older Windows versions like XP, Vista or 7?

arandomguysomewhere commented 3 months ago

I tested the game on Windows 10 64-bit and had the crashes, on an XP VM it crashes too but that might just be a VirtualBox limitation as its in-built GPU support is very basic. I'll try again with some compatibility settings and such.

arandomguysomewhere commented 3 months ago

After testing I can confirm the post-game launch crashes do not occur when NOT using dgvoodoo2 so although launching the game can be finnicky, once it runs it is mostly smooth but there are weird moments where the camera would suddenly snap to one side of the screen unintentionally after some movement, don't know if a pre-existing bug or not. Windows compatibility fixes do nothing to improve the situation. As of right now the most stable way of playing the game under Windows 10 64-bit is to run it at 1024x768 without dgvoodoo2 sadly. @ThirteenAG Please consider making a patch for this game, it seems to be an amateur lithtech game so might be simpler than larger scale productions :)

gordonfreeman01 commented 3 days ago

Good news, the latest version of dgvoodoo2 (v2.82.5) seems to have fixed the issue! On v2.82.3 the crashes happened regularly. Another thing to note is that the game runs very smoothly using DDrawCompat or EnableDdrawWrapper via https://github.com/elishacloud/dxwrapper/ but those cannot be combined with dgvoodoo for higher resolutions. So far it looks like using dgvoodoo2 (v2.82.5) and the fix by @alphayellow1 actually allow proper widescreen and 4K for this game! I'll test out the game and report back if I find any crashes.

Of note, it seems the game needs both D3DImm.dll and ddraw.dll to work correctly with dgvoodoo. It may still crash when loaded first but once it loads correctly the session seems to work correctly.