Remove 25 FPS limit in Single Player

This forum is for discussions on how to edit what can not be edited through the txt files, needless to say this isn't about battle net hacking.

Moderators: Nefarius, Havvoric

Post Reply
User avatar
devurandom
Forum Regular
Angel
Posts: 604
Joined: Sat Mar 07, 2015 9:07 pm
United States of America

Remove 25 FPS limit in Single Player

Post by devurandom » Fri Mar 23, 2018 5:13 am

I think this question has been asked a few times. The code that handles Frame Rates is quite a mess,
and you'd almost have to rewrite the function to find where the limit is.
Thanks to Necrolis for finding this!



Code: Select all

Remove 25 FPS Limit in Single Player

Credit to Necrolis for finding this


(In v1.14 Glide3x may peak at 200 FPS)
Note: Negative impact on your CPU 
without other edits
=====================================



[1.14d] - Game.0x4F27E


0004F278   391D 04077A00  CMP DWORD PTR DS:[7A0704],EBX
0004F27E   75 24          JNE SHORT 0004F2A4

Change to:

0004F278   90             NOP
0004F279   90             NOP
0004F27A   90             NOP
0004F27B   90             NOP
0004F27C   90             NOP
0004F27D   90             NOP
0004F27E   90             NOP
0004F27F   90             NOP


--------------------------

[1.13d] - D2Client.0x45EA7


00045EA1   391D F046BD6F  CMP DWORD PTR DS:[6FBD46F0],EBX
00045EA7   75 35          JNE SHORT 00045EDE

Change to:


00045EA1   90             NOP
00045EA2   90             NOP
00045EA3   90             NOP
00045EA4   90             NOP
00045EA5   90             NOP
00045EA6   90             NOP
00045EA7   90             NOP
00045EA8   90             NOP


--------------------------

[1.13c] - D2Client.0x44E57


00044E51   391D 9034BD6F  CMP DWORD PTR DS:[6FBD3490],EBX
00044E57   75 35          JNE SHORT 00044E8E

Change to:

00044E51   90             NOP
00044E52   90             NOP
00044E53   90             NOP
00044E54   90             NOP
00044E55   90             NOP
00044E56   90             NOP
00044E57   90             NOP
00044E58   90             NOP


--------------------------

[1.12a] - D2Client.0x7D1E7


0007D1E1   391D 2834BD6F  CMP DWORD PTR DS:[6FBD3428],EBX
0007D1E7   75 35          JNE SHORT 0007D21E

Change to:

0007D1E1   90             NOP
0007D1E2   90             NOP
0007D1E3   90             NOP
0007D1E4   90             NOP
0007D1E5   90             NOP
0007D1E6   90             NOP
0007D1E7   90             NOP
0007D1E8   90             NOP


--------------------------

[1.11b] - D2Client.0x33597


00033591   391D 8036BD6F  CMP DWORD PTR DS:[6FBD3680],EBX
00033597   75 35          JNE SHORT 000335CE

Change to:

00033591   90             NOP
00033592   90             NOP
00033593   90             NOP
00033594   90             NOP
00033595   90             NOP
00033596   90             NOP
00033597   90             NOP
00033598   90             NOP


--------------------------

[1.10f] - D2Client.0xA2CB


0000A2C4   A1 E079BA6F    MOV EAX,DWORD PTR DS:[6FBA79E0]
0000A2C9   85C0           TEST EAX,EAX
0000A2CB   75 2B          JNE SHORT 0000A2F8

Change to:

0000A2C4   A1 E079BA6F    MOV EAX,DWORD PTR DS:[6FBA79E0]
0000A2C9   90             NOP
0000A2CA   90             NOP
0000A2CB   90             NOP
0000A2CC   90             NOP


--------------------------

[1.09d] - D2Client.0x9B5F


00009B5F   392D 400CBB6F  CMP DWORD PTR DS:[6FBB0C40],EBP
00009B65   75 2B          JNE SHORT 00009B92

Change to:

00009B5F   90             NOP
00009B60   90             NOP
00009B61   90             NOP
00009B62   90             NOP
00009B63   90             NOP
00009B64   90             NOP
00009B65   90             NOP
00009B66   90             NOP


--------------------------

[1.09b] - D2Client.0x9B5F


00009B6F   392D E01DBB6F  CMP DWORD PTR DS:[6FBB1DE0],EBP
00009B75   75 2B          JNE SHORT 00009BA2

Change to:

