1
0
Fork 0
mirror of https://github.com/melonDS-emu/melonDS.git synced 2025-03-06 21:00:31 +01:00
This commit is contained in:
GalaxyShard 2025-02-21 11:53:02 +01:00 committed by GitHub
commit 678eb7f400
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 66 additions and 8 deletions

View file

@ -44,6 +44,13 @@ CommandLineOptions* ManageArgs(QApplication& melon)
parser.addOption(QCommandLineOption({"b", "boot"}, "Whether to boot firmware on startup. Defaults to \"auto\" (boot if NDS rom given)", "auto/always/never", "auto")); parser.addOption(QCommandLineOption({"b", "boot"}, "Whether to boot firmware on startup. Defaults to \"auto\" (boot if NDS rom given)", "auto/always/never", "auto"));
parser.addOption(QCommandLineOption({"f", "fullscreen"}, "Start melonDS in fullscreen mode")); parser.addOption(QCommandLineOption({"f", "fullscreen"}, "Start melonDS in fullscreen mode"));
#ifdef GDBSTUB_ENABLED
parser.addOption(QCommandLineOption("break-arm9", "Yield ARM9 execution to the GDB stub immediately on startup"));
parser.addOption(QCommandLineOption("break-arm7", "Yield ARM7 execution to the GDB stub immediately on startup"));
parser.addOption(QCommandLineOption("no-break-arm9", "Do not wait for GDB on ARM9 startup, even if the option to do so is enabled"));
parser.addOption(QCommandLineOption("no-break-arm7", "Do not wait for GDB on ARM9 startup, even if the option to do so is enabled"));
#endif
#ifdef ARCHIVE_SUPPORT_ENABLED #ifdef ARCHIVE_SUPPORT_ENABLED
parser.addOption(QCommandLineOption({"a", "archive-file"}, "Specify file to load inside an archive given (NDS)", "rom")); parser.addOption(QCommandLineOption({"a", "archive-file"}, "Specify file to load inside an archive given (NDS)", "rom"));
parser.addOption(QCommandLineOption({"A", "archive-file-gba"}, "Specify file to load inside an archive given (GBA)", "rom")); parser.addOption(QCommandLineOption({"A", "archive-file-gba"}, "Specify file to load inside an archive given (GBA)", "rom"));
@ -55,6 +62,25 @@ CommandLineOptions* ManageArgs(QApplication& melon)
options->fullscreen = parser.isSet("fullscreen"); options->fullscreen = parser.isSet("fullscreen");
#ifdef GDBSTUB_ENABLED
if (parser.isSet("break-arm9"))
{
options->arm9BreakOnStart = true;
}
if (parser.isSet("no-break-arm9"))
{
options->arm9BreakOnStart = false;
}
if (parser.isSet("break-arm7"))
{
options->arm7BreakOnStart = true;
}
if (parser.isSet("no-break-arm7"))
{
options->arm7BreakOnStart = false;
}
#endif
QStringList posargs = parser.positionalArguments(); QStringList posargs = parser.positionalArguments();
switch (posargs.size()) switch (posargs.size())
{ {

View file

@ -34,6 +34,10 @@ struct CommandLineOptions
std::optional<QString> gbaRomArchivePath; std::optional<QString> gbaRomArchivePath;
bool fullscreen; bool fullscreen;
bool boot; bool boot;
#ifdef GDBSTUB_ENABLED
std::optional<bool> arm9BreakOnStart;
std::optional<bool> arm7BreakOnStart;
#endif
}; };
extern CommandLineOptions* ManageArgs(QApplication& melon); extern CommandLineOptions* ManageArgs(QApplication& melon);

View file

