2024-09-21 16:59:55 +03:00
|
|
|
#include "pch.h"
|
|
|
|
#include "swa_recompiler.h"
|
2024-09-21 21:47:34 +03:00
|
|
|
#include "test_recompiler.h"
|
2024-09-15 22:04:40 +03:00
|
|
|
|
2024-09-18 15:19:20 +03:00
|
|
|
// argv 1: xex file path
|
|
|
|
// argv 2: switches toml file path
|
|
|
|
// argv 3: output directory path
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
2024-09-07 18:00:09 +06:00
|
|
|
{
|
2024-09-21 21:47:34 +03:00
|
|
|
if (strstr(argv[1], ".xex") != nullptr)
|
|
|
|
{
|
|
|
|
SWARecompiler recompiler;
|
2024-09-26 17:24:04 +03:00
|
|
|
//recompiler.config.skipLr = true;
|
2024-09-24 17:32:04 +03:00
|
|
|
recompiler.config.ctrAsLocalVariable = true;
|
|
|
|
recompiler.config.xerAsLocalVariable = true;
|
|
|
|
recompiler.config.reservedRegisterAsLocalVariable = true;
|
|
|
|
recompiler.config.skipMsr = true;
|
|
|
|
recompiler.config.crRegistersAsLocalVariables = true;
|
|
|
|
recompiler.config.nonArgumentRegistersAsLocalVariables = true;
|
|
|
|
recompiler.config.nonVolatileRegistersAsLocalVariables = true;
|
2024-09-18 11:37:50 +03:00
|
|
|
|
2024-09-21 21:47:34 +03:00
|
|
|
std::println("Loading executable...");
|
|
|
|
recompiler.LoadExecutable(argv[1]);
|
2024-09-18 11:37:50 +03:00
|
|
|
|
2024-09-21 21:47:34 +03:00
|
|
|
std::println("Loading switch tables...");
|
|
|
|
recompiler.LoadSwitchTables(argv[2]);
|
2024-09-18 11:37:50 +03:00
|
|
|
|
2024-09-21 21:47:34 +03:00
|
|
|
std::println("Analysing functions...");
|
|
|
|
recompiler.Analyse();
|
|
|
|
|
2024-09-28 22:44:27 +06:00
|
|
|
auto entry = recompiler.image.symbols.find(recompiler.image.entry_point);
|
|
|
|
if (entry != recompiler.image.symbols.end())
|
|
|
|
{
|
|
|
|
entry->name = "_xstart";
|
|
|
|
}
|
|
|
|
|
2024-09-21 21:47:34 +03:00
|
|
|
recompiler.Recompile(argv[3]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TestRecompiler::RecompileTests(argv[1], argv[2]);
|
|
|
|
}
|
2024-09-09 23:23:04 +06:00
|
|
|
|
2024-09-07 18:21:08 +06:00
|
|
|
return 0;
|
|
|
|
}
|