# The Lord of the Rings: War in the North - Legacy Edition 1.0.2 # BID: D70341137DAA544C # INFO: RenderThreadWaitOnGPU blocks game to 59 FPS and causes CPU cores to rampage if not adjusted, but if adjusted to allow perfect 60 FPS image starts tearing, so i decided to not change it DECLARATIONS: - type: variable name: frametime value_type: uint32 default_value: 33333 evaluate: 1000000 / FPS_LOCK_TARGET - type: variable name: refresh_rate value_type: float default_value: 0.01665 evaluate: 0.999 * (1 / REFRESH_RATE) - type: code name: sleep instructions: [ [adrp, x26, $frametime], [ldr, w26, [x26, $frametime]], [sub, w24, w26, 1], [cmp, x0, x24], [b, 0x1B7190] ] - type: code name: sleep2 instructions: [ [adrp, x26, $frametime], [ldr, w26, [x26, $frametime]], [sub, w24, w26, 1], [cmp, x0, x24], [b, 0x1B7238] ] - type: code name: gpuSleep instructions: [ [mov, x0, -2], [svc, 0xB], [mov, x0, 10000], [svc, 0xB], [ret] ] MASTER_WRITE: # RenderThreadWaitOnMainThread, main FPS lock # REF: 98 46 90 52 BA 46 90 52, search for CMP X0, X24 - type: asm_a64 main_offset: 0x1B718C instructions: [ [b, _sleep()] ] - type: asm_a64 main_offset: 0x1B7234 instructions: [ [b, _sleep2()] ] # RenderThreadWaitOnGPU # REF: A8 B2 8C 52 08 91 A7 72 - type: asm_a64 main_offset: 0x25CDD8 instructions: [ [adrp, x8, $refresh_rate], [ldr, w8, [x8, $refresh_rate]] ] # Stabilize CPU usage # patch YieldThread below - type: asm_a64 main_offset: 0x25CDF0 instructions: [ [bl, _gpuSleep()] ] ALL_FPS: - type: block what: timing