@ -64,7 +64,12 @@ const string kWifiSettingsPath = "wfcsettings.bin";
extern Net net; extern Net net;
EmuInstance::EmuInstance(int inst) : deleting(false), EmuInstance::EmuInstance(int inst, InstanceStartupOptions options) :
#ifdef GDBSTUB_ENABLED
overrideArm9BreakOnStart(options.arm9BreakOnStart),
overrideArm7BreakOnStart(options.arm7BreakOnStart),
#endif
deleting(false),
instanceID(inst), instanceID(inst),
globalCfg(Config::GetGlobalTable()), globalCfg(Config::GetGlobalTable()),
localCfg(Config::GetLocalTable(inst)) localCfg(Config::GetLocalTable(inst))
@ -150,6 +155,12 @@ EmuInstance::EmuInstance(int inst) : deleting(false),
} }
} }
EmuInstance::EmuInstance(int inst) :
EmuInstance(inst, {})
{
}
EmuInstance::~EmuInstance() EmuInstance::~EmuInstance()
{ {
deleting = true; deleting = true;
@ -1287,8 +1298,8 @@ bool EmuInstance::updateConsole() noexcept
GDBArgs _gdbargs { GDBArgs _gdbargs {
static_cast<u16>(gdbopt.GetInt("ARM7.Port")), static_cast<u16>(gdbopt.GetInt("ARM7.Port")),
static_cast<u16>(gdbopt.GetInt("ARM9.Port")), static_cast<u16>(gdbopt.GetInt("ARM9.Port")),
gdbopt.GetBool("ARM7.BreakOnStartup"), overrideArm7BreakOnStart.value_or(gdbopt.GetBool("ARM7.BreakOnStartup")),
gdbopt.GetBool("ARM9.BreakOnStartup"), overrideArm9BreakOnStart.value_or(gdbopt.GetBool("ARM9.BreakOnStartup")),
}; };
auto gdbargs = gdbopt.GetBool("Enabled") ? std::make_optional(_gdbargs) : std::nullopt; auto gdbargs = gdbopt.GetBool("Enabled") ? std::make_optional(_gdbargs) : std::nullopt;
#else #else

View file

@ -21,6 +21,12 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
struct InstanceStartupOptions
{
std::optional<bool> arm9BreakOnStart;
std::optional<bool> arm7BreakOnStart;
};
#include "main.h" #include "main.h"
#include "NDS.h" #include "NDS.h"
#include "EmuThread.h" #include "EmuThread.h"
@ -79,6 +85,7 @@ class EmuInstance
{ {
public: public:
EmuInstance(int inst); EmuInstance(int inst);
EmuInstance(int inst, InstanceStartupOptions options);
~EmuInstance(); ~EmuInstance();
int getInstanceID() { return instanceID; } int getInstanceID() { return instanceID; }
@ -271,6 +278,11 @@ private:
bool changeGBACart; bool changeGBACart;
std::unique_ptr<melonDS::GBACart::CartCommon> nextGBACart; std::unique_ptr<melonDS::GBACart::CartCommon> nextGBACart;
#ifdef GDBSTUB_ENABLED
std::optional<bool> overrideArm9BreakOnStart = std::nullopt;
std::optional<bool> overrideArm7BreakOnStart = std::nullopt;
#endif
// HACK // HACK
public: public:
std::unique_ptr<SaveManager> ndsSave; std::unique_ptr<SaveManager> ndsSave;

View file

@ -1743,7 +1743,7 @@ void MainWindow::onOpenTitleManager()
void MainWindow::onMPNewInstance() void MainWindow::onMPNewInstance()
{ {
createEmuInstance(); createEmuInstance({});
} }
void MainWindow::onLANStartHost() void MainWindow::onLANStartHost()

View file

@ -118,7 +118,7 @@ void NetInit()
} }
bool createEmuInstance() bool createEmuInstance(InstanceStartupOptions options)
{ {
int id = -1; int id = -1;
for (int i = 0; i < kMaxEmuInstances; i++) for (int i = 0; i < kMaxEmuInstances; i++)
@ -133,7 +133,7 @@ bool createEmuInstance()
if (id == -1) if (id == -1)
return false; return false;
auto inst = new EmuInstance(id); auto inst = new EmuInstance(id, options);
emuInstances[id] = inst; emuInstances[id] = inst;
return true; return true;
@ -349,7 +349,12 @@ int main(int argc, char** argv)
NetInit(); NetInit();
createEmuInstance(); InstanceStartupOptions instanceOptions;
#ifdef GDBSTUB_ENABLED
instanceOptions.arm9BreakOnStart = options->arm9BreakOnStart;
instanceOptions.arm7BreakOnStart = options->arm7BreakOnStart;
#endif
createEmuInstance(instanceOptions);
{ {
MainWindow* win = emuInstances[0]->getMainWindow(); MainWindow* win = emuInstances[0]->getMainWindow();

View file

@ -54,7 +54,7 @@ extern QString emuDirectory;
extern QElapsedTimer sysTimer; extern QElapsedTimer sysTimer;
bool createEmuInstance(); bool createEmuInstance(InstanceStartupOptions options);
void deleteEmuInstance(int id); void deleteEmuInstance(int id);
void deleteAllEmuInstances(int first = 0); void deleteAllEmuInstances(int first = 0);
int numEmuInstances(); int numEmuInstances();