Need for Speed: Porsche Unleashed on over 2.1 GHz CPU LOD patch

After releasing a patch to limit the number of resolutions NFS: PU reports, I had to look a the problem of setting the wrong LOD (Level of Detail) for textures on fast PCs. It was empirically proven, that on CPUs running above 2 GHz all textures were set to the lowest detail what caused ugly graphics. On a x86 a program can use the Read Time-Stamp Counter (RDTSC) intruction to get the CPU clock rate. A quick search in OllyDbg has found 10 places w porsche.exe, where it is used. By setting brakepoints counting invocations on procedures executing RDTSC I’ve pinpointed the one run at the start of every race. The patch simply changes the return value of this procedure:

0055609D  |. 75 08          JNZ     SHORT Porsche_.005560A7
0055609F  |. 8B4D F8        MOV     ECX, [LOCAL.2]
005560A2  |. 894D FC        MOV     [LOCAL.1], ECX
005560A5  |. 8BC1           MOV     EAX, ECX
005560A7  |> 8D0480         LEA     EAX, DWORD PTR DS:[EAX+EAX*4]
005560AA  |. 8BE5           MOV     ESP, EBP
005560AC  |. 5D             POP     EBP
005560AD  \. C3             RETN

to:

0055609D  |. 75 06          JNZ     SHORT Porsche.005560A5
0055609F  |. 8B4D F8        MOV     ECX, [LOCAL.2]
005560A2  |. 894D FC        MOV     [LOCAL.1], ECX
005560A5  |> B8 0000007F    MOV     EAX, 7F000000
005560AA  |. 8BE5           MOV     ESP, EBP
005560AC  |. 5D             POP     EBP
005560AD  \. C3             RETN

Since the value was returned in EAX, I’ve put there the constant 0x7F000000 which basically means it always reports a CPU clocked at around 2 GHz. Additionally I had to modify the jump at @0055609D, because it pointed to an invalid location after the previous change. Several people on the nfstuning.com forum tested it and confirmed it works.

About GL1zdA

Who cares?
This entry was posted in Reverse Engineering and tagged , , , , . Bookmark the permalink.

5 Responses to Need for Speed: Porsche Unleashed on over 2.1 GHz CPU LOD patch

  1. Vince says:

    Hello, can you explain to me how to get this to work? That would be amazing! Not sure what i need to do exactly. This CPU fix is the only patch what i need for my retro PC.

    • GL1zdA says:

      Use Verok’s patch: https://verokster.blogspot.com/2019/11/need-for-speed-porsche-unleashed-patch.html , it already has this fix and works nice for me.

      • Vince says:

        Yea i know, but it has additional fixes. I want the game as original as possible without all the other patches. Maybe you can explain the steps, but if its a lot of work for you dont even mind.

      • GL1zdA says:

        You basically have to open porsche.exe in a hex editor (HxD is a good one https://mh-nexus.de/en/hxd/ ), find hex values: “75 08 8B 4D F8 89 4D FC 8B C1 8D 04 80 8B E5 5D C3” and overwrite them with “75 06 8B 4D F8 89 4D FC B8 00 00 00 7F 8B E5 5D C3”. It’s at offset 0015609D in mine version.

        I think the original version was protected with SafeDisc, so you probably need a cracked Porsche.exe file for it or find UnSafeDisc 1.5.5.

  2. Vince says:

    You’re a Hero. (even with original disc and exe 3.5 on 98SE ;D)

Leave a comment