Skip to content

Some small corrections - #773

Merged
SquareMan merged 2 commits into
bfbbdecomp:mainfrom
joeyballentine:xfx-aura-fixes
Aug 4, 2026
Merged

Some small corrections #773
SquareMan merged 2 commits into
bfbbdecomp:mainfrom
joeyballentine:xfx-aura-fixes

Conversation

@joeyballentine

@joeyballentine joeyballentine commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

While looking into compiler patches, I noticed the patched compiler produced worse fuzzy matches for a few functions. Some were able to 100% after the patch, but two were able to 100% with the stock compiler. Rather than include those fixes in a PR with the patch, I decided to make a separate PR

Four separate defects, all visible once the aura loop is read against the
retail body:

- `ap = (_xFXAura*)ap->dangle` advanced the cursor by the offset of `dangle`
  (0x1C) rather than by sizeof(_xFXAura), which DWARF gives as 0x24. The array
  was being walked misaligned. It is a plain `ap++`; retail emits
  `addi r30,r30,36`.
- The billboard size arguments were hardcoded to 0 where retail loads
  `ap->size` (offset 16). RenderRotatedBillboard is currently an empty stub, so
  there is no behaviour change today, but the arguments are now correct.
- `RwRenderStateGet(rwRENDERSTATEFOGTYPE, (void*)0x1)` passed the integer 1
  where RenderWare writes the out-value -- a store to address 1 -- and queried
  the wrong enumerator. It is
  `RwRenderStateGet(rwRENDERSTATEFOGENABLE, &fogstate)`, which is what the
  otherwise-unused `fogstate` local, present in the DWARF, is for.
- The matching restore then wrote a hardcoded 0x10 instead of the saved value.

    xFXAuraRender  84.0660% -> 100%
    matched functions  6401 -> 6402

xFX is the only unit that changes; the DOL sha1 is unchanged.
The frame-time constant was written 0.01666667f, which rounds to 0x3C88888A.
The .sdata2 of the reference object holds 0x3C888889 -- exactly 1/60 in single
precision, i.e. one more digit: 0.016666667f.

This corrects the emitted constant rather than any instruction, so it moves the
data section only:

    zNPCTypeRobot .sdata2  25.2475% -> 25.7426%

No function reaches 100% from it and the matched-function count is unchanged at
6402. zNPCTypeRobot is the only unit that changes; the DOL sha1 is unchanged.
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

main/SB/Core/x/xFX

Section From To Bytes
📈 .text 29.75% 29.81% +15
Function From To Bytes
xFXAuraRender() 96.25% 100.00% +15

@joeyballentine
joeyballentine marked this pull request as ready for review August 3, 2026 20:19
@SquareMan
SquareMan merged commit 8219bd8 into bfbbdecomp:main Aug 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants