Offsets CPU Fix 1.13c Menus

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

User avatar
Specktro
Posts: 78
Joined: Sat Jun 10, 2017 12:49 am
Location: Rio Grande do Sul, Brasil
Brazil

Offsets CPU Fix 1.13c Menus

Post by Specktro » Tue Dec 18, 2018 11:00 pm

Hi Everyone...
I've been looking around for cpu fix for 1.13c, and found codes provided by Necrolis for 1.10, just like by Sampson for 1.13c, but both for ingame fix...
GalaXyHaXz posted all the offsets for 1.14d here: viewtopic.php?t=62140
But I was mad I couldn't find the offsets he posted (of course "translating" to 1.13c), coz all the codes, but this one, were in d2client.dll... Menu codes were in D2Win.dll...
So Just in case someone in future will search for the codes, I'm posting here all in one topic... to make things easier...

CPU Fix 1.13c Single, Closed and Open Bnet:
Found in D2CLIENT.DLL

Code: Select all

; For Single Player
0003CB83   75 17            JNZ SHORT 0003CB9C  //NOP
0003CB85   A1 94C3BC6F      MOV EAX,DWORD PTR DS:[6FBCC394]
0003CB8A   83F8 06          CMP EAX,6

; For Closed Bnet
0003CB8D   74 0D            JE SHORT 0003CB9C  //NOP
0003CB8F   83F8 08          CMP EAX,8

; For Closed and IP Games
0003CB92   74 08            JE SHORT 0003CB9C  //NOP
0003CB94   6A 0A            PUSH 0A                   //Time = 10ms
0003CB96   FF15 A0EFB76F    CALL DWORD PTR DS:[6FB7EFA0]	//Sleep
CPU Fix 1.13c for Main Menu, Waitingroom, Charselect, etc:
Found in D2WIN.DLL

Code: Select all

00018A5F   74 02            JE SHORT D2Win.6F8F8A63  //NOP
00018A61   33C0             XOR EAX,EAX
00018A63   50		    PUSH EAX                 //Timeout
00018A64   FF15 C8B28F6F    CALL DWORD PTR [<&KERNEL32>]	//Sleep
Hope it helps someone... And sorry for my bad english...


Edit:
Credits (for helping me directly or indirectly on my search for this)

Necrolis
Sampson
GalaXyHaXz
Killer gorilla
Enceladus
and devurandom for helping with the credits.. haha
Last edited by Specktro on Thu Dec 20, 2018 10:34 pm, edited 1 time in total.
Image
Be Xtreme!

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

Re: Offsets CPU Fix 1.13c Menus

Post by devurandom » Wed Dec 19, 2018 2:24 am

Original credit for first fix to "Killer gorilla" on phrozen keep.
Original credit for second fix to "Enceladus", posted on Russian website long before it was ported to 1.14d.
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin

Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..

User avatar
Specktro
Posts: 78
Joined: Sat Jun 10, 2017 12:49 am
Location: Rio Grande do Sul, Brasil
Brazil

Re: Offsets CPU Fix 1.13c Menus

Post by Specktro » Wed Dec 19, 2018 9:57 pm

devurandom wrote:
Wed Dec 19, 2018 2:24 am
Original credit for first fix to "Killer gorilla" on phrozen keep.
Original credit for second fix to "Enceladus", posted on Russian website long before it was ported to 1.14d.
Thanks for helping with credits 🙂...
Image
Be Xtreme!

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

Re: Offsets CPU Fix 1.13c Menus

Post by devurandom » Thu Dec 20, 2018 4:49 am

np. I had both edits from Enceladus, but didn't post both at the time.
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin

Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..

User avatar
Darion
Posts: 14
Joined: Mon Aug 27, 2018 12:22 pm

Re: Offsets CPU Fix 1.13c Menus

Post by Darion » Fri Dec 21, 2018 7:07 am

This menu fix doesn't work for me at all, and the in-game fixes are working, but not that impressive.

I'm playing v1.13d with Sven's glide wrapper (to lock 100 fps), on Win10 using a quad-core PC.
In the menu, with or without the edit, D2 would always cousume ~20% CPU (almost a full core);
In game, after using this edit, the CPU usage does cut in half (from 10% to 5%), but at the price of losing a significant amount of fps (from 100 fps to ~30 fps). The screen, the mouse and everything becomes so choppy, almost unplayable.
And last my GPU usage is always high (60%) when playing, with or without the edit.

