#ifndef __RECOMP_PORT__ #define __RECOMP_PORT__ #include #include #include #include #include #ifdef _MSC_VER inline uint32_t byteswap(uint32_t val) { return _byteswap_ulong(val); } #else constexpr uint32_t byteswap(uint32_t val) { return __builtin_bswap32(val); } #endif namespace RecompPort { struct JumpTable { uint32_t vram; uint32_t addend_reg; uint32_t rom; uint32_t lw_vram; uint32_t addu_vram; uint32_t jr_vram; std::vector entries; }; struct Function { uint32_t vram; uint32_t rom; const std::span words; std::string name; bool ignored; }; struct FunctionStats { std::vector jump_tables; }; struct Context { std::vector functions; std::unordered_map> functions_by_vram; std::vector rom; }; bool analyze_function(const Context& context, const Function& function, const std::vector& instructions, FunctionStats& stats); bool recompile_function(const Context& context, const Function& func, std::string_view output_path); } #endif