all repos — mgba @ f3daa19a6dc58773d5f1d76e3b2d3d21fa9449c5

mGBA Game Boy Advance Emulator

Qt: More GB bringup
Jeffrey Pfau jeffrey@endrift.com
Sat, 13 Feb 2016 01:06:36 -0800
commit

f3daa19a6dc58773d5f1d76e3b2d3d21fa9449c5

parent

adf20bea09a3fe39273bf2ffaf0f12a4dcf83163

M src/lr35902/isa-lr35902.hsrc/lr35902/isa-lr35902.h

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

struct LR35902Core; typedef void (*LR35902Instruction)(struct LR35902Core*); -const LR35902Instruction _lr35902InstructionTable[0x100]; +extern const LR35902Instruction _lr35902InstructionTable[0x100]; #endif
M src/platform/qt/Display.cppsrc/platform/qt/Display.cpp

@@ -9,7 +9,7 @@ #include "DisplayGL.h"

#include "DisplayQt.h" extern "C" { -#include "gba/video.h" +#include "gb/video.h" } using namespace QGBA;

@@ -54,7 +54,7 @@ , m_lockAspectRatio(false)

, m_filter(false) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - setMinimumSize(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); + setMinimumSize(GB_VIDEO_HORIZONTAL_PIXELS, GB_VIDEO_VERTICAL_PIXELS); connect(&m_mouseTimer, SIGNAL(timeout()), this, SIGNAL(hideCursor())); m_mouseTimer.setSingleShot(true); m_mouseTimer.setInterval(MOUSE_DISAPPEAR_TIMER);
M src/platform/qt/GBAApp.cppsrc/platform/qt/GBAApp.cpp

@@ -83,7 +83,7 @@ }

