all repos — mgba @ 4b7883e1fd9154e200c35b62ed453b6c29de43d6

mGBA Game Boy Advance Emulator

Add command line parsing to Qt frontend
Jeffrey Pfau jeffrey@endrift.com
Sat, 18 Oct 2014 01:54:51 -0700
commit

4b7883e1fd9154e200c35b62ed453b6c29de43d6

parent

acd0e58235b2afe37597b3980eac23ef8e1c70a7

3 files changed, 40 insertions(+), 1 deletions(-)

jump to
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -12,6 +12,10 @@ #include "GDBController.h"

#include "LoadSaveState.h" #include "LogView.h" +extern "C" { +#include "platform/commandline.h" +} + using namespace QGBA; Window::Window(QWidget* parent)

@@ -97,6 +101,25 @@ break;

default: return GBA_KEY_NONE; } +} + +void Window::optionsPassed(StartupOptions* opts) { + if (opts->fname) { + m_controller->loadGame(opts->fname, opts->dirmode); + } + + if (opts->logLevel) { + m_logView->setLevels(opts->logLevel); + } + + // TODO: + // - bios + // - patch + // - frameskip; + // - rewindBufferCapacity + // - rewindBufferInterval + // - DebuggerType debuggerType + // - debugAtStart } void Window::selectROM() {
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -11,6 +11,8 @@

#include "Display.h" #include "LoadSaveState.h" +struct StartupOptions; + namespace QGBA { class GameController;

@@ -25,6 +27,8 @@ Window(QWidget* parent = nullptr);

virtual ~Window(); static GBAKey mapKey(int qtKey); + + void optionsPassed(StartupOptions*); signals: void startDrawing(const uint32_t*, GBAThread*);
M src/platform/qt/main.cppsrc/platform/qt/main.cpp

@@ -1,12 +1,24 @@

#include <QApplication> #include "Window.h" +extern "C" { +#include "platform/commandline.h" +} + int main(int argc, char* argv[]) { QApplication application(argc, argv); QApplication::setApplicationName(PROJECT_NAME); QApplication::setApplicationVersion(PROJECT_VERSION); + QGBA::Window window; + + struct StartupOptions opts; + if (parseCommandArgs(&opts, argc, argv, 0)) { + window.optionsPassed(&opts); + } window.show(); - return application.exec(); + int rcode = application.exec(); + freeOptions(&opts); + return rcode; }