Not sure if it's just me, or glide interferes these somehow, but I end up not using this edit at all.

User avatar
Specktro
Posts: 78
Joined: Sat Jun 10, 2017 12:49 am
Location: Rio Grande do Sul, Brasil
Brazil

Re: Offsets CPU Fix 1.13c Menus

Post by Specktro » Sat Dec 22, 2018 3:46 pm

Darion wrote:
Fri Dec 21, 2018 7:07 am
This menu fix doesn't work for me at all, and the in-game fixes are working, but not that impressive.

I'm playing v1.13d with Sven's glide wrapper (to lock 100 fps), on Win10 using a quad-core PC.
In the menu, with or without the edit, D2 would always cousume ~20% CPU (almost a full core);
In game, after using this edit, the CPU usage does cut in half (from 10% to 5%), but at the price of losing a significant amount of fps (from 100 fps to ~30 fps). The screen, the mouse and everything becomes so choppy, almost unplayable.
And last my GPU usage is always high (60%) when playing, with or without the edit.

Not sure if it's just me, or glide interferes these somehow, but I end up not using this edit at all.
Those offsets are for 1.13C...
You can find 1.13d working here: viewtopic.php?t=62140
Image
Be Xtreme!

User avatar
Darion
Posts: 14
Joined: Mon Aug 27, 2018 12:22 pm

Re: Offsets CPU Fix 1.13c Menus

Post by Darion » Sun Dec 23, 2018 2:22 pm

Specktro wrote:
Sat Dec 22, 2018 3:46 pm
Those offsets are for 1.13C...
Ye I know that... the offsets are different on other versions, but the codes are identical.
What I mean is that this fix doesn't work very well, at least in my case. CPU usage is not the problem, FPS is.
And for the menu part, it doesn't work at all.

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

Re: Offsets CPU Fix 1.13c Menus

Post by devurandom » Mon Dec 24, 2018 12:08 am

Edit:

The Client cpu fix (2) different methods all patch into the client frame render code. The Client cpu fix I use now is included the remove 25 FPS limit, because its part of the client frame render code. If you have more than one client cpu fix method, it would cause a lot of frame render issues/lag. Glide3x is a separate issue.
The other patch is for Out of Game Drawing loop (OOG).

I would have to add this.. as far as I know only Necrolis has properly fixed this issue by rewriting that code.
none of the asm fixes address it properly, why render at a higher rate than monitor refresh.
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin

Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..

User avatar
Necrolis
Senior Admin
Throne
Posts: 9125
Joined: Sat Mar 25, 2006 1:22 pm
Location: The Land of the Dead
South Africa

Hand-picked

Re: Offsets CPU Fix 1.13c Menus

Post by Necrolis » Mon Dec 24, 2018 9:19 am

The best fix for this involves doing a few things:
1) Enabled vsync via the D2GFX ordinal (which may not work in windowed mode/GDI, but should work fine with glide wrapper, which in itself allows forcing of vsync). If you are feeling fancy, you can use adaptive VSync, but then you have to iinterface with the current rendering backend yourself. There is literally no point rendering any faster than the refresh rate of your monitor, so VSync is a good way to limit CPU and GPU usage; and remember, D2 was designed to run at 25fps...

2) Removal of the render loop FPS limits, SP is limited to 25fps, menus are limited to 20 fps (this is a relic from D1 :lol: ). There actually isn't really a need to remove the menu ones TBH.

3) Implement a correct thread wait to save on burning the CPU, Sleep'ing for 10ms seems to be loved by everyone, except that you can't actually sleep for less than the system time quanta (see this). SwitchToThread and Sleep with a time of 0ms (this is a special value) would likely be better choices if you don't want to fiddle with the system-wide wait periods.

4) Remember that if you are running an SP game, you are hosting a server, which also needs the thread to be throttled if needed (same goes for hosting in MP etc), hence why your CPU usage will still be high (plus there is also a sound related thread, and some of the GFX drivers spawn an additional thread as well).

If the GPU side is your issue, I'd recommend tuning the GlideWrapper settings, remove things like supersampling that don't actually do much; but remember, GlideWrapper is a wrapper around an very old rendering API, it has some issues, especially on Win10. You'll notice that if you run in windowed mode without the wrapper, you'll have significantly better FPS.
Image
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal

Return to “Code Editing”