all repos — mgba @ b0157aa871991d34cb6471e5184740ea63067fc9

mGBA Game Boy Advance Emulator

Qt: Preliminary build cleanup when GBA core is disabled
Jeffrey Pfau jeffrey@endrift.com
Mon, 05 Sep 2016 10:17:14 -0700
commit

b0157aa871991d34cb6471e5184740ea63067fc9

parent

5b710a59fa407f8bba20100c008510f717597746

M CMakeLists.txtCMakeLists.txt

@@ -201,7 +201,7 @@ if(PSP2 OR WII)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format") endif() -if(DEFINED 3DS OR DEFINED PSP2 OR DEFINED WII) +if(DEFINED 3DS OR DEFINED PSP2 OR DEFINED WII OR NOT M_CORE_GBA) set(USE_GDB_STUB OFF) endif()
M src/gba/extra/export.csrc/util/export.c

@@ -8,7 +8,7 @@

#include "gba/video.h" #include "util/vfs.h" -bool GBAExportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colors) { +bool exportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colors) { if (entries > 0xFFFF) { return false; }

@@ -56,7 +56,7 @@

return true; } -bool GBAExportPaletteACT(struct VFile* vf, size_t entries, const uint16_t* colors) { +bool exportPaletteACT(struct VFile* vf, size_t entries, const uint16_t* colors) { if (entries > 256) { return false; }
D src/gba/extra/export.h

@@ -1,16 +0,0 @@

-/* Copyright (c) 2013-2015 Jeffrey Pfau - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef GBA_EXPORT_H -#define GBA_EXPORT_H - -#include "util/common.h" - -struct VFile; - -bool GBAExportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colors); -bool GBAExportPaletteACT(struct VFile* vf, size_t entries, const uint16_t* colors); - -#endif
M src/gba/gba.csrc/gba/gba.c

@@ -28,7 +28,6 @@ #include "util/vfs.h"

mLOG_DEFINE_CATEGORY(GBA, "GBA"); -const uint32_t GBA_ARM7TDMI_FREQUENCY = 0x1000000; const uint32_t GBA_COMPONENT_MAGIC = 0x1000000; static const size_t GBA_ROM_MAGIC_OFFSET = 3;
M src/gba/gba.hsrc/gba/gba.h

@@ -17,7 +17,7 @@ #include "gba/video.h"

#include "gba/audio.h" #include "gba/sio.h" -extern const uint32_t GBA_ARM7TDMI_FREQUENCY; +#define GBA_ARM7TDMI_FREQUENCY 0x1000000U enum GBAIRQ { IRQ_VBLANK = 0x0,
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -71,6 +71,7 @@ , m_backupSaveState(nullptr)

, m_saveStateFlags(SAVESTATE_SCREENSHOT | SAVESTATE_SAVEDATA | SAVESTATE_CHEATS) , m_loadStateFlags(SAVESTATE_SCREENSHOT) { +#ifdef M_CORE_GBA m_lux.p = this; m_lux.sample = [](GBALuminanceSource* context) { GameControllerLux* lux = static_cast<GameControllerLux*>(context);

@@ -82,6 +83,7 @@ GameControllerLux* lux = static_cast<GameControllerLux*>(context);

return lux->value; }; setLuminanceLevel(0); +#endif m_threadContext.startCallback = [](mCoreThread* context) { GameController* controller = static_cast<GameController*>(context->userData);

@@ -197,13 +199,16 @@ if (!context) {

return; } GameController* controller = static_cast<GameController*>(context->userData); +#ifdef M_CORE_GBA if (level == mLOG_STUB && category == _mLOG_CAT_GBA_BIOS()) { va_list argc; va_copy(argc, args); int immediate = va_arg(argc, int); va_end(argc); QMetaObject::invokeMethod(controller, "unimplementedBiosCall", Q_ARG(int, immediate)); - } else if (category == _mLOG_CAT_STATUS()) { + } else +#endif + if (category == _mLOG_CAT_STATUS()) { // Slot 0 is reserved for suspend points if (strncmp(savestateMessage, format, strlen(savestateMessage)) == 0) { va_list argc;

@@ -503,6 +508,10 @@ void GameController::importSharkport(const QString& path) {

if (!isLoaded()) { return; } +#ifdef M_CORE_GBA + if (platform() != PLATFORM_GBA) { + return; + } VFile* vf = VFileDevice::open(path, O_RDONLY); if (!vf) { LOG(QT, ERROR) << tr("Failed to open snapshot file for reading: %1").arg(path);

@@ -512,12 +521,17 @@ threadInterrupt();

GBASavedataImportSharkPort(static_cast<GBA*>(m_threadContext.core->board), vf, false); threadContinue(); vf->close(vf); +#endif } void GameController::exportSharkport(const QString& path) { if (!isLoaded()) { return; } +#ifdef M_CORE_GBA + if (platform() != PLATFORM_GBA) { + return; + } VFile* vf = VFileDevice::open(path, O_WRONLY | O_CREAT | O_TRUNC); if (!vf) { LOG(QT, ERROR) << tr("Failed to open snapshot file for writing: %1").arg(path);

@@ -527,6 +541,7 @@ threadInterrupt();

GBASavedataExportSharkPort(static_cast<GBA*>(m_threadContext.core->board), vf); threadContinue(); vf->close(vf); +#endif } void GameController::closeGame() {

@@ -818,6 +833,7 @@ if (layer > 4 || layer < 0) {

return; } m_videoLayers[layer] = enable; +#ifdef M_CORE_GBA if (isLoaded() && m_threadContext.core->platform(m_threadContext.core) == PLATFORM_GBA) { GBA* gba = static_cast<GBA*>(m_threadContext.core->board); switch (layer) {

@@ -832,6 +848,7 @@ gba->video.renderer->disableOBJ = !enable;

break; } } +#endif } void GameController::setFPSTarget(float fps) {
M src/platform/qt/PaletteView.cppsrc/platform/qt/PaletteView.cpp

@@ -14,8 +14,9 @@ #include <QFontDatabase>

extern "C" { #include "core/core.h" -#ifdef M_CORE_GBA -#include "gba/extra/export.h" +#include "util/export.h" +#ifdef M_CORE_GA +#include "gba/gba.h" #endif #ifdef M_CORE_GB #include "gb/gb.h"

@@ -148,9 +149,9 @@ return;

} QString filter = dialog->selectedNameFilter(); if (filter.contains("*.pal")) { - GBAExportPaletteRIFF(vf, length, &static_cast<GBA*>(m_controller->thread()->core->board)->video.palette[start]); + exportPaletteRIFF(vf, length, &static_cast<GBA*>(m_controller->thread()->core->board)->video.palette[start]); } else if (filter.contains("*.act")) { - GBAExportPaletteACT(vf, length, &static_cast<GBA*>(m_controller->thread()->core->board)->video.palette[start]); + exportPaletteACT(vf, length, &static_cast<GBA*>(m_controller->thread()->core->board)->video.palette[start]); } vf->close(vf); m_controller->threadContinue();
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -690,9 +690,11 @@ MutexUnlock(&context->stateMutex);

foreach (QAction* action, m_gameActions) { action->setDisabled(false); } +#ifdef M_CORE_GBA foreach (QAction* action, m_gbaActions) { action->setDisabled(context->core->platform(context->core) != PLATFORM_GBA); } +#endif multiplayerChanged(); if (!fname.isEmpty()) { setWindowFilePath(fname);

@@ -716,9 +718,11 @@ m_focusCheck.start();

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

@@ -979,6 +983,7 @@ m_nonMpActions.append(quickSave);

addControlledAction(quickSaveMenu, quickSave, QString("quickSave.%1").arg(i)); } +#ifdef M_CORE_GBA fileMenu->addSeparator(); QAction* importShark = new QAction(tr("Import GameShark Save"), fileMenu); connect(importShark, SIGNAL(triggered()), this, SLOT(importSharkport()));

@@ -991,6 +996,7 @@ connect(exportShark, SIGNAL(triggered()), this, SLOT(exportSharkport()));

m_gameActions.append(exportShark); m_gbaActions.append(exportShark); addControlledAction(fileMenu, exportShark, "exportShark"); +#endif fileMenu->addSeparator(); QAction* multiWindow = new QAction(tr("New multiplayer window"), fileMenu);

@@ -1024,11 +1030,13 @@ connect(shutdown, SIGNAL(triggered()), m_controller, SLOT(closeGame()));

m_gameActions.append(shutdown); addControlledAction(emulationMenu, shutdown, "shutdown"); +#ifdef M_CORE_GBA 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"); +#endif emulationMenu->addSeparator(); QAction* pause = new QAction(tr("&Pause"), emulationMenu);

@@ -1299,10 +1307,12 @@ QAction* viewLogs = new QAction(tr("View &logs..."), toolsMenu);

connect(viewLogs, SIGNAL(triggered()), m_logView, SLOT(show())); addControlledAction(toolsMenu, viewLogs, "viewLogs"); +#ifdef M_CORE_GBA QAction* overrides = new QAction(tr("Game &overrides..."), toolsMenu); connect(overrides, SIGNAL(triggered()), this, SLOT(openOverrideWindow())); m_gbaActions.append(overrides); addControlledAction(toolsMenu, overrides, "overrideWindow"); +#endif QAction* sensors = new QAction(tr("Game &Pak sensors..."), toolsMenu); connect(sensors, SIGNAL(triggered()), this, SLOT(openSensorWindow()));

@@ -1331,22 +1341,26 @@ connect(paletteView, SIGNAL(triggered()), this, SLOT(openPaletteWindow()));

m_gameActions.append(paletteView); addControlledAction(toolsMenu, paletteView, "paletteWindow"); +#ifdef M_CORE_GBA QAction* tileView = new QAction(tr("View &tiles..."), toolsMenu); connect(tileView, SIGNAL(triggered()), this, SLOT(openTileWindow())); m_gameActions.append(tileView); m_gbaActions.append(tileView); addControlledAction(toolsMenu, tileView, "tileWindow"); +#endif QAction* memoryView = new QAction(tr("View memory..."), toolsMenu); connect(memoryView, SIGNAL(triggered()), this, SLOT(openMemoryWindow())); m_gameActions.append(memoryView); addControlledAction(toolsMenu, memoryView, "memoryView"); +#ifdef M_CORE_GBA 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"); +#endif ConfigOption* skipBios = m_config->addOption("skipBios"); skipBios->connect([this](const QVariant& value) {
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -156,7 +156,9 @@ Display* m_display;

// TODO: Move these to a new class QList<QAction*> m_gameActions; QList<QAction*> m_nonMpActions; +#ifdef M_CORE_GBA QList<QAction*> m_gbaActions; +#endif QMap<int, QAction*> m_frameSizes; LogController m_log; LogView* m_logView;
A src/util/export.h

@@ -0,0 +1,16 @@

+/* Copyright (c) 2013-2015 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef EXPORT_H +#define EXPORT_H + +#include "util/common.h" + +struct VFile; + +bool exportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colors); +bool exportPaletteACT(struct VFile* vf, size_t entries, const uint16_t* colors); + +#endif