View Single Post
Old 16-04-17, 21:43   #9
Arsunt
Historian
 
Arsunt's Avatar
 
Join Date: Jan 2010
Location: Russia
Posts: 364
Default

I've uploaded the patched EXE for TR3 and The Lost Artifact. It includes my (exclusive) FOV patch. It was was not published anywhere until now.

That's how it works. There is the original code (let it be C pseudocode):
Code:
#define SCREEN_WIDTH	dword_5A6AF4
#define SCREEN_HEIGHT	dword_4D790C
#define ASPECT_RATIO	flt_4C3244	// 1.3333334

void sub_402030(__int16 a1) {
    int v1, v2, v3;

    v1 = SCREEN_WIDTH / 2 * sub_4B4C58(a1 / 2);
    v2 = sub_4B4C5E(a1 / 2);
    dword_4F6D50 = v1 / v2;

    v3 = sub_4B5E10(v2, v1 % v2, flt_4C5084);
    dword_5A6A28 = v3 / dword_4F6D50;

    flt_5A6AB8 = (double)dword_4F6D50; // heigth ratio
    flt_4F6D48 = flt_4C5084 / flt_5A6AB8; // depth ratio
    flt_53170C = flt_5A6AB8 / flt_56C0A0;

    flt_4D38D8 = ASPECT_RATIO / ((double)SCREEN_WIDTH / (double)SCREEN_HEIGHT);

    sub_48D6A0(v3 % dword_4F6D50);
}
And I've changed it to this code:
Code:
#define SCREEN_WIDTH	dword_5A6AF4
#define SCREEN_HEIGHT	dword_4D790C
#define ASPECT_RATIO	flt_4C3244	// 1.3333334

const float flt_4D38D8 = 1.0;    // it is always 1.0 now

int sub_4020B8() {
    return (int)((float)SCREEN_HEIGHT * ASPECT_RATIO)
}

void sub_402030(__int16 a1) {
    int v1, v2, v3;

    // SCREEN_WIDTH value replaced by new function sub_4020B8
    v1 = sub_4020B8 / 2 * sub_4B4C58(a1 / 2);
    v2 = sub_4B4C5E(a1 / 2);
    dword_4F6D50 = v1 / v2;

    v3 = sub_4B5E10(v2, v1 % v2, flt_4C5084);
    dword_5A6A28 = v3 / dword_4F6D50;

    flt_5A6AB8 = (double)dword_4F6D50; // heigth ratio
    flt_4F6D48 = flt_4C5084 / flt_5A6AB8; // depth ratio
    flt_53170C = flt_5A6AB8 / flt_56C0A0;

    sub_48D6A0(v3 % dword_4F6D50);
}
There are v1, v2, v3 variables to calculate FOV. I changed the formula so that they depended on the original aspect ratio (4/3) and the current screen height, but NOT screen width, because this is not correct for wide screens.

The flt_4D38D8 variable is pixel aspect ratio. It must always be 1.0 if we want correct aspect ratio.

P.S. Do not combine this patch with other Widescreen patches and Peixoto's patch. They will break the formula.

UPD. I've updated the patch. Old links deleted.
__________________
To seek. To learn. To do. (C) Quest for Glory

Last edited by Arsunt; 24-09-21 at 03:44.
Arsunt is offline   Reply With Quote