CLI: Add argument to pass an argument to the game (#2135)

This commit is contained in:
kalaposfos13 2025-01-18 13:21:08 +01:00 committed by GitHub
parent 1ea5f8f092
commit 3b92cd1c1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 61 additions and 9 deletions

View file

@ -52,7 +52,7 @@ Linker::Linker() : memory{Memory::Instance()} {}
Linker::~Linker() = default;
void Linker::Execute() {
void Linker::Execute(const std::vector<std::string> args) {
if (Config::debugDump()) {
DebugDump();
}
@ -101,7 +101,7 @@ void Linker::Execute() {
memory->SetupMemoryRegions(fmem_size, use_extended_mem1, use_extended_mem2);
main_thread.Run([this, module](std::stop_token) {
main_thread.Run([this, module, args](std::stop_token) {
Common::SetCurrentThreadName("GAME_MainThread");
LoadSharedLibraries();
@ -109,6 +109,12 @@ void Linker::Execute() {
EntryParams params{};
params.argc = 1;
params.argv[0] = "eboot.bin";
if (!args.empty()) {
params.argc = args.size() + 1;
for (int i = 0; i < args.size() && i < 32; i++) {
params.argv[i + 1] = args[i].c_str();
}
}
params.entry_addr = module->GetEntryAddress();
RunMainEntry(&params);
});