freeArguments(&args); if (graphicsOpts.multiplier) { - w->resizeFrame(VIDEO_HORIZONTAL_PIXELS * graphicsOpts.multiplier, VIDEO_VERTICAL_PIXELS * graphicsOpts.multiplier); + w->resizeFrame(QSize(VIDEO_HORIZONTAL_PIXELS * graphicsOpts.multiplier, VIDEO_VERTICAL_PIXELS * graphicsOpts.multiplier)); } if (graphicsOpts.fullscreen) { w->enterFullScreen();
M src/platform/qt/GDBController.cppsrc/platform/qt/GDBController.cpp

@@ -36,7 +36,7 @@ m_bindAddress.ipv4 = htonl(bindAddress);

} void GDBController::attach() { - if (isAttached()) { + if (isAttached() || m_gameController->platform() != PLATFORM_GBA) { return; } m_gameController->setDebugger(&m_gdbStub.d);
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -463,6 +463,23 @@ }

return mCoreThreadIsPaused(&m_threadContext); } +mPlatform GameController::platform() const { + if (!m_gameOpen) { + return PLATFORM_NONE; + } + return m_threadContext.core->platform(m_threadContext.core); +} + +QSize GameController::screenDimensions() const { + if (!m_gameOpen) { + return QSize(); + } + unsigned width, height; + m_threadContext.core->desiredVideoDimensions(m_threadContext.core, &width, &height); + + return QSize(width, height); +} + void GameController::setPaused(bool paused) { if (!isLoaded() || m_rewindTimer.isActive() || paused == mCoreThreadIsPaused(&m_threadContext)) { return;
M src/platform/qt/GameController.hsrc/platform/qt/GameController.h

@@ -16,6 +16,7 @@

#include <memory> extern "C" { +#include "core/core.h" #include "core/thread.h" #include "gba/cheats.h" #include "gba/context/overrides.h"

@@ -58,9 +59,11 @@ void threadContinue();

bool isPaused(); bool isLoaded() { return m_gameOpen && mCoreThreadIsActive(&m_threadContext); } + mPlatform platform() const; bool audioSync() const { return m_audioSync; } bool videoSync() const { return m_videoSync; } + QSize screenDimensions() const; void setInputController(InputController* controller) { m_inputController = controller; }
M src/platform/qt/OverrideView.cppsrc/platform/qt/OverrideView.cpp

@@ -104,6 +104,10 @@ if (!thread->core) {

gameStopped(); return; } + if (thread->core->platform(thread->core) != PLATFORM_GBA) { + close(); + return; + } GBA* gba = static_cast<GBA*>(thread->core->board); m_ui.savetype->setCurrentIndex(gba->memory.savedata.type + 1); m_ui.savetype->setEnabled(false);
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -185,11 +185,11 @@ m_controller->loadGame(args->fname);

} } -void Window::resizeFrame(int width, int height) { - QSize newSize(width, height); +void Window::resizeFrame(const QSize& size) { + QSize newSize(size); m_screenWidget->setSizeHint(newSize); newSize -= m_screenWidget->size(); - newSize += size(); + newSize += this->size(); resize(newSize); }

@@ -215,7 +215,7 @@ emit sampleRateChanged(opts->sampleRate);

} if (opts->width && opts->height) { - resizeFrame(opts->width, opts->height); + resizeFrame(QSize(opts->width, opts->height)); } if (opts->fullscreen) {

@@ -488,9 +488,13 @@ m_config->setOption("width", m_screenWidget->width());

} int factor = 0; - if (event->size().width() % VIDEO_HORIZONTAL_PIXELS == 0 && event->size().height() % VIDEO_VERTICAL_PIXELS == 0 && - event->size().width() / VIDEO_HORIZONTAL_PIXELS == event->size().height() / VIDEO_VERTICAL_PIXELS) { - factor = event->size().width() / VIDEO_HORIZONTAL_PIXELS; + QSize size(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); + if (m_controller->isLoaded()) { + size = m_controller->screenDimensions(); + } + if (event->size().width() % size.width() == 0 && event->size().height() % size.height() == 0 && + event->size().width() / size.width() == event->size().height() / size.height()) { + factor = event->size().width() / size.width(); } for (QMap<int, QAction*>::iterator iter = m_frameSizes.begin(); iter != m_frameSizes.end(); ++iter) { bool enableSignals = iter.value()->blockSignals(true);

@@ -506,7 +510,7 @@ m_config->setOption("fullscreen", isFullScreen());

} void Window::showEvent(QShowEvent* event) { - resizeFrame(m_screenWidget->sizeHint().width(), m_screenWidget->sizeHint().height()); + resizeFrame(m_screenWidget->sizeHint()); QVariant windowPos = m_config->getQtOption("windowPos"); if (!windowPos.isNull()) { move(windowPos.toPoint());

@@ -612,12 +616,18 @@ MutexUnlock(&context->stateMutex);

foreach (QAction* action, m_gameActions) { action->setDisabled(false); } + foreach (QAction* action, m_gbaActions) { + action->setDisabled(context->core->platform(context->core) != PLATFORM_GBA); + } multiplayerChanged(); if (!fname.isEmpty()) { setWindowFilePath(fname); appendMRU(fname); } updateTitle(); + unsigned width, height; + context->core->desiredVideoDimensions(context->core, &width, &height); + m_display->setMinimumSize(width, height); attachWidget(m_display); #ifndef Q_OS_MAC

@@ -632,6 +642,9 @@ m_focusCheck.start();

} void Window::gameStopped() { + foreach (QAction* action, m_gbaActions) { + action->setDisabled(false); + } foreach (QAction* action, m_gameActions) { action->setDisabled(true); }

@@ -799,6 +812,7 @@ loadState->setShortcut(tr("F10"));

connect(loadState, &QAction::triggered, [this]() { this->openStateWindow(LoadSave::LOAD); }); m_gameActions.append(loadState); m_nonMpActions.append(loadState); + m_gbaActions.append(loadState); addControlledAction(fileMenu, loadState, "loadState"); QAction* saveState = new QAction(tr("&Save state"), fileMenu);

@@ -806,6 +820,7 @@ saveState->setShortcut(tr("Shift+F10"));

connect(saveState, &QAction::triggered, [this]() { this->openStateWindow(LoadSave::SAVE); }); m_gameActions.append(saveState); m_nonMpActions.append(saveState); + m_gbaActions.append(saveState); addControlledAction(fileMenu, saveState, "saveState"); QMenu* quickLoadMenu = fileMenu->addMenu(tr("Quick load"));

@@ -817,12 +832,14 @@ QAction* quickLoad = new QAction(tr("Load recent"), quickLoadMenu);

connect(quickLoad, SIGNAL(triggered()), m_controller, SLOT(loadState())); m_gameActions.append(quickLoad); m_nonMpActions.append(quickLoad); + m_gbaActions.append(quickLoad); addControlledAction(quickLoadMenu, quickLoad, "quickLoad"); QAction* quickSave = new QAction(tr("Save recent"), quickSaveMenu); connect(quickSave, SIGNAL(triggered()), m_controller, SLOT(saveState())); m_gameActions.append(quickSave); m_nonMpActions.append(quickSave); + m_gbaActions.append(quickSave); addControlledAction(quickSaveMenu, quickSave, "quickSave"); quickLoadMenu->addSeparator();

@@ -833,6 +850,7 @@ undoLoadState->setShortcut(tr("F11"));

connect(undoLoadState, SIGNAL(triggered()), m_controller, SLOT(loadBackupState())); m_gameActions.append(undoLoadState); m_nonMpActions.append(undoLoadState); + m_gbaActions.append(undoLoadState); addControlledAction(quickLoadMenu, undoLoadState, "undoLoadState"); QAction* undoSaveState = new QAction(tr("Undo save state"), quickSaveMenu);

@@ -840,6 +858,7 @@ undoSaveState->setShortcut(tr("Shift+F11"));

connect(undoSaveState, SIGNAL(triggered()), m_controller, SLOT(saveBackupState())); m_gameActions.append(undoSaveState); m_nonMpActions.append(undoSaveState); + m_gbaActions.append(undoSaveState); addControlledAction(quickSaveMenu, undoSaveState, "undoSaveState"); quickLoadMenu->addSeparator();

@@ -852,6 +871,7 @@ quickLoad->setShortcut(tr("F%1").arg(i));

connect(quickLoad, &QAction::triggered, [this, i]() { m_controller->loadState(i); }); m_gameActions.append(quickLoad); m_nonMpActions.append(quickLoad); + m_gbaActions.append(quickLoad); addControlledAction(quickLoadMenu, quickLoad, QString("quickLoad.%1").arg(i)); quickSave = new QAction(tr("State &%1").arg(i), quickSaveMenu);

@@ -859,6 +879,7 @@ quickSave->setShortcut(tr("Shift+F%1").arg(i));

connect(quickSave, &QAction::triggered, [this, i]() { m_controller->saveState(i); }); m_gameActions.append(quickSave); m_nonMpActions.append(quickSave); + m_gbaActions.append(quickSave); addControlledAction(quickSaveMenu, quickSave, QString("quickSave.%1").arg(i)); }

@@ -866,11 +887,13 @@ fileMenu->addSeparator();

QAction* importShark = new QAction(tr("Import GameShark Save"), fileMenu); connect(importShark, SIGNAL(triggered()), this, SLOT(importSharkport())); m_gameActions.append(importShark); + m_gbaActions.append(importShark); addControlledAction(fileMenu, importShark, "importShark"); QAction* exportShark = new QAction(tr("Export GameShark Save"), fileMenu); connect(exportShark, SIGNAL(triggered()), this, SLOT(exportSharkport())); m_gameActions.append(exportShark); + m_gbaActions.append(exportShark); addControlledAction(fileMenu, exportShark, "exportShark"); fileMenu->addSeparator();

@@ -908,6 +931,7 @@

QAction* yank = new QAction(tr("Yank game pak"), emulationMenu); connect(yank, SIGNAL(triggered()), m_controller, SLOT(yankPak())); m_gameActions.append(yank); + m_gbaActions.append(yank); addControlledAction(emulationMenu, yank, "yank"); emulationMenu->addSeparator();

@@ -1032,7 +1056,12 @@ QAction* setSize = new QAction(tr("%1x").arg(QString::number(i)), avMenu);

setSize->setCheckable(true); connect(setSize, &QAction::triggered, [this, i, setSize]() { showNormal(); - resizeFrame(VIDEO_HORIZONTAL_PIXELS * i, VIDEO_VERTICAL_PIXELS * i); + QSize size(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); + if (m_controller->isLoaded()) { + size = m_controller->screenDimensions(); + } + size *= i; + resizeFrame(size); bool enableSignals = setSize->blockSignals(true); setSize->setChecked(true); setSize->blockSignals(enableSignals);

@@ -1174,6 +1203,7 @@ addControlledAction(toolsMenu, viewLogs, "viewLogs");

QAction* overrides = new QAction(tr("Game &overrides..."), toolsMenu); connect(overrides, SIGNAL(triggered()), this, SLOT(openOverrideWindow())); + m_gbaActions.append(overrides); addControlledAction(toolsMenu, overrides, "overrideWindow"); QAction* sensors = new QAction(tr("Game &Pak sensors..."), toolsMenu);

@@ -1182,11 +1212,13 @@ addControlledAction(toolsMenu, sensors, "sensorWindow");

QAction* cheats = new QAction(tr("&Cheats..."), toolsMenu); connect(cheats, SIGNAL(triggered()), this, SLOT(openCheatsWindow())); + m_gbaActions.append(cheats); addControlledAction(toolsMenu, cheats, "cheatsWindow"); #ifdef USE_GDB_STUB QAction* gdbWindow = new QAction(tr("Start &GDB server..."), toolsMenu); connect(gdbWindow, SIGNAL(triggered()), this, SLOT(gdbOpen())); + m_gbaActions.append(gdbWindow); addControlledAction(toolsMenu, gdbWindow, "gdbWindow"); #endif

@@ -1199,16 +1231,19 @@

QAction* paletteView = new QAction(tr("View &palette..."), toolsMenu); connect(paletteView, SIGNAL(triggered()), this, SLOT(openPaletteWindow())); m_gameActions.append(paletteView); + m_gbaActions.append(paletteView); addControlledAction(toolsMenu, paletteView, "paletteWindow"); QAction* memoryView = new QAction(tr("View memory..."), toolsMenu); connect(memoryView, SIGNAL(triggered()), this, SLOT(openMemoryWindow())); m_gameActions.append(memoryView); + m_gbaActions.append(memoryView); addControlledAction(toolsMenu, memoryView, "memoryView"); QAction* ioViewer = new QAction(tr("View &I/O registers..."), toolsMenu); connect(ioViewer, SIGNAL(triggered()), this, SLOT(openIOViewer())); m_gameActions.append(ioViewer); + m_gbaActions.append(ioViewer); addControlledAction(toolsMenu, ioViewer, "ioViewer"); ConfigOption* skipBios = m_config->addOption("skipBios");
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -47,7 +47,7 @@

void setConfig(ConfigController*); void argumentsPassed(mArguments*); - void resizeFrame(int width, int height); + void resizeFrame(const QSize& size); signals: void startDrawing(mCoreThread*);

@@ -146,8 +146,10 @@ void updateTitle(float fps = NAN);

GameController* m_controller; Display* m_display; + // TODO: Move these to a new class QList<QAction*> m_gameActions; QList<QAction*> m_nonMpActions; + QList<QAction*> m_gbaActions; QMap<int, QAction*> m_frameSizes; LogController m_log; LogView* m_logView;