From b0157aa871991d34cb6471e5184740ea63067fc9 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 5 Sep 2016 10:17:14 -0700 Subject: [PATCH] Qt: Preliminary build cleanup when GBA core is disabled --- CMakeLists.txt | 2 +- src/gba/gba.c | 1 - src/gba/gba.h | 2 +- src/platform/qt/GameController.cpp | 19 ++++++++++++++++++- src/platform/qt/PaletteView.cpp | 9 +++++---- src/platform/qt/Window.cpp | 14 ++++++++++++++ src/platform/qt/Window.h | 2 ++ src/{gba/extra => util}/export.c | 4 ++-- src/{gba/extra => util}/export.h | 8 ++++---- 9 files changed, 47 insertions(+), 14 deletions(-) rename src/{gba/extra => util}/export.c (89%) rename src/{gba/extra => util}/export.h (58%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90f69b435..afb3c0f3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.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() diff --git a/src/gba/gba.c b/src/gba/gba.c index d8436e47e..674da776f 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -28,7 +28,6 @@ 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; diff --git a/src/gba/gba.h b/src/gba/gba.h index 207bb11fb..d7de413b7 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -17,7 +17,7 @@ #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, diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 785eaf181..f53a7fdfe 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -71,6 +71,7 @@ GameController::GameController(QObject* parent) , 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(context); @@ -82,6 +83,7 @@ GameController::GameController(QObject* parent) return lux->value; }; setLuminanceLevel(0); +#endif m_threadContext.startCallback = [](mCoreThread* context) { GameController* controller = static_cast(context->userData); @@ -197,13 +199,16 @@ GameController::GameController(QObject* parent) return; } GameController* controller = static_cast(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 @@ void GameController::importSharkport(const QString& path) { GBASavedataImportSharkPort(static_cast(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 @@ void GameController::exportSharkport(const QString& path) { GBASavedataExportSharkPort(static_cast(m_threadContext.core->board), vf); threadContinue(); vf->close(vf); +#endif } void GameController::closeGame() { @@ -818,6 +833,7 @@ void GameController::setVideoLayerEnabled(int layer, bool enable) { return; } m_videoLayers[layer] = enable; +#ifdef M_CORE_GBA if (isLoaded() && m_threadContext.core->platform(m_threadContext.core) == PLATFORM_GBA) { GBA* gba = static_cast(m_threadContext.core->board); switch (layer) { @@ -832,6 +848,7 @@ void GameController::setVideoLayerEnabled(int layer, bool enable) { break; } } +#endif } void GameController::setFPSTarget(float fps) { diff --git a/src/platform/qt/PaletteView.cpp b/src/platform/qt/PaletteView.cpp index 5d72453dc..f8fe3a7f8 100644 --- a/src/platform/qt/PaletteView.cpp +++ b/src/platform/qt/PaletteView.cpp @@ -14,8 +14,9 @@ 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 @@ void PaletteView::exportPalette(int start, int length) { } QString filter = dialog->selectedNameFilter(); if (filter.contains("*.pal")) { - GBAExportPaletteRIFF(vf, length, &static_cast(m_controller->thread()->core->board)->video.palette[start]); + exportPaletteRIFF(vf, length, &static_cast(m_controller->thread()->core->board)->video.palette[start]); } else if (filter.contains("*.act")) { - GBAExportPaletteACT(vf, length, &static_cast(m_controller->thread()->core->board)->video.palette[start]); + exportPaletteACT(vf, length, &static_cast(m_controller->thread()->core->board)->video.palette[start]); } vf->close(vf); m_controller->threadContinue(); diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index b1559974d..9c7c9d58d 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -690,9 +690,11 @@ void Window::gameStarted(mCoreThread* context, const QString& fname) { 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 @@ void Window::gameStarted(mCoreThread* context, const QString& fname) { } 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 @@ void Window::setupMenu(QMenuBar* menubar) { 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 @@ void Window::setupMenu(QMenuBar* menubar) { 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 @@ void Window::setupMenu(QMenuBar* menubar) { 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 @@ void Window::setupMenu(QMenuBar* menubar) { 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 @@ void Window::setupMenu(QMenuBar* menubar) { 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) { diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h index 5a2c2fb2d..3bf0bb2f2 100644 --- a/src/platform/qt/Window.h +++ b/src/platform/qt/Window.h @@ -156,7 +156,9 @@ private: // TODO: Move these to a new class QList m_gameActions; QList m_nonMpActions; +#ifdef M_CORE_GBA QList m_gbaActions; +#endif QMap m_frameSizes; LogController m_log; LogView* m_logView; diff --git a/src/gba/extra/export.c b/src/util/export.c similarity index 89% rename from src/gba/extra/export.c rename to src/util/export.c index 4ef29174c..09dd1e084 100644 --- a/src/gba/extra/export.c +++ b/src/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 @@ bool GBAExportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colo 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; } diff --git a/src/gba/extra/export.h b/src/util/export.h similarity index 58% rename from src/gba/extra/export.h rename to src/util/export.h index 024e17618..3e933620c 100644 --- a/src/gba/extra/export.h +++ b/src/util/export.h @@ -3,14 +3,14 @@ * 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 +#ifndef EXPORT_H +#define 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); +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