Skip to content

GamePatch: add second FFL endian-swap signature for Mario Kart 8#1867

Open
iPixzl wants to merge 1 commit intocemu-project:mainfrom
iPixzl:fix-ffl-mk8-signature
Open

GamePatch: add second FFL endian-swap signature for Mario Kart 8#1867
iPixzl wants to merge 1 commit intocemu-project:mainfrom
iPixzl:fix-ffl-mk8-signature

Conversation

@iPixzl
Copy link
Copy Markdown

@iPixzl iPixzl commented Apr 9, 2026

Add second FFL float-array endian-swap signature for Mario Kart 8

What

Adds a second byte-pattern signature for the existing FFL endian-swap HLE hook in GamePatch.cpp. The original signature is hardcoded to one specific compiled form of the helper and doesn't match Mario Kart 8's build, so the hook silently fails to install and Miis render with missing/broken facial features in-game.

Why v1 doesn't match MK8

Both functions are semantically identical — same loop body (lfsx → bl byte-swap helper → stfsx → index increment → loop) and same register usage — but MK8's compiler scheduled 7 of the 14 prologue instructions in a different order, mostly register saves and the mr r30, r3 argument move. A simple byte mask can't cleanly cover it since the differences are positional rather than per-byte, so a second full signature is the cleanest option.

Verification

Tested on MK8 EU v81 (00050000-1010ed00) against main (b9b46ec).

  • Located the FFL helper at 0x02720bc8 in MK8 via the PPC debugger, confirmed structural match to the function the v1 signature targets.
  • Before the fix: v1 does not match, no hook installed, Miis render with missing eyes/mouth/beard/glasses. Switching CPU mode to interpreter restores correct rendering (consistent with the recompiler LFSX/STFSX issue the v1 hook was added to work around).
  • After the fix: log.txt contains HLE: Hook FFL float array endian swap function (v2) at 0x02720bc8, Miis render correctly.

This may also fix Bug #77 but I haven't tested Super Mario Maker or the Wii U Menu.

Safety

Strictly additive. v1 is tried first; v2 is only attempted on failure. Games currently hitting v1 are unaffected. Games hitting neither signature behave exactly as before.

Changes

src/Cafe/GamePatch.cpp:

  • Added ffl_floatArrayEndianSwap_v2[] (56 bytes)
  • GamePatch_scan() tries v2 as a fallback if v1 doesn't match
  • Added (v1) / (v2) suffix to the debug log to distinguish which signature matched

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.

1 participant