match(SaveDataManager): decompile isEqualChannel #677

Merged
coah80 merged 2 commits from agent/asm2c/isEqualChannel into main 2026-10-02 00:47:51 +00:00
coah80 commented 2026-10-02 00:02:04 +00:00 (Migrated from github.com)

Summary

Decompile ipl::savedata::Manager::isEqualChannel from asm to exact C++.

Match

  • Function: isEqualChannel__Q33ipl8savedata7ManagerFUxUx
  • Instructions: 39/39
  • Instruction diff: 0
  • DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d (ninja build/43U/ok)

Before (asm)

        asm int Manager::isEqualChannel(register ESTitleId titleId0, register ESTitleId titleId1) {
            nofralloc
            xor r3, r6, r8
            xor r0, r5, r7
            or. r0, r3, r0
            bne isEqualChannel_L1
            li r3, -2
            blr
        isEqualChannel_L1:
            li r3, -0x100
            li r0, -1
            and r9, r6, r3
            and r3, r8, r3
            and r4, r5, r0
            and r0, r7, r0
            xor r3, r9, r3
            xor r0, r4, r0
            or. r0, r3, r0
            bne isEqualChannel_L4
            clrlwi r3, r6, 0x18
            xori r0, r3, 0x41
            cmpwi r0, 0
            beq isEqualChannel_L2
            clrlwi r0, r8, 0x18
            xori r0, r0, 0x41
            cmpwi r0, 0
            bne isEqualChannel_L2
            li r3, 0
            blr
        isEqualChannel_L2:
            xori r0, r3, 0x41
            cmpwi r0, 0
            bne isEqualChannel_L3
            clrlwi r0, r8, 0x18
            xori r0, r0, 0x41
            cmpwi r0, 0
            beq isEqualChannel_L3
            li r3, 1
            blr
        isEqualChannel_L3:
            li r3, -1
            blr
        isEqualChannel_L4:
            li r3, -1
            blr
        }

After (C++)

        int Manager::isEqualChannel(register ESTitleId titleId0, register ESTitleId titleId1) {
            if (titleId0 == titleId1) {
                return -2;
            }

            if (TITLE_NO_REGION(titleId0) == TITLE_NO_REGION(titleId1)) {
                if (TITLE_REGION(titleId0) != TITLE_REGION_ALL) {
                    if (TITLE_REGION(titleId1) == TITLE_REGION_ALL) {
                        return 0;
                    }
                }

                if (TITLE_REGION(titleId0) == TITLE_REGION_ALL) {
                    if (TITLE_REGION(titleId1) != TITLE_REGION_ALL) {
                        return 1;
                    }
                }

                return -1;
            }

            return -1;
        }

Notes

  • Exact equality returns -2
  • TITLE_NO_REGION compare (four ands via 0xFFFFFFFFFFFFFF00) then region A (0x41) asymmetry returns 0 / 1
  • Positive TITLE_NO_REGION equality keeps the target bne to a second -1 return
  • One function only; please do not merge until reviewed
## Summary Decompile `ipl::savedata::Manager::isEqualChannel` from asm to exact C++. ## Match - Function: `isEqualChannel__Q33ipl8savedata7ManagerFUxUx` - Instructions: **39/39** - Instruction diff: **0** - DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d` (`ninja build/43U/ok`) ## Before (asm) ```cpp asm int Manager::isEqualChannel(register ESTitleId titleId0, register ESTitleId titleId1) { nofralloc xor r3, r6, r8 xor r0, r5, r7 or. r0, r3, r0 bne isEqualChannel_L1 li r3, -2 blr isEqualChannel_L1: li r3, -0x100 li r0, -1 and r9, r6, r3 and r3, r8, r3 and r4, r5, r0 and r0, r7, r0 xor r3, r9, r3 xor r0, r4, r0 or. r0, r3, r0 bne isEqualChannel_L4 clrlwi r3, r6, 0x18 xori r0, r3, 0x41 cmpwi r0, 0 beq isEqualChannel_L2 clrlwi r0, r8, 0x18 xori r0, r0, 0x41 cmpwi r0, 0 bne isEqualChannel_L2 li r3, 0 blr isEqualChannel_L2: xori r0, r3, 0x41 cmpwi r0, 0 bne isEqualChannel_L3 clrlwi r0, r8, 0x18 xori r0, r0, 0x41 cmpwi r0, 0 beq isEqualChannel_L3 li r3, 1 blr isEqualChannel_L3: li r3, -1 blr isEqualChannel_L4: li r3, -1 blr } ``` ## After (C++) ```cpp int Manager::isEqualChannel(register ESTitleId titleId0, register ESTitleId titleId1) { if (titleId0 == titleId1) { return -2; } if (TITLE_NO_REGION(titleId0) == TITLE_NO_REGION(titleId1)) { if (TITLE_REGION(titleId0) != TITLE_REGION_ALL) { if (TITLE_REGION(titleId1) == TITLE_REGION_ALL) { return 0; } } if (TITLE_REGION(titleId0) == TITLE_REGION_ALL) { if (TITLE_REGION(titleId1) != TITLE_REGION_ALL) { return 1; } } return -1; } return -1; } ``` ## Notes - Exact equality returns `-2` - `TITLE_NO_REGION` compare (four `and`s via `0xFFFFFFFFFFFFFF00`) then region `A` (`0x41`) asymmetry returns `0` / `1` - Positive `TITLE_NO_REGION` equality keeps the target `bne` to a second `-1` return - One function only; please do not merge until reviewed
coah80 commented 2026-10-02 00:02:45 +00:00 (Migrated from github.com)

Almost there: converting isEqualChannel from asm to C is great. The C signature still carries the register keyword from the old asm version (register ESTitleId titleId0, register ESTitleId titleId1), and register is forbidden in new C. Drop both, check it still matches 100%, and push. It'll re-run and merge automatically.

Almost there: converting isEqualChannel from asm to C is great. The C signature still carries the `register` keyword from the old asm version (`register ESTitleId titleId0, register ESTitleId titleId1`), and `register` is forbidden in new C. Drop both, check it still matches 100%, and push. It'll re-run and merge automatically.
coah80 commented 2026-10-02 00:47:49 +00:00 (Migrated from github.com)

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.
Sign in to join this conversation.