diff --git a/PowerRecomp/main.cpp b/PowerRecomp/main.cpp index edfa557..dd2d298 100644 --- a/PowerRecomp/main.cpp +++ b/PowerRecomp/main.cpp @@ -63,7 +63,7 @@ int main() name = std::format("sub_{:X}", base); } - std::println(f, "void {}(PPCContext& __restrict callerCtx, uint8_t* base) {{", name); + std::println(f, "PPC_FUNC void {}(PPCContext& __restrict callerCtx, uint8_t* base) {{", name); std::println(f, "\tPPCContext ctx = callerCtx;"); std::println(f, "\tuint32_t ea;\n"); @@ -176,7 +176,9 @@ int main() targetName = std::format("sub_{:X}", insn.operands[0]); } std::println(f, "\tctx.lr = 0x{:X};", base); - std::println(f, "\t{}(ctx, base);", targetName); + std::println(f, "\tcallerCtx = ctx;"); + std::println(f, "\t{}(callerCtx, base);", targetName); + std::println(f, "\ctx = callerCtx;"); break; } diff --git a/PowerUtils/ppc_context.h b/PowerUtils/ppc_context.h index 852a268..d89c949 100644 --- a/PowerUtils/ppc_context.h +++ b/PowerUtils/ppc_context.h @@ -7,6 +7,9 @@ #define _byteswap_ushort __builtin_bswap16 #define _byteswap_ulong __builtin_bswap32 #define _byteswap_uint64 __builtin_bswap64 +#define PPC_FUNC extern inline __attribute__((weak,noinline)) +#else +#define PPC_FUNC __declspec(noinline) #endif #define PPC_LOAD_U8(x) *(uint8_t*)(base + (x))