Recompile the outputted .cpp files?
I did everything the instructions told me to, i found all of the addresses, i put them in the toml, i checked to make sure everything was correct, and yep! it outputted some cpp files. what do i do with them afterwards though?? ive tried opening them all in visual studio to compile them with clang but it just gives errors about things like __builtin_rotateleft64, and __bf16 The game I'm trying to recompile is The Legend of Spyro: Dawn of the Dragon
I can't be sure about it without seeing your workspace, but your error about __builtin_rotateleft64 reminds me of #17 which is related to the compiler. Visual Studio really wants to use MSVC and I don't have a lot of experience with VS so I just switched to CLion where you can specify the compiler by hand in the toolchain configuration.
This is bound to be far from the end of your problems though.
I think that you have to reimplement/redefine some functions that are part of the Xbox360 kernel, such as __imp__XGetGameRegion before being able to recompile your project, but I wonder how those should be declared. In the UnleashedRecomp project, there doesn't seem to be any reference to the PPC_EXTERN_FUNC macro but GUEST_FUNCTION_HOOK fills a similar purpose.
I wonder if we need to use mid-asm hooks for those functions, or if adding our own .cpp file with a block such as
__attribute__((alias("__imp__XGetGameRegion"))) PPC_WEAK_FUNC(XGetGameRegion);
PPC_FUNC_IMPL(__imp__XGetGameRegion) {
...
}
would be the way. The patching mechanism mentioned here also sounds interesting.
I've also followed the instruction and got the recomp to generate bunch of ppc file. However, I've been getting hit with same errors here. The question is, which compiler are we supposed to use on windows? I tried gcc from MSYS2, g++ from MinGW, none of which is working.
I've also followed the instruction and got the recomp to generate bunch of ppc file. However, I've been getting hit with same errors here. The question is, which compiler are we supposed to use on windows? I tried gcc from MSYS2, g++ from MinGW, none of which is working.
The recompiler uses CLANG optimizations so it's not surprising GCC and G++ don't recognize a lot of instructions
I've also followed the instruction and got the recomp to generate bunch of ppc file. However, I've been getting hit with same errors here. The question is, which compiler are we supposed to use on windows? I tried gcc from MSYS2, g++ from MinGW, none of which is working.
The recompiler uses CLANG optimizations so it's not surprising GCC and G++ don't recognize a lot of instructions
that explains it. I might install WSL later
I've also followed the instruction and got the recomp to generate bunch of ppc file. However, I've been getting hit with same errors here. The question is, which compiler are we supposed to use on windows? I tried gcc from MSYS2, g++ from MinGW, none of which is working.
The recompiler uses CLANG optimizations so it's not surprising GCC and G++ don't recognize a lot of instructions
that explains it. I might install WSL later
MSYS2 has a CLANG64 environment that should make compilation to Windows OSes easier, you can use one of my artifacts otherwise, though the branch with the actions isn't up to date with the main code
I've also followed the instruction and got the recomp to generate bunch of ppc file. However, I've been getting hit with same errors here. The question is, which compiler are we supposed to use on windows? I tried gcc from MSYS2, g++ from MinGW, none of which is working.
The recompiler uses CLANG optimizations so it's not surprising GCC and G++ don't recognize a lot of instructions
that explains it. I might install WSL later
MSYS2 has a CLANG64 environment that should make compilation to Windows OSes easier, you can use one of my artifacts otherwise, though the branch with the actions isn't up to date with the main code
I'll check it out, thanks. Altho I probably will still install WSL because of some changes I've made on recomp in order to work with missing instructions, which is taken from PR #1
I think that you have to reimplement/redefine some functions that are part of the Xbox360 kernel, such as
__imp__XGetGameRegionbefore being able to recompile your project, but I wonder how those should be declared. In the UnleashedRecomp project, there doesn't seem to be any reference to thePPC_EXTERN_FUNCmacro butGUEST_FUNCTION_HOOKfills a similar purpose.I wonder if we need to use mid-asm hooks for those functions, or if adding our own .cpp file with a block such as
attribute((alias("__imp__XGetGameRegion"))) PPC_WEAK_FUNC(XGetGameRegion); PPC_FUNC_IMPL(__imp__XGetGameRegion) { ... }
would be the way. The patching mechanism mentioned here also sounds interesting.
UnleashedRecomp handles these by defining them in the runtime project, and since the functions in ppc_recomp.*.cpp files are weakly linked they just get overriden with your implementation. So if you wanted to implement that function you'd declare it like:
PPC_FUNC(XGetGameRegion)
{
// your implementation here...
}
and all calls to this import would get replaced. The GUEST_FUNCTION_HOOK in the codebase is a helper to translate the PPC registers to real function arguments, which is implemented here: https://github.com/hedge-dev/UnleashedRecomp/blob/main/UnleashedRecomp/kernel/function.h
So if you wanted to implement that function you'd declare it like:
PPC_FUNC(XGetGameRegion) { // your implementation here... } and all calls to this import would get replaced. The GUEST_FUNCTION_HOOK in the codebase is a helper to translate the PPC registers to real function arguments, which is implemented here: https://github.com/hedge-dev/UnleashedRecomp/blob/main/UnleashedRecomp/kernel/function.h
I'm struggling to get this working. where would i put my new definition? what else do i have to change/remove/add from the output? everything i've tried just gives a different error
You don't need to change the ppc_recomp.*.cpp files, preferably don't touch them at all even. You can put your own implementations in separate .cpp files and link all the compiled .obj/.o files together.
UnleashedRecomp handles these by defining them in the runtime project, and since the functions in ppc_recomp.*.cpp files are weakly linked they just get overriden with your implementation. So if you wanted to implement that function you'd declare it like:
PPC_FUNC(XGetGameRegion) { // your implementation here... }
and all calls to this import would get replaced. The GUEST_FUNCTION_HOOK in the codebase is a helper to translate the PPC registers to real function arguments, which is implemented here: https://github.com/hedge-dev/UnleashedRecomp/blob/main/UnleashedRecomp/kernel/function.h
so if i were to implement the functions, i just have to make a seperate cpp file and do something like this?
PPC_FUNC_IMPL(XamWriteGamerTile)
{
ctx.r3.u32 = 0; // Success
}
Yup, though I can't remember if the __imp__ prefix was required for imports or not right now.
For functions you don't need the original implementation of, I recommend using the helper GUEST_FUNCTION_HOOK macros instead.
Yup, though I can't remember if the
__imp__prefix was required for imports or not right now.For functions you don't need the original implementation of, I recommend using the helper GUEST_FUNCTION_HOOK macros instead.
when i do it the way you confirmed should work i get this
ld.lld: error: undefined symbol: __imp__vswprintf(PPCContext&, unsigned char*)
referenced by CMakeFiles/PPCRecompiler.dir/ppc_func_mapping.cpp.obj:(PPCFuncMappings) referenced by CMakeFiles/PPCRecompiler.dir/ppc_recomp.377.cpp.obj:(__declspec(dllimport) _sub_82BEA498)
of course for every function. does this mean i do need the imp prefix?
If the linker complained about it being missing then yeah you do. I got a better example here: https://github.com/hedge-dev/XenonRecomp/issues/96#issuecomment-2709101684
If the linker complained about it being missing then yeah you do. I got a better example here: https://github.com/hedge-dev/XenonRecomp/issues/96#issuecomment-2709101684
That was indeed the case, now I just have to edit my cmakelists.txt to make an exe. Ty for - your assistance