REDIVIVUS

Proposals / #1034

D2GFX_InitializeLineBuffer's nBlendValue is an int: clamped with SETLE/JL and shifted with SAR

applied · by Niehztog · submitted 2026-11-02, applied 2026-11-02

Ghidra v1841 · 4ca0e98

nBlendValue (EAX) is a signed 8.24 fixed-point ramp written into the table at 0x007ca320: 004f7cfa TEST EAX,EAX / 004f7cfc SETLE BL / SUB EBX,1 / AND EAX,EBX (clamp below 0), 004f7d04 CMP EAX,0x1f000000 / 004f7d09 JL (clamp above), 004f7d12 SAR EBX,0x18 (the byte it stores), and after the row 004f7d22 SAR EAX,0x18 / CMP EAX,EDX. Ghidra leaves it undefined4 and resolves it to uint, so the generator declares uint32_t; the stored byte then comes from SHR, and the source needs (int) casts for the clamps. Recompiled with VC8 SP1 (the 1.14d compiler) on main f26206a with the local as int: the shift is the original's SAR, the function's similarity rises 0.806 -> 0.819, and no function in the TU changes status.

Changes 1, applied together

  1. Retype variable win 0x004f7cc0 EAX

    typeundefined4→int