Getting Tekken Tag Tournament 2 to work with the tools

Author: DennisStanistanCreated Mar 4, 2025Updated Aug 25, 2026

Documenting my process for getting ttt2 recompiled for others to see, it might be of help for other games (i know nothing about x360 modding and it's my first time reading powerpc instructions, i come from an x86 background.) If you know what you're doing you'll get further with this project than me, feel free to use this as a reference

anyway, the analyzer tries to scan for switch tables using the following instructions (sonic unleashed uses this pattern before the tables):

PPC_INST_LIS,
PPC_INST_ADDI,
PPC_INST_RLWINM,   // SLWI alias
PPC_INST_LWZX,
PPC_INST_MTCTR,
PPC_INST_BCTR

where as in tag 2 (and probably other games) it's:

PPC_INST_LIS,
PPC_INST_RLWINM,   // SLWI alias
PPC_INST_ADDI,
PPC_INST_LWZX,
PPC_INST_MTCTR,
PPC_INST_BCTR

ADDI and RLWINM are swapped, so changing the values in absoluteSwitch to:

cpp
uint32_t absoluteSwitch[] =
    {
        PPC_INST_LIS,
        PPC_INST_RLWINM,   // (slwi alias)
        PPC_INST_ADDI,
        PPC_INST_LWZX,
        PPC_INST_MTCTR,
        PPC_INST_BCTR
    };

and adjusting the ReadTable function to properly offset the instructions from:

cpp
 auto* code = (uint32_t*)image.Find(table.base);
    ppc::Disassemble(code, table.base, insn);
    pOffset = insn.operands[1] << 16;

    ppc::Disassemble(code + 1, table.base + 4, insn);
    pOffset += insn.operands[2];

to

cpp
auto* code = (uint32_t*)image.Find(table.base);
    ppc::Disassemble(code, table.base, insn);           // lis
    pOffset = insn.operands[1] << 16;                   // Upper 16 bits

    ppc::Disassemble(code + 2, table.base + 8, insn);   // addi (skip rlwinm at +4)
    pOffset += insn.operands[2];                        // Lower 16 bits

now we're getting a proper switch table, here's an example:

toml
[[switch]]
base = 0x822537A4
r = 11
default = 0x82253868
labels = [
    0x82253854,
    0x82253868,
    0x82253854,
    0x82253854,
    0x82253868,
    0x82253854,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253854,
    0x82253868,
    0x82253868,
    0x82253854,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253854,
    0x82253868,
    0x82253868,
    0x82253868,
    0x82253854,
    0x82253868,
    0x82253854,
    0x82253868,
    0x82253854,
    0x82253868,
    0x82253868,
    0x82253854,
]

...

looks perfect to what we see in r2:

c
[0x822400ec]> /x 7c0903a6 @ 0x82240000..0x82da0000
0x82253fb4 hit9_0 7c0903a6
0x82254214 hit9_1 7c0903a6
0x822545b0 hit9_2 7c0903a6
0x822550b0 hit9_3 7c0903a6
0x82255890 hit9_4 7c0903a6
0x82268f1c hit9_5 7c0903a6
0x8226c000 hit9_6 7c0903a6
...
[0x822400ec]> s hit9_0
[0x82253fb4]> pd 10
│           ;-- hit0_0:
│           ;-- hit9_0:
│           0x82253fb4      7c0903a6       mtctr r0
│           0x82253fb8      4e800420       bctr
            0x82253fbc      .dword 0x82253854 ; aav.0x82253854 # Wow!
            0x82253fc0      .dword 0x82253868 ; aav.0x82253868
            0x82253fc4      .dword 0x82253854 ; aav.0x82253854
            0x82253fc8      .dword 0x82253854 ; aav.0x82253854
            0x82253fcc      .dword 0x82253868 ; aav.0x82253868
            0x82253fd0      .dword 0x82253854 ; aav.0x82253854
            0x82253fd4      .dword 0x82253868 ; aav.0x82253868
            0x82253fd8      .dword 0x82253868 ; aav.0x82253868
[0x82253fb4]> 

Now for the config toml file, here's the bare minimum I got to make it generate the recompiled files without getting a segfault:

toml
[main]
file_path = "Default_unpacked.xex"
out_directory_path = "ppc"
switch_table_file_path = "jump_tables.toml"

restgprlr_14_address = 0x82bafea0
savegprlr_14_address = 0x82bafe50
restfpr_14_address = 0x82bb0b3c
savefpr_14_address = 0x82bb0af0
restvmx_14_address = 0x82bb1d58
savevmx_14_address = 0x82bb1ac0
savevmx_64_address = 0x82bb1b54
restvmx_64_address = 0x82bb1dec

Getting the rest/save addresses is pretty straight forward: https://github.com/hedge-dev/XenonRecomp/tree/main?tab=readme-ov-file#register-restore--save-functions

Right now i'm stuck at trying to get it compiled without anything special, just the raw ppc files themselves as a test. i'm getting errors for: "error: use of undeclared label 'loc_82BAFE5C'" in lots of places, XenonRecomp did warn me about switch cases jumping out of functions like:

ERROR: Switch case at 822FA970 is trying to jump outside function: 822FAC64
ERROR: Switch case at 822FA970 is trying to jump outside function: 822FAC64
ERROR: Switch case at 822FA970 is trying to jump outside function: 822FAC64
ERROR: Switch case at 822FA970 is trying to jump outside function: 822FAC64
ERROR: Switch case at 822FA970 is trying to jump outside function: 822FAB58
ERROR: Switch case at 822FA970 is trying to jump outside function: 822FAC64
ERROR: Switch case at 822FA970 is trying to jump outside function: 822FAAA8
ERROR: Switch case at 822FA970 is trying to jump outside function: 822FAAC4

and also some unrecognized instructions:

Unrecognized instruction at 0x82D6E3B8: lhzu
Unrecognized instruction at 0x82D6E3BC: sthu
Unrecognized instruction at 0x82D6E3DC: lhzu
Unrecognized instruction at 0x82D6E3E0: sthu
Unrecognized instruction at 0x82D6E3FC: lhzu
Unrecognized instruction at 0x82D6E400: sthu
Unrecognized instruction at 0x82D6E41C: lhzu
Unrecognized instruction at 0x82D6E420: sthu
Unrecognized instruction at 0x82D6E43C: lhzu
Unrecognized instruction at 0x82D6E440: sthu
Unrecognized instruction at 0x82D6E45C: lhzu
Unrecognized instruction at 0x82D6E460: sthu
Unrecognized instruction at 0x82D6E47C: lhzu
Unrecognized instruction at 0x82D6E480: sthu
Unrecognized instruction at 0x82D6E49C: lhzu
Unrecognized instruction at 0x82D6E4A0: sthu

For now I gotta edit the analyzer to account for the function boundaries because I really don't wanna do it manually so i'll update here if I get anything working