From d5f44c11c534bbce13fbee824342911d2ce9c874 Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Fri, 27 Sep 2024 19:26:13 +0300 Subject: [PATCH] Don't print save/restore calls when non volatile registers as local variables option is enabled. --- PowerRecomp/recompiler.cpp | 9 ++++++++- PowerRecomp/swa_recompiler.cpp | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/PowerRecomp/recompiler.cpp b/PowerRecomp/recompiler.cpp index ffe0ef9..576db91 100644 --- a/PowerRecomp/recompiler.cpp +++ b/PowerRecomp/recompiler.cpp @@ -157,7 +157,14 @@ bool Recompiler::Recompile( if (targetSymbol != image.symbols.end() && targetSymbol->address == address && targetSymbol->type == Symbol_Function) { - println("\t{}(ctx, base);", targetSymbol->name); + if (config.nonVolatileRegistersAsLocalVariables && (targetSymbol->name.starts_with("__rest") || targetSymbol->name.starts_with("__save"))) + { + // print nothing + } + else + { + println("\t{}(ctx, base);", targetSymbol->name); + } } else { diff --git a/PowerRecomp/swa_recompiler.cpp b/PowerRecomp/swa_recompiler.cpp index bf83f0a..3c815a1 100644 --- a/PowerRecomp/swa_recompiler.cpp +++ b/PowerRecomp/swa_recompiler.cpp @@ -20,7 +20,18 @@ void SWARecompiler::Analyse() f.base = fn.BeginAddress; f.size = fn.FunctionLength * 4; - image.symbols.emplace(std::format("sub_{:X}", f.base), f.base, f.size, Symbol_Function); + std::string name; + if (f.base == 0x831B0B40) name = "__restgprlr_14"; + else if (f.base == 0x831B0AF0) name = "__savegprlr_14"; + else if (f.base == 0x831B144C) name = "__restfpr_14"; + else if (f.base == 0x831B1400) name = "__savefpr_14"; + else if (f.base == 0x831B36E8) name = "__restvmx_14"; + else if (f.base == 0x831B3450) name = "__savevmx_14"; + else if (f.base == 0x831B377C) name = "__restvmx_64"; + else if (f.base == 0x831B34E4) name = "__savevmx_64"; + else name = std::format("sub_{:X}", f.base); + + image.symbols.emplace(name, f.base, f.size, Symbol_Function); } for (size_t i = 15; i < 128; i++)