Jump to content

More information for our favorite reverse engineer.


the bigg

Recommended Posts

Weak-ling has contacted me. First thing first, he has allowed me to continue shipping this widescreen mod. He also provided me with a lot of further info.

Since Avenger says he can find most info by looking at the ToB offsets, hopefully these will be helpful :)

 

This is an explanation of how resolution selection works in ToB:

the resolution selection code in BG2 works like this (pseudocode):
CODE
Get res_ini from ini
if (res_ini <= 1280) {
if (res_ini == 1280)	   -> codepath for 1280
elseif (res_ini == 800)	-> codepath for 800
elseif (res_ini == 1024)   -> codepath for 1024 (I want to go here)
else					   -> codepath for 640
}
else {
if (res_ini == 1600)	   -> codepath for 1600
elseif (res_ini == 2048)   -> codepath for 2048
else					   -> codepath for 640
}



Now for my mod I have replaced the following:
"elseif (res_ini == 1024)" by "elseif (res_ini == res_x)" (this happens at xOff = 0x32831)
"if(res_ini <= 1280)" by "if(res_ini <= res_x)" (this happens at x_1280 = 0x32809)

The first replacement is absolutely neccessary, the second is only needed if res_x is larger than 1280

If we want the game to choose the codepath for 1024 even if res_x is 1280 or 800 we have to do two more replacements
at 0x32815 replace 1280 by something else
at 0x32825 replace 800 by something else

 

These are the "magic numbers" for BG1: TotSC:

This one sets the size of the game window:

CODE
offset			old(hex)		old(dec)		patch
0x003a7faf		e0010000		480			 res_y
0x003a7fb4		80020000		640			 res_x



If I don't patch this the cursor didn't work outside of the original 640x480 area:

CODE
offset			old(hex)		old(dec)		patch
0x003ab18d		80020000		640			 res_x
0x003ab194		e0010000		480			 res_y



And without these values I wasn't able to scroll with the mouse:

CODE
offset			old(hex)		old(dec)		patch
0x0008a190		7f020000		639			 res_x - 1
0x0008a5e6		df010000		479			 res_y - 1



viewport:


CODE
offset			old(hex)		old(dec)		patch

0x00084A74		40020000		576			 res_x - 64
0x00084A7E		86010000		390			 res_y - 480 + 390

0x0010C135		40020000		576			 res_x - 64
0x0010C13C		C6000000		198			 res_y - 480 + 198

0x001BAC17		40020000		576			 res_x - 64
0x001BAC1E		86010000		390			 res_y - 480 + 390

0x002791CA		40020000		576			 res_x - 64
0x002791D1		C6000000		198			 res_y - 480 + 198

0x0027A0E1		40020000		576			 res_x - 64
0x0027A0E8		86010000		390			 res_y - 480 + 390

0x0027A21F		40020000		576			 res_x - 64
0x0027A229		46010000		326			 res_y - 480 + 326

0x0027A345		40020000		576			 res_x - 64
0x0027A34F		C6000000		198			 res_y - 480 + 198

0x0027BA5D		40020000		576			 res_x - 64
0x0027BA64		86010000		390			 res_y - 480 + 390

0x0027BBB6		40020000		576			 res_x - 64
0x0027BBBD		46010000		326			 res_y - 480 + 326

0x0027BCF9		40020000		576			 res_x - 64
0x0027BD00		C6000000		198			 res_y - 480 + 198


0x0027FDAD		40020000		576			 res_x - 64
0x0027FDB4		46010000		326			 res_y - 480 + 326

0x0027FF67		40020000		576			 res_x - 64
0x0027FF6E		46010000		326			 res_y - 480 + 326

0x002805A0		40020000		576			 res_x - 64
0x002805A7		72010000		370			 res_y - 480 + 370

0x00280612		40020000		576			 res_x - 64
0x00280619		EA000000		234			 res_y - 480 + 234

0x00280ED2		40020000		576			 res_x - 64
0x00280ED9		86010000		390			 res_y - 480 + 390

0x00280FFE		40020000		576			 res_x - 64
0x00281005		46010000		326			 res_y - 480 + 326

0x00281126		40020000		576			 res_x - 64
0x0028112D		C6000000		198			 res_y - 480 + 198

0x002813CE		40020000		576			 res_x - 64
0x002813D5		55010000		341			 res_y - 480 + 341

0x00283E9B		40020000		576			 res_x - 64
0x00283EA2		46010000		326			 res_y - 480 + 326

0x00354440		40020000		576			 res_x - 64
0x00354447		86010000		390			 res_y - 480 + 390


0x0037CF4A		40020000		576			 res_x - 64
0x0037CF51		46010000		326			 res_y - 480 + 326

