SuiMachine / StuntGP-Widescreen-Fix

Aspect ratio fixer for StuntGP
MIT License
3 stars 1 forks source link

Fix GUI scaling #4

Open halamix2 opened 3 years ago

halamix2 commented 3 years ago

There should be one float 0.0015625 (CD CC CC 3A) in exe that controls GUI scaling . When set to half of the original value ~0.0007625 the GUI and menus are centered and taking half of the screen on X axis. Problem: how to decide correct value for widescreen (4/3)*(21/9)*0.0015625 // for 21/9 screens

Offsets:

Example with 21:9 widescreen fix and the float set to 0.0007625:

widescreen

halamix2 commented 3 years ago

Mainly creating issue to keep notes here for later, I might try programming that in a week or two, (alongside with converting widescreen fix to loadable dll, as version detection currently used in other things, like autosplitter, is based on exe MD5 sum)

SuiMachine commented 3 years ago

Mainly creating issue to keep notes here for later, I might try programming that in a week or two, (alongside with converting widescreen fix to loadable dll, as version detection currently used in other things, like autosplitter, is based on exe MD5 sum)

https://github.com/ThirteenAG/Ultimate-ASI-Loader should make it easy in that case unless you really need it to be one dll.

halamix2 commented 3 years ago

I kinda already done something like original WormKit (haven't yet published that, only internal development on Discord for now), a launcher that loads all sk*.dll libraries inside game directory; and tested that with library replacing 4:3 float with one for 21:9 ratio.

halamix2 commented 3 years ago

I managed to make widescreen fix in a form of loadable dll module, but it needs original .exe to work (version is checked by executable hash) loader for module module itself

halamix2 commented 3 years ago

Finding 8988083B CDCCCC3A (2 floats, ~0.0020833334 and ~0.0015625) is easy, there is only one occurrence in all exe I've tested (interntional/pl, d3d/glide) These are two floats for Y and X 2D scaling, I've used something like this in skScreen:

float ratio43 = 4.0f / 3.0f;
float ratioWanted = gameConfig.getWidth() / gameConfig.getHeight();
// is new resolution wider than 4:3?
if (ratio43 < ratioWanted)
{
    // make UI shorter in X axis
    float ratio = ratio43 / ratioWanted * 0.0015625f; // 0.0015625 is magic
    // replace original magic value wiith calculated one
    replaceMemory(addressX, ratio);
}
else
{
    // make UI shorter in Y axis
    float ratio = ratioWanted / ratio43 * 0.0020833334f; // 0.0020833334 is magic
    // replace original magic value wiith calculated one
    replaceMemory(addressY, ratio);
}