00009B6F   90             NOP
00009B70   90             NOP
00009B71   90             NOP
00009B72   90             NOP
00009B73   90             NOP
00009B74   90             NOP
00009B75   90             NOP
00009B76   90             NOP


Last edited by devurandom on Sun Mar 25, 2018 1:47 pm, edited 1 time in total.
Assembly Reference | 1.13d Code Edits | UVLoD

“The urge to save humanity is almost always a false-face for the urge to rule it." ― H.L. Mencken 1956

User avatar
kidpaddle94
Forum Legend
Principality
Posts: 2055
Joined: Thu Aug 13, 2009 2:54 pm
Location: localhost
Canada

Re: Remove 25 FPS limit in Single Player

Post by kidpaddle94 » Sun Mar 25, 2018 5:23 am

The CMP instruction should be NOP'd out as well, on version where it applies. For example on 1.13c it should be

Code: Select all

00044E51   391D 9034BD6F  CMP DWORD PTR DS:[6FBD3490],EBX
00044E57   75 35          JNE SHORT 00044E8E

Change to:

00044E51   90             NOP
00044E52   90             NOP
00044E53   90             NOP
00044E54   90             NOP
00044E55   90             NOP
00044E56   90             NOP
00044E57   90             NOP
00044E58   90             NOP
Thanks to you & Necrolis for this.

User avatar
devurandom
Forum Regular
Angel
Posts: 604
Joined: Sat Mar 07, 2015 9:07 pm
United States of America

Re: Remove 25 FPS limit in Single Player

Post by devurandom » Sun Mar 25, 2018 1:57 pm

It is best practice to nop out the cmp, but in this case it doesn't matter, cause the flag isn't evaluated before it's set again. I went ahead and changed it anyway. Thanks for noticing that. ;)

Code: Select all

00044E51   391D 9034BD6F CMP DWORD PTR DS:[6FBD3490],EBX
00044E57   75 35         JNE SHORT 00044E8E
00044E59   A1 FCBBBC6F   MOV EAX,DWORD PTR DS:[6FBCBBFC]
00044E5E   3BC3          CMP EAX,EBX
00044E60   74 38         JE SHORT 00044E9A
.......
00044E8E   395C24 10      CMP DWORD PTR SS:[ESP+10],EBX
00044E92   74 06          JE SHORT 00044E9A
Last edited by devurandom on Wed Mar 28, 2018 5:21 am, edited 1 time in total.
Assembly Reference | 1.13d Code Edits | UVLoD

“The urge to save humanity is almost always a false-face for the urge to rule it." ― H.L. Mencken 1956

leekun
Dark Alliance Beta Test
Warrior
Posts: 17
Joined: Wed Jul 19, 2017 9:41 pm

Re: Remove 25 FPS limit in Single Player

Post by leekun » Sun Mar 25, 2018 4:49 pm

Will kidpaddle94's edit fix the "Negative impact on your CPU without other edits" problem? and is there still more side effect, I'm not aware of?

User avatar
devurandom
Forum Regular
Angel
Posts: 604
Joined: Sat Mar 07, 2015 9:07 pm
United States of America

Re: Remove 25 FPS limit in Single Player

Post by devurandom » Wed Mar 28, 2018 9:00 am

You may need CPU Fix, otherwise it just runs the full render rate i.e. the same as TCP/IP Multiplayer. That's the negative impact.

There can be other side effects that take some balancing to fix if adding CPU Fix. one is a possible increase in packet latency, depending on how much sleep time you give to CPU fix.

Would be better overall just to set an absolute frame rate cap, but as mentioned the code is a mess.

EDIT:

What I do is patch @6FAF4E51 [1.13c] to a custom call. It does the CPU fix, and sets a limit on rendering in one small function. Testing gives 10% CPU in Glide3x and 2% CPU for other Render Modes.

Code: Select all

// skip 2 then render  = 100 FPS for Glide3x and 64 FPS all other modes
BOOL __fastcall D2RenderSkip()
{
	Sleep (1);     // replacement for CPU Fix

	if(*gdwRenderMode == VIDEO_MODE_GLIDE)
	{
		if(gdwRenderSkip >= 2)
		{
			gdwRenderSkip = 0;
			return FALSE;
		}
		
		gdwRenderSkip++;
		return TRUE;
	}

	return FALSE;
}
Assembly Reference | 1.13d Code Edits | UVLoD

“The urge to save humanity is almost always a false-face for the urge to rule it." ― H.L. Mencken 1956

Post Reply

Return to “Code Editing”