*

Author Topic: Playing around with a Descent 3 patcher [Build 1 released!]  (Read 6763 times)

Offline SaladBadger

  • Gold
  • ***
  • Posts: 602
Playing around with a Descent 3 patcher [Build 1 released!]
« on: March 23, 2021, 05:18:47 PM »
https://github.com/InsanityBringer/InjectD3/releases/tag/v0.1-alpha

Assuming nothing's gone wrong, here's my first build!

It's absolutely vital you read the readme to tell what's going on. You'll need to use OpenGL for most patches to take effect, you'll probably need to rename your movies folder since I haven't patched the movie player yet, and there's still bugs in this release I'm trying to track down, but for normal playing it should be fine.

Old post:

Descent 3 always bugged me. It messes up your desktop windows if you play it in OpenGL, can't be run in windowed mode, doesn't support widescreen well, constantly changes video resolution. It sucks, but without a source release on the horizon, what can one do about it? Well, I've gotten curious, and with some motivation and help from Arne, I've been working on a program that patches it.

I have a dll injection system that loads a dll into the program's address space, and makes several patches, which should be user configurable. So far the current patches are:
  • Windowed mode
  • New mouse library (since the old system didn't work well in windowed mode)
  • Fov override (it's a bit buggy ATM though)

Things I want to include for later include:
  • Borderless window fullscreen mode
  • Virtual resolution system so that the window or fullscreen resolution remain the same no matter the game resolution, like Chocolate Descent.
  • New rendering features, such as a shader-based OpenGL renderer that can support bumpmaps
  • Incorporate 32-bit color hack so you don't have to change it all the time
  • Incorporate sound quality hack so you don't have crackly sounds. Or just gut the entire sound system and replace it with OpenAL..

It's all pretty rough so far, but I'm planning on having a frontend that will allow choosing what modifications are active and setting parameters for them, such as the desired FOV and so on.

For now, have a pic of the game running natively in windowed mode (with no glide emulators in sight) with a ridiculously high FOV. There's still plenty of bugs I'm trying to chase down with this right now, but it kinda works:
« Last Edit: August 28, 2021, 12:01:43 PM by SaladBadger »

Offline Scyphi

  • Purple Heart
  • *****
  • Posts: 2386
  • TechPro Jr.
Re: Playing around with a Descent 3 patcher
« Reply #1 on: March 24, 2021, 06:12:44 AM »
Well, that all looks very promising! As I, too, have been getting frustrated with D3's various...quirks...and the increasing difficulty to get it to run smoothly on modern systems, I'd be very interested in something like this.  ;D
"I thought I had a great idea, but it never really took off. In fact, it didn't even get on the runway. I guess you could say it exploded in the hanger." -Calvin and Hobbes
Check out my deviantART

Offline SaladBadger

  • Gold
  • ***
  • Posts: 602
Re: Playing around with a Descent 3 patcher
« Reply #2 on: March 24, 2021, 07:41:59 AM »
Ah, I hope I can deliver on this front, I've played the first couple of levels of Descent 3 with it and it's a lot more stable than I expected (only major bug I'm trying to track down now is that the mouse doesn't work in Telcom screens for reasons I can't comprehend), so I think I may be able to release something soon, though it currently only patches 1.4 (the exe that old fan packaged version of the game uses). I need to write code to detect your version and select the right offsets for 1.4 and 1.5.

For now, I just got command line arguments working in the injector program, so here's some 1920x1080 windowed with expanded FOV:


The cockpit is absolutely unusable, and it's probably fixable, but that will be very tricky to do, so just use the fullscreen HUD for now.

Offline Hunter

  • Gold
  • ***
  • Posts: 219
  • Sectorgame
    • Sectorgame
Re: Playing around with a Descent 3 patcher
« Reply #3 on: March 25, 2021, 04:11:57 AM »
The fact you managed to increase the FOV is an achievement! It's one of the MAIN gripes from Overload players that D3's FOV is too small.

A modified frontend could be sweet, a bit like PureFaction's frontend on top of Red Factions menus.

You also might wanna contact Matt about this - he and luke (I think) were working on a modified D3 build around the time Overload was in development. We never heard anything more about it, but I do remember seeing it briefly on a livestream so it definitely exists.
« Last Edit: March 25, 2021, 04:14:21 AM by Hunter »
Sectorgame.com - Descent and Freespace mods/levels.

Offline SaladBadger

  • Gold
  • ***
  • Posts: 602
Re: Playing around with a Descent 3 patcher
« Reply #4 on: March 25, 2021, 07:41:58 AM »
Honestly, I didn't realize quite how bad the FOV was until I started working on this. The default is a whopping 72 degrees. Ouch. As I discovered from writing Chocolate, Descent 1 and 2 were probably lower in fullscreen mode (cockpit mode expands it a bit), so I'm not entirely surprised, but it still hurts. In any case, being able to fix that was a breath of fresh air. That widescreen pic has it at 105, and I've played the first couple of levels like that and it's all fine.

I can look into menu integration for a frontend, but it'll be a bit hellish, the D3 menu code isn't exactly intuitive to hack.

I'm also trying to hack in an alternate sound implementation right now, using OpenAL. I have the entirety of the "LLS system" patched atm, but no sound yet. I tried to correct the crackles and pops the original sound code gives me, but honestly, I don't know DirectX well enough as it is, and I certainly have no idea why 22 year old DirectSound 6 code could be full of crackles and pops, so replacing it is basically my only option. I thought the sound quality wasn't getting set right, but I whacked a debugger up against the relevant functions and they're all passing high quality down the pipeline, so it's not that like I had thought.
« Last Edit: March 25, 2021, 07:44:36 AM by SaladBadger »

Offline Hunter

  • Gold
  • ***
  • Posts: 219
  • Sectorgame
    • Sectorgame
Re: Playing around with a Descent 3 patcher
« Reply #5 on: March 27, 2021, 03:04:20 AM »
Oddly enough, when I play D3 on Wine there are no sound issues - even on high quality (a toggle which ONLY works in the main menu btw). Linux has its own set of issues though, but wine is the best way to play D3 despite the existence of the new 64-bit D3 port for native Linux. When it comes to Windows, there is that 'IndirectSound' dll that is supposed to fix sound issues. Have you tried it?

Another big gripe is the hardcoded menu/map resolution. That can REALLY mess up peoples desktops on Windows..

Also look into D3's bump mapping (-bumped) for Direct3D. I could only ever get it working on my old Radeon, but it looks pretty sweet when combined with reflective surfaces. It even puts Unreal's original 98 engine to shame (same production year).
Sectorgame.com - Descent and Freespace mods/levels.

Offline SaladBadger

  • Gold
  • ***
  • Posts: 602
Re: Playing around with a Descent 3 patcher
« Reply #6 on: March 27, 2021, 08:39:11 AM »
I think bumpmapping is one of those things where it used some sort of GPU extension to do its thing, and I wouldn't be surprised if modern cards don't carry that feature anymore, since any game using bumpmapping from the past two decades would use shaders. One of my dream features ATM is to be able to outright replace the GL renderer with a shader based one, but that's going to take some time.

I am currently investigating making the game not mess with your resolution. My initial solution for this was my windowed mode, but this is a bit lacklustre if you wish to play in fullscreen. Interestingly, the game actually uses borderless windowed mode normally in GL mode, but it also changes your screen resolution... The idea I'm drafting up ATM is to use a render target. Descent 3, so far as I can tell, doesn't use render targets normally, even for things like the HUD camera views, so I can trick the game into thinking a render target is actually the main framebuffer, and then when the game goes to flip buffers, I quickly draw that render target to the main framebuffer and then flip. I'll give that a try today.

Also, regrettably, the sound code is on hold for the moment. While I got 3D sound playing just fine, no crackles and pops, I cannot get streams working for the life of me, I need to reverse engineer a lot more of the LLS system and other parts of the sound system before I can do it. If people aren't interested in music, I can toss in an optional prototype version of the new sound code that will just have the 3D sound but no music.
edit: the music not working properly may have been a 1 line typo. Oops.

I want to get something released by next weekend. With my usual reliability and the frustrations of things like the sound system, it may drift some, but there's not too much work. I currently worry that there's too many "downsides" to this patch (ie, movies will still change your resolution if you don't disable them), but a lot of it is stuff that isn't too important so far so I think the benefits will outweigh the negatives for this first release (we've all seen those crappy late-90s FMVs a hundred times at this point...)
« Last Edit: March 27, 2021, 09:11:08 AM by SaladBadger »

Offline SaladBadger

  • Gold
  • ***
  • Posts: 602
Re: Playing around with a Descent 3 patcher
« Reply #7 on: March 27, 2021, 09:54:58 PM »
Alright, I got borderless window fullscreen in... well, kinda. It was my intention, but Windows is weird and automatically handles the case of creating a window the size of the desktop as a sign you actually want exclusive fullscreen mode, so it's actually exclusive fullscreen mode but the resolution is your desktop resolution... good enough for now, I need to figure out what borderless window games do differently to avoid this. The framebuffer system caused some bugs at first, but I think I squashed them. All of these hacks currently only work with the OpenGL renderer, since it's the only one I know how to service, but it works out nicely.

I've basically completed all the big hacks I want to get into an initial release, so the rest of it is probably going to be things like automatically setting certain command line switches and things like the 32-bit color hack (I keep on neglecting it because my executable came pre-patched with the ancient fan 32-bit hack)

Offline Hunter

  • Gold
  • ***
  • Posts: 219
  • Sectorgame
    • Sectorgame
Re: Playing around with a Descent 3 patcher
« Reply #8 on: March 29, 2021, 02:33:28 AM »
Very nice! And no rush. Things move really slowly these days... it can be about 3 months before people even check a new level!

I believe Ryan converted the movies to ogg, they're included in the new Linux release. (https://www.gamingonlinux.com/articles/descent-3-returns-to-linux-and-macos-with-an-official-modern-port.15900)
Sectorgame.com - Descent and Freespace mods/levels.

Offline Matthew

  • Platinum
  • ****
  • Posts: 1275
    • Globalgamers.de
Re: Playing around with a Descent 3 patcher
« Reply #9 on: March 31, 2021, 07:58:20 AM »
This sounds excellent! I might even be able to stomach a playthrough of D3 again! Thanks for your work!

Offline SaladBadger

  • Gold
  • ***
  • Posts: 602
Re: Playing around with a Descent 3 patcher
« Reply #10 on: April 01, 2021, 08:59:55 AM »
Just a small update, but I'm finally working on the configuration parser, and then the configuration tool. While finishing up the fullscreen code I also took a moment to squeeze in optional MSAA support for the new windowed and fullscreen modes, and it looks quite nice.

Offline SaladBadger

  • Gold
  • ***
  • Posts: 602
Re: Playing around with a Descent 3 patcher
« Reply #11 on: April 02, 2021, 11:26:06 AM »

The configuration parser is functional now, and the configuration tool is working. Some testing and cleanup is still needed, and I need to load in the offsets for some other versions, but I hope I can get this mess released this weekend.

These are all the patches that will be in the initial release, but I want to add more later down the line

Offline SaladBadger

  • Gold
  • ***
  • Posts: 602
Re: Playing around with a Descent 3 patcher
« Reply #12 on: May 23, 2021, 06:37:03 AM »
Well, I was hoping to have a build released by now, but I've been trying to track down a mysterious crashing issue in the OpenAL sound code I wrote. At first, it never crashed, I could launch the game reliably and I never had any issues. Later, it would crash like once in 10 launches, but now it's crashing nearly every launch. This is really hard to track down since the game installs an exception handler, which does at least create error.log which shows you the full state of the stack and register dumps, but it's harder than actually using a debugger on this...

Hopefully soon, but the source is available now.

Offline SaladBadger

  • Gold
  • ***
  • Posts: 602
Re: Playing around with a Descent 3 patcher
« Reply #13 on: July 11, 2021, 06:21:00 PM »
It's been a while, but I have two new patches in the pipeline ATM.

The first is reverbs. Descent 3 supported EAX-enabled sound cards to provide reverbs with DirectSound3D, but this wouldn't work on any modern system with simple integrated sound hardware. The right emulator should provide it, but rather than deal with that I've added support for reverbs in the OpenAL Soft sound code I've provided. This can be turned on and off in the configuration.

The second is that I added a patch to change the game to use the HKEY_CURRENT_USER registry hive instead of HKEY_LOCAL_MACHINE. The upshot of this is that you will never need to run the game as adminstrator to change settings (unless you stick it in Program Files, so don't), and settings are per-user if that's your thing. Downside is that settings are now per-user if that's not your thing, but for most people it's absolutely worth it.

This does warrant a new configuration program, since the stock launcher won't work here, so I added one to the configuration program:

Offline Kaiaatzl

  • An unusual choice for ship's cat
  • Platinum
  • ****
  • Posts: 1918
  • beware of ounce
Re: Playing around with a Descent 3 patcher
« Reply #14 on: July 12, 2021, 10:28:58 AM »
Neat!

 

An Error Has Occurred!

Cannot create references to/from string offsets