Qt: Preliminary build cleanup when GBA core is disabled

This commit is contained in:
Jeffrey Pfau 2016-09-05 10:17:14 -07:00
parent 5b710a59fa
commit b0157aa871
9 changed files with 47 additions and 14 deletions

View File

@ -201,7 +201,7 @@ if(PSP2 OR WII)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format")
endif() 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) set(USE_GDB_STUB OFF)
endif() endif()

View File

@ -28,7 +28,6 @@
mLOG_DEFINE_CATEGORY(GBA, "GBA"); mLOG_DEFINE_CATEGORY(GBA, "GBA");
const uint32_t GBA_ARM7TDMI_FREQUENCY = 0x1000000;
const uint32_t GBA_COMPONENT_MAGIC = 0x1000000; const uint32_t GBA_COMPONENT_MAGIC = 0x1000000;
static const size_t GBA_ROM_MAGIC_OFFSET = 3; static const size_t GBA_ROM_MAGIC_OFFSET = 3;

View File

@ -17,7 +17,7 @@
#include "gba/audio.h" #include "gba/audio.h"
#include "gba/sio.h" #include "gba/sio.h"
extern const uint32_t GBA_ARM7TDMI_FREQUENCY; #define GBA_ARM7TDMI_FREQUENCY 0x1000000U
enum GBAIRQ { enum GBAIRQ {
IRQ_VBLANK = 0x0, IRQ_VBLANK = 0x0,

View File

@ -71,6 +71,7 @@ GameController::GameController(QObject* parent)
, m_saveStateFlags(SAVESTATE_SCREENSHOT | SAVESTATE_SAVEDATA | SAVESTATE_CHEATS) , m_saveStateFlags(SAVESTATE_SCREENSHOT | SAVESTATE_SAVEDATA | SAVESTATE_CHEATS)
, m_loadStateFlags(SAVESTATE_SCREENSHOT) , m_loadStateFlags(SAVESTATE_SCREENSHOT)
{ {
#ifdef M_CORE_GBA
m_lux.p = this; m_lux.p = this;
m_lux.sample = [](GBALuminanceSource* context) { m_lux.sample = [](GBALuminanceSource* context) {
GameControllerLux* lux = static_cast<GameControllerLux*>(context); GameControllerLux* lux = static_cast<GameControllerLux*>(context);
@ -82,6 +83,7 @@ GameController::GameController(QObject* parent)
return lux->value; return lux->value;
}; };
setLuminanceLevel(0); setLuminanceLevel(0);
#endif
m_threadContext.startCallback = [](mCoreThread* context) { m_threadContext.startCallback = [](mCoreThread* context) {
GameController* controller = static_cast<GameController*>(context->userData); GameController* controller = static_cast<GameController*>(context->userData);
@ -197,13 +199,16 @@ GameController::GameController(QObject* parent)
return; return;
} }
GameController* controller = static_cast<GameController*>(context->userData); GameController* controller = static_cast<GameController*>(context->userData);
#ifdef M_CORE_GBA
if (level == mLOG_STUB && category == _mLOG_CAT_GBA_BIOS()) { if (level == mLOG_STUB && category == _mLOG_CAT_GBA_BIOS()) {
va_list argc; va_list argc;
va_copy(argc, args); va_copy(argc, args);
int immediate = va_arg(argc, int); int immediate = va_arg(argc, int);
va_end(argc); va_end(argc);
QMetaObject::invokeMethod(controller, "unimplementedBiosCall", Q_ARG(int, immediate)); 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 // Slot 0 is reserved for suspend points
if (strncmp(savestateMessage, format, strlen(savestateMessage)) == 0) { if (strncmp(savestateMessage, format, strlen(savestateMessage)) == 0) {
va_list argc; va_list argc;
@ -503,6 +508,10 @@ void GameController::importSharkport(const QString& path) {
if (!isLoaded()) { if (!isLoaded()) {
return; return;
} }
#ifdef M_CORE_GBA
if (platform() != PLATFORM_GBA) {
return;
}
VFile* vf = VFileDevice::open(path, O_RDONLY); VFile* vf = VFileDevice::open(path, O_RDONLY);
if (!vf) { if (!vf) {
LOG(QT, ERROR) << tr("Failed to open snapshot file for reading: %1").arg(path); 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<GBA*>(m_threadContext.core->board), vf, false); GBASavedataImportSharkPort(static_cast<GBA*>(m_threadContext.core->board), vf, false);
threadContinue(); threadContinue();
vf->close(vf); vf->close(vf);
#endif
} }
void GameController::exportSharkport(const QString& path) { void GameController::exportSharkport(const QString& path) {
if (!isLoaded()) { if (!isLoaded()) {
return; return;
} }
#ifdef M_CORE_GBA
if (platform() != PLATFORM_GBA) {
return;
}
VFile* vf = VFileDevice::open(path, O_WRONLY | O_CREAT | O_TRUNC); VFile* vf = VFileDevice::open(path, O_WRONLY | O_CREAT | O_TRUNC);
if (!vf) { if (!vf) {
LOG(QT, ERROR) << tr("Failed to open snapshot file for writing: %1").arg(path); 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<GBA*>(m_threadContext.core->board), vf); GBASavedataExportSharkPort(static_cast<GBA*>(m_threadContext.core->board), vf);
threadContinue(); threadContinue();
vf->close(vf); vf->close(vf);
#endif
} }
void GameController::closeGame() { void GameController::closeGame() {
@ -818,6 +833,7 @@ void GameController::setVideoLayerEnabled(int layer, bool enable) {
return; return;
} }
m_videoLayers[layer] = enable; m_videoLayers[layer] = enable;
#ifdef M_CORE_GBA
if (isLoaded() && m_threadContext.core->platform(m_threadContext.core) == PLATFORM_GBA) { if (isLoaded() && m_threadContext.core->platform(m_threadContext.core) == PLATFORM_GBA) {
GBA* gba = static_cast<GBA*>(m_threadContext.core->board); GBA* gba = static_cast<GBA*>(m_threadContext.core->board);
switch (layer) { switch (layer) {
@ -832,6 +848,7 @@ void GameController::setVideoLayerEnabled(int layer, bool enable) {
break; break;
} }
} }
#endif
} }
void GameController::setFPSTarget(float fps) { void GameController::setFPSTarget(float fps) {

View File

@ -14,8 +14,9 @@
extern "C" { extern "C" {
#include "core/core.h" #include "core/core.h"
#ifdef M_CORE_GBA #include "util/export.h"
#include "gba/extra/export.h" #ifdef M_CORE_GA
#include "gba/gba.h"
#endif #endif
#ifdef M_CORE_GB #ifdef M_CORE_GB
#include "gb/gb.h" #include "gb/gb.h"
@ -148,9 +149,9 @@ void PaletteView::exportPalette(int start, int length) {
} }
QString filter = dialog->selectedNameFilter(); QString filter = dialog->selectedNameFilter();
if (filter.contains("*.pal")) { 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")) { } 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); vf->close(vf);
m_controller->threadContinue(); m_controller->threadContinue();

View File

@ -690,9 +690,11 @@ void Window::gameStarted(mCoreThread* context, const QString& fname) {
foreach (QAction* action, m_gameActions) { foreach (QAction* action, m_gameActions) {
action->setDisabled(false); action->setDisabled(false);
} }
#ifdef M_CORE_GBA
foreach (QAction* action, m_gbaActions) { foreach (QAction* action, m_gbaActions) {
action->setDisabled(context->core->platform(context->core) != PLATFORM_GBA); action->setDisabled(context->core->platform(context->core) != PLATFORM_GBA);
} }
#endif
multiplayerChanged(); multiplayerChanged();
if (!fname.isEmpty()) { if (!fname.isEmpty()) {
setWindowFilePath(fname); setWindowFilePath(fname);
@ -716,9 +718,11 @@ void Window::gameStarted(mCoreThread* context, const QString& fname) {
} }
void Window::gameStopped() { void Window::gameStopped() {
#ifdef M_CORE_GBA
foreach (QAction* action, m_gbaActions) { foreach (QAction* action, m_gbaActions) {
action->setDisabled(false); action->setDisabled(false);
} }
#endif
foreach (QAction* action, m_gameActions) { foreach (QAction* action, m_gameActions) {
action->setDisabled(true); action->setDisabled(true);
} }
@ -979,6 +983,7 @@ void Window::setupMenu(QMenuBar* menubar) {
addControlledAction(quickSaveMenu, quickSave, QString("quickSave.%1").arg(i)); addControlledAction(quickSaveMenu, quickSave, QString("quickSave.%1").arg(i));
} }
#ifdef M_CORE_GBA
fileMenu->addSeparator(); fileMenu->addSeparator();
QAction* importShark = new QAction(tr("Import GameShark Save"), fileMenu); QAction* importShark = new QAction(tr("Import GameShark Save"), fileMenu);
connect(importShark, SIGNAL(triggered()), this, SLOT(importSharkport())); connect(importShark, SIGNAL(triggered()), this, SLOT(importSharkport()));
@ -991,6 +996,7 @@ void Window::setupMenu(QMenuBar* menubar) {
m_gameActions.append(exportShark); m_gameActions.append(exportShark);
m_gbaActions.append(exportShark); m_gbaActions.append(exportShark);
addControlledAction(fileMenu, exportShark, "exportShark"); addControlledAction(fileMenu, exportShark, "exportShark");
#endif
fileMenu->addSeparator(); fileMenu->addSeparator();
QAction* multiWindow = new QAction(tr("New multiplayer window"), fileMenu); QAction* multiWindow = new QAction(tr("New multiplayer window"), fileMenu);
@ -1024,11 +1030,13 @@ void Window::setupMenu(QMenuBar* menubar) {
m_gameActions.append(shutdown); m_gameActions.append(shutdown);
addControlledAction(emulationMenu, shutdown, "shutdown"); addControlledAction(emulationMenu, shutdown, "shutdown");
#ifdef M_CORE_GBA
QAction* yank = new QAction(tr("Yank game pak"), emulationMenu); QAction* yank = new QAction(tr("Yank game pak"), emulationMenu);
connect(yank, SIGNAL(triggered()), m_controller, SLOT(yankPak())); connect(yank, SIGNAL(triggered()), m_controller, SLOT(yankPak()));
m_gameActions.append(yank); m_gameActions.append(yank);
m_gbaActions.append(yank); m_gbaActions.append(yank);
addControlledAction(emulationMenu, yank, "yank"); addControlledAction(emulationMenu, yank, "yank");
#endif
emulationMenu->addSeparator(); emulationMenu->addSeparator();
QAction* pause = new QAction(tr("&Pause"), emulationMenu); QAction* pause = new QAction(tr("&Pause"), emulationMenu);
@ -1299,10 +1307,12 @@ void Window::setupMenu(QMenuBar* menubar) {
connect(viewLogs, SIGNAL(triggered()), m_logView, SLOT(show())); connect(viewLogs, SIGNAL(triggered()), m_logView, SLOT(show()));
addControlledAction(toolsMenu, viewLogs, "viewLogs"); addControlledAction(toolsMenu, viewLogs, "viewLogs");
#ifdef M_CORE_GBA
QAction* overrides = new QAction(tr("Game &overrides..."), toolsMenu); QAction* overrides = new QAction(tr("Game &overrides..."), toolsMenu);
connect(overrides, SIGNAL(triggered()), this, SLOT(openOverrideWindow())); connect(overrides, SIGNAL(triggered()), this, SLOT(openOverrideWindow()));
m_gbaActions.append(overrides); m_gbaActions.append(overrides);
addControlledAction(toolsMenu, overrides, "overrideWindow"); addControlledAction(toolsMenu, overrides, "overrideWindow");
#endif
QAction* sensors = new QAction(tr("Game &Pak sensors..."), toolsMenu); QAction* sensors = new QAction(tr("Game &Pak sensors..."), toolsMenu);
connect(sensors, SIGNAL(triggered()), this, SLOT(openSensorWindow())); connect(sensors, SIGNAL(triggered()), this, SLOT(openSensorWindow()));
@ -1331,22 +1341,26 @@ void Window::setupMenu(QMenuBar* menubar) {
m_gameActions.append(paletteView); m_gameActions.append(paletteView);
addControlledAction(toolsMenu, paletteView, "paletteWindow"); addControlledAction(toolsMenu, paletteView, "paletteWindow");
#ifdef M_CORE_GBA
QAction* tileView = new QAction(tr("View &tiles..."), toolsMenu); QAction* tileView = new QAction(tr("View &tiles..."), toolsMenu);
connect(tileView, SIGNAL(triggered()), this, SLOT(openTileWindow())); connect(tileView, SIGNAL(triggered()), this, SLOT(openTileWindow()));
m_gameActions.append(tileView); m_gameActions.append(tileView);
m_gbaActions.append(tileView); m_gbaActions.append(tileView);
addControlledAction(toolsMenu, tileView, "tileWindow"); addControlledAction(toolsMenu, tileView, "tileWindow");
#endif
QAction* memoryView = new QAction(tr("View memory..."), toolsMenu); QAction* memoryView = new QAction(tr("View memory..."), toolsMenu);
connect(memoryView, SIGNAL(triggered()), this, SLOT(openMemoryWindow())); connect(memoryView, SIGNAL(triggered()), this, SLOT(openMemoryWindow()));
m_gameActions.append(memoryView); m_gameActions.append(memoryView);
addControlledAction(toolsMenu, memoryView, "memoryView"); addControlledAction(toolsMenu, memoryView, "memoryView");
#ifdef M_CORE_GBA
QAction* ioViewer = new QAction(tr("View &I/O registers..."), toolsMenu); QAction* ioViewer = new QAction(tr("View &I/O registers..."), toolsMenu);
connect(ioViewer, SIGNAL(triggered()), this, SLOT(openIOViewer())); connect(ioViewer, SIGNAL(triggered()), this, SLOT(openIOViewer()));
m_gameActions.append(ioViewer); m_gameActions.append(ioViewer);
m_gbaActions.append(ioViewer); m_gbaActions.append(ioViewer);
addControlledAction(toolsMenu, ioViewer, "ioViewer"); addControlledAction(toolsMenu, ioViewer, "ioViewer");
#endif
ConfigOption* skipBios = m_config->addOption("skipBios"); ConfigOption* skipBios = m_config->addOption("skipBios");
skipBios->connect([this](const QVariant& value) { skipBios->connect([this](const QVariant& value) {

View File

@ -156,7 +156,9 @@ private:
// TODO: Move these to a new class // TODO: Move these to a new class
QList<QAction*> m_gameActions; QList<QAction*> m_gameActions;
QList<QAction*> m_nonMpActions; QList<QAction*> m_nonMpActions;
#ifdef M_CORE_GBA
QList<QAction*> m_gbaActions; QList<QAction*> m_gbaActions;
#endif
QMap<int, QAction*> m_frameSizes; QMap<int, QAction*> m_frameSizes;
LogController m_log; LogController m_log;
LogView* m_logView; LogView* m_logView;

View File

@ -8,7 +8,7 @@
#include "gba/video.h" #include "gba/video.h"
#include "util/vfs.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) { if (entries > 0xFFFF) {
return false; return false;
} }
@ -56,7 +56,7 @@ bool GBAExportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colo
return true; 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) { if (entries > 256) {
return false; return false;
} }

View File

@ -3,14 +3,14 @@
* This Source Code Form is subject to the terms of the Mozilla Public * 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GBA_EXPORT_H #ifndef EXPORT_H
#define GBA_EXPORT_H #define EXPORT_H
#include "util/common.h" #include "util/common.h"
struct VFile; struct VFile;
bool GBAExportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colors); bool exportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colors);
bool GBAExportPaletteACT(struct VFile* vf, size_t entries, const uint16_t* colors); bool exportPaletteACT(struct VFile* vf, size_t entries, const uint16_t* colors);
#endif #endif