REDIVIVUS

Proposals / #1036

MISSILE_CreateSubWithSound: nGameFrame and nSpawnCountByLevel are ints (signed remainder and CDQ/SAR halving)

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

Ghidra v1841 · 4ca0e98

The original takes nGameFrame % 2 and % 16 with VC8's signed-remainder idiom, which it emits only for a signed operand: 004ce8c7 MOV ECX,ESI / AND ECX,0x80000001 / JNS / DEC ECX / OR ECX,-2 / INC ECX / JNZ, and 004ce8e1 AND ESI,0x8000000f / JNS / DEC / OR ESI,-0x10 / INC / JNZ (ESI = [EBP+0xc], nGameFrame). It then halves the spawn count signed: 004ce91d CMP ESI,1 / JLE / MOV EAX,ESI / CDQ / SUB EAX,EDX / ... / SAR EBX,1. With nGameFrame uint32_t (Stack[0x8]) and nSpawnCountByLevel (ECX) resolving to uint, the decompiler prints the idiom expanded and the generator halves with SHR. Recompiled with VC8 SP1 (the 1.14d compiler) on main f26206a: with both as int the halving is the original's CDQ/SUB/SAR (0.289 -> 0.344, no function in the TU changes status); written as nGameFrame % 2 / % 0x10, which the idiom compiles from, the function is a byte match on the oracle bench.

Changes 2, applied together

  1. Retype variable win 0x004ce850 Stack[0x8]

    typeuint32_t→int
  2. Retype variable win 0x004ce850 ECX

    typeundefined4→int