mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-26 08:51:05 -04:00
fix: fix recompile from single file to multi file
This commit is contained in:
@@ -14,7 +14,7 @@ namespace ps2recomp
|
||||
CodeGenerator(const std::vector<Symbol> &symbols);
|
||||
~CodeGenerator();
|
||||
|
||||
std::string generateFunction(const Function &function, const std::vector<Instruction> &instructions);
|
||||
std::string generateFunction(const Function &function, const std::vector<Instruction> &instructions, const bool &useHeaders);
|
||||
std::string generateMacroHeader();
|
||||
std::string handleBranchDelaySlots(const Instruction &branchInst, const Instruction &delaySlot);
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace ps2recomp
|
||||
std::string translateInstruction(const Instruction &inst);
|
||||
std::string translateMMIInstruction(const Instruction &inst);
|
||||
std::string translateVUInstruction(const Instruction &inst);
|
||||
std::string translateFPUInstruction(const Instruction& inst);
|
||||
std::string translateCOP0Instruction(const Instruction& inst);
|
||||
std::string translateFPUInstruction(const Instruction &inst);
|
||||
std::string translateCOP0Instruction(const Instruction &inst);
|
||||
|
||||
std::string generateJumpTableSwitch(const Instruction &inst, uint32_t tableAddress,
|
||||
const std::vector<JumpTableEntry> &entries);
|
||||
|
||||
@@ -391,13 +391,16 @@ namespace ps2recomp
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string CodeGenerator::generateFunction(const Function &function, const std::vector<Instruction> &instructions)
|
||||
std::string CodeGenerator::generateFunction(const Function &function, const std::vector<Instruction> &instructions, const bool &useHeaders)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "#include \"ps2_runtime_macros.h\"\n";
|
||||
ss << "#include \"ps2_runtime.h\"\n";
|
||||
ss << "#include \"ps2_recompiled_functions.h\"\n\n";
|
||||
if (useHeaders)
|
||||
{
|
||||
ss << "#include \"ps2_runtime_macros.h\"\n";
|
||||
ss << "#include \"ps2_runtime.h\"\n";
|
||||
ss << "#include \"ps2_recompiled_functions.h\"\n\n";
|
||||
}
|
||||
|
||||
ss << "// Function: " << function.name << "\n";
|
||||
ss << "// Address: 0x" << std::hex << function.start << " - 0x" << function.end << std::dec << "\n";
|
||||
|
||||
@@ -123,15 +123,12 @@ namespace ps2recomp
|
||||
{
|
||||
try
|
||||
{
|
||||
generateFunctionHeader();
|
||||
|
||||
if (m_config.singleFileOutput)
|
||||
{
|
||||
std::stringstream combinedOutput;
|
||||
|
||||
combinedOutput << "#include \"ps2_runtime_macros.h\"\n";
|
||||
combinedOutput << "#include \"ps2_runtime.h\"\n";
|
||||
combinedOutput << "#include \"ps2_recompiled_functions.h\"\n\n";
|
||||
combinedOutput << "#include \"ps2_runtime.h\"\n\n";
|
||||
|
||||
for (const auto &function : m_functions)
|
||||
{
|
||||
@@ -147,7 +144,7 @@ namespace ps2recomp
|
||||
else
|
||||
{
|
||||
const auto &instructions = m_decodedFunctions[function.start];
|
||||
std::string code = m_codeGenerator->generateFunction(function, instructions);
|
||||
std::string code = m_codeGenerator->generateFunction(function, instructions, false);
|
||||
combinedOutput << code << "\n\n";
|
||||
}
|
||||
}
|
||||
@@ -158,6 +155,7 @@ namespace ps2recomp
|
||||
}
|
||||
else
|
||||
{
|
||||
generateFunctionHeader();
|
||||
for (const auto &function : m_functions)
|
||||
{
|
||||
if (!function.isRecompiled || function.isStub)
|
||||
@@ -173,7 +171,7 @@ namespace ps2recomp
|
||||
else
|
||||
{
|
||||
const auto &instructions = m_decodedFunctions[function.start];
|
||||
code = m_codeGenerator->generateFunction(function, instructions);
|
||||
code = m_codeGenerator->generateFunction(function, instructions, true);
|
||||
}
|
||||
|
||||
fs::path outputPath = getOutputPath(function);
|
||||
|
||||
Reference in New Issue
Block a user