0x0037D20A		40020000		576			 res_x - 64
0x0037D211		C6000000		198			 res_y - 480 + 198

0x0037D49F		40020000		576			 res_x - 64
0x0037D4A6		46010000		326			 res_y - 480 + 326

0x0037D6EE		40020000		576			 res_x - 64
0x0037D6F5		86010000		390			 res_y - 480 + 390

 

Questions for Avenger:

-> with the first batch of information, is it possible to find the codepaths and similar offsets for SoA, HoW and IWD2 too? (difference: in IWD2, you might have to replace a 1280 with a 1600 somewhere).

-> with the second batch of information, is it possible to find the equivalent offsets in either pure IWD1, pure BG1, or (most important IMHO) PST?

 

A build with TotSC support and (1280|800)xY in ToB will be up shortly.

 

EDIT: HoW&IWD2 @1280|800xY done. For SoA, done with blind hacking: can you confirm that 0x324f3 is for the "if (x >= 1280)", 0x324ff is for the "if (x == 1280)" => 1280 and 0x3250f is for the "if (x == 800)"?

Link to comment

PST:

Well, if i understood correctly totsc has no variable resolution, and he provided the magic numbers for it. And you want me to check PST for an analogous change?

 

IWD2:

I guess, you understood the IWD2 part, and can cope with it. 1280 is indeed replaced with 1600. (There are 2 numbers of this high resolution number close to each other, but you modified only one of them so far).

Link to comment

IWD2: it works at (800|1280|1600)xY, so I'd say it works as is :)

PST: you said that with access to ToB magic numbers you could find the similar magic numbers for the other games with selectable resolutions (SoA, IWD2, HoW). I hoped that, with the TotSC magic numbers, you could find something similar for either plain BG1, plain IWD1, or PST.

Link to comment

I have 1.3.0.1 5512 and the offsets are the same. Perhaps it depends on the game version (I.E. International vs. American vs. European)? My bgmain2.exe has md5 da3527afc6b8ed1cc82e7b8d7ae41c7f and size 5042223.

 

Are you sure about having 1.3.0.1 5521?

Link to comment

This seems promising (my totsc version):

(subtract 400000)

 

0079DB91 55				   push		ebp
0079DB92 8B EC				mov		 ebp,esp
0079DB94 51				   push		ecx
0079DB95 89 4D FC			 mov		 dword ptr [ebp-4],ecx
0079DB98 8B 45 08			 mov		 eax,dword ptr [ebp+8]
0079DB9B C7 00 80 02 00 00	mov		 dword ptr [eax],280h
0079DBA1 8B 4D 0C			 mov		 ecx,dword ptr [ebp+0Ch]
0079DBA4 C7 01 E0 01 00 00	mov		 dword ptr [ecx],1E0h
0079DBAA 8B E5				mov		 esp,ebp
0079DBAC 5D				   pop		 ebp
0079DBAD C2 08 00			 ret		 8

 

The same in PST:

 

0082CF97 55				   push		ebp
0082CF98 8B EC				mov		 ebp,esp
0082CF9A 51				   push		ecx
0082CF9B 89 4D FC			 mov		 dword ptr [ebp-4],ecx
0082CF9E 8B 45 08			 mov		 eax,dword ptr [ebp+8]
0082CFA1 C7 00 80 02 00 00	mov		 dword ptr [eax],280h
0082CFA7 8B 4D 0C			 mov		 ecx,dword ptr [ebp+0Ch]
0082CFAA C7 01 E0 01 00 00	mov		 dword ptr [ecx],1E0h
0082CFB0 8B E5				mov		 esp,ebp
0082CFB2 5D				   pop		 ebp
0082CFB3 C2 08 00			 ret		 8

 

Now, i just need to find 2 more pairs for PST, and hope you got the same version.

But even if not, you can simply look for the same sequences,

i think c7 00 80 02 00 00 is enough.

Link to comment

Just repeating, if it wasn't clear from the earlier note:

 

2 of the 6 magic numbers for PST are these: 0x42cfa3/0x42cfac

 

I believe i found the second pair:

 

0082E69E 52				   push		edx
0082E69F 68 E0 01 00 00	   push		1E0h
0082E6A4 68 80 02 00 00	   push		280h
0082E6A9 A1 18 E8 96 00	   mov		 eax,[0096E818]

 

Which makes them 0x42e6a0/0x42e6a5

Link to comment

I hate myself. They work, but not in windowed mode, only in fullscreen :)

 

Mouse is not scrolling out of the 640x480 box, but I don't know if it's a problem with a magic number or with GUI files.

 

Since it's getting a bit late, I'll check those later.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...