mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-06-23 16:05:30 +00:00
Saving to separate files.
This commit is contained in:
parent
618cc75198
commit
5a16d14d30
@ -136,18 +136,61 @@ int main()
|
|||||||
out += '\n';
|
out += '\n';
|
||||||
};
|
};
|
||||||
|
|
||||||
println("#include <ppc_context.h>\n");
|
std::filesystem::create_directory("out");
|
||||||
|
|
||||||
for (auto& symbol : image.symbols)
|
size_t cppFileIndex = 0;
|
||||||
println("PPC_FUNC void {}(PPCContext& __restrict ctx, uint8_t* base);", symbol.name);
|
|
||||||
|
|
||||||
println("");
|
auto saveFile = [&](std::string name = "")
|
||||||
|
{
|
||||||
|
if (!out.empty())
|
||||||
|
{
|
||||||
|
if (name.empty())
|
||||||
|
{
|
||||||
|
name = std::format("out/ppc_recomp.{}.cpp", cppFileIndex);
|
||||||
|
++cppFileIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* f = fopen(name.c_str(), "wb");
|
||||||
|
fwrite(out.data(), 1, out.size(), f);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
out.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
println("#pragma once\n");
|
||||||
|
println("#include <ppc_context.h>\n");
|
||||||
|
|
||||||
|
for (auto& symbol : image.symbols)
|
||||||
|
println("PPC_FUNC void {}(PPCContext& __restrict ctx, uint8_t* base);", symbol.name);
|
||||||
|
|
||||||
|
saveFile("out/ppc_recomp_shared.h");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
println("#include \"ppc_recomp_shared.h\"\n");
|
||||||
|
|
||||||
|
println("extern \"C\" __declspec(dllexport) PPCFuncMapping PPCFuncMapping[] = {{");
|
||||||
|
for (auto& symbol : image.symbols)
|
||||||
|
println("\t{{ 0x{:X}, {} }},", symbol.address, symbol.name);
|
||||||
|
|
||||||
|
println("\t{{ 0, nullptr }}");
|
||||||
|
println("}};");
|
||||||
|
|
||||||
|
saveFile("out/ppc_func_mapping.cpp");
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t funcIdx = 0; funcIdx < functions.size(); funcIdx++)
|
for (size_t funcIdx = 0; funcIdx < functions.size(); funcIdx++)
|
||||||
{
|
{
|
||||||
if ((funcIdx % 1000) == 0)
|
if ((funcIdx % 1000) == 0)
|
||||||
|
{
|
||||||
std::println("Recompiling functions... {}%", static_cast<float>(funcIdx) / functions.size() * 100.0f);
|
std::println("Recompiling functions... {}%", static_cast<float>(funcIdx) / functions.size() * 100.0f);
|
||||||
|
|
||||||
|
saveFile();
|
||||||
|
println("#include \"ppc_recomp_shared.h\"\n");
|
||||||
|
}
|
||||||
|
|
||||||
auto& fn = functions[funcIdx];
|
auto& fn = functions[funcIdx];
|
||||||
auto base = fn.base;
|
auto base = fn.base;
|
||||||
auto end = base + fn.size;
|
auto end = base + fn.size;
|
||||||
@ -1687,11 +1730,7 @@ int main()
|
|||||||
println("}}\n");
|
println("}}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::create_directory("out");
|
saveFile();
|
||||||
|
|
||||||
FILE* f = fopen("out/" TEST_FILE ".cpp", "w");
|
|
||||||
fwrite(out.data(), 1, out.size(), f);
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,12 @@
|
|||||||
|
|
||||||
typedef void PPCFunc(struct PPCContext& __restrict ctx, uint8_t* base);
|
typedef void PPCFunc(struct PPCContext& __restrict ctx, uint8_t* base);
|
||||||
|
|
||||||
|
struct PPCFuncMapping
|
||||||
|
{
|
||||||
|
size_t guest;
|
||||||
|
PPCFunc* host;
|
||||||
|
};
|
||||||
|
|
||||||
struct PPCRegister
|
struct PPCRegister
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
|
Loading…
x
Reference in New Issue
Block a user