all repos — mgba @ 5bcf56c5caccea4021abc92b461a0873978546f5

mGBA Game Boy Advance Emulator

Qt: GBA refactoring and cleanup
Jeffrey Pfau jeffrey@endrift.com
Tue, 09 Feb 2016 22:03:31 -0800
commit

5bcf56c5caccea4021abc92b461a0873978546f5

parent

a75c019fab24f045069cb9a923d02795f4d6f564

M src/core/core.hsrc/core/core.h

@@ -46,6 +46,8 @@

bool (*init)(struct mCore*); void (*deinit)(struct mCore*); + enum mPlatform (*platform)(struct mCore*); + void (*setSync)(struct mCore*, struct mCoreSync*); void (*loadConfig)(struct mCore*, const struct mCoreConfig*);
M src/gb/core.csrc/gb/core.c

@@ -55,6 +55,11 @@ mDirectorySetDeinit(&core->dirs);

#endif } +static enum mPlatform _GBCorePlatform(struct mCore* core) { + UNUSED(core); + return PLATFORM_GB; +} + static void _GBCoreSetSync(struct mCore* core, struct mCoreSync* sync) { struct GB* gb = core->board; gb->sync = sync;

@@ -229,6 +234,7 @@ core->cpu = 0;

core->board = 0; core->init = _GBCoreInit; core->deinit = _GBCoreDeinit; + core->platform = _GBCorePlatform; core->setSync = _GBCoreSetSync; core->loadConfig = _GBCoreLoadConfig; core->desiredVideoDimensions = _GBCoreDesiredVideoDimensions;
M src/gba/core.csrc/gba/core.c

@@ -64,6 +64,11 @@ mDirectorySetDeinit(&core->dirs);

#endif } +static enum mPlatform _GBACorePlatform(struct mCore* core) { + UNUSED(core); + return PLATFORM_GBA; +} + static void _GBACoreSetSync(struct mCore* core, struct mCoreSync* sync) { struct GBA* gba = core->board; gba->sync = sync;

@@ -265,6 +270,7 @@ core->cpu = 0;

core->board = 0; core->init = _GBACoreInit; core->deinit = _GBACoreDeinit; + core->platform = _GBACorePlatform; core->setSync = _GBACoreSetSync; core->loadConfig = _GBACoreLoadConfig; core->desiredVideoDimensions = _GBACoreDesiredVideoDimensions;
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -86,21 +86,23 @@ }

mRTCGenericSourceInit(&controller->m_rtc, context->core); context->core->setRTC(context->core, &controller->m_rtc.d); - /*GBA* gba = static_cast<GBA*>(context->core->board); - gba->luminanceSource = &controller->m_lux; - gba->rumble = controller->m_inputController->rumble(); - gba->rotationSource = controller->m_inputController->rotationSource(); - gba->audio.psg.forceDisableCh[0] = !controller->m_audioChannels[0]; - gba->audio.psg.forceDisableCh[1] = !controller->m_audioChannels[1]; - gba->audio.psg.forceDisableCh[2] = !controller->m_audioChannels[2]; - gba->audio.psg.forceDisableCh[3] = !controller->m_audioChannels[3]; - gba->audio.forceDisableChA = !controller->m_audioChannels[4]; - gba->audio.forceDisableChB = !controller->m_audioChannels[5]; - gba->video.renderer->disableBG[0] = !controller->m_videoLayers[0]; - gba->video.renderer->disableBG[1] = !controller->m_videoLayers[1]; - gba->video.renderer->disableBG[2] = !controller->m_videoLayers[2]; - gba->video.renderer->disableBG[3] = !controller->m_videoLayers[3]; - gba->video.renderer->disableOBJ = !controller->m_videoLayers[4];*/ + if (context->core->platform(context->core) == PLATFORM_GBA) { + GBA* gba = static_cast<GBA*>(context->core->board); + gba->luminanceSource = &controller->m_lux; + gba->rumble = controller->m_inputController->rumble(); + gba->rotationSource = controller->m_inputController->rotationSource(); + gba->audio.psg.forceDisableCh[0] = !controller->m_audioChannels[0]; + gba->audio.psg.forceDisableCh[1] = !controller->m_audioChannels[1]; + gba->audio.psg.forceDisableCh[2] = !controller->m_audioChannels[2]; + gba->audio.psg.forceDisableCh[3] = !controller->m_audioChannels[3]; + gba->audio.forceDisableChA = !controller->m_audioChannels[4]; + gba->audio.forceDisableChB = !controller->m_audioChannels[5]; + gba->video.renderer->disableBG[0] = !controller->m_videoLayers[0]; + gba->video.renderer->disableBG[1] = !controller->m_videoLayers[1]; + gba->video.renderer->disableBG[2] = !controller->m_videoLayers[2]; + gba->video.renderer->disableBG[3] = !controller->m_videoLayers[3]; + gba->video.renderer->disableOBJ = !controller->m_videoLayers[4]; + } controller->m_fpsTarget = context->sync.fpsTarget; if (mCoreLoadState(context->core, 0, controller->m_loadStateFlags)) {

@@ -661,9 +663,9 @@ void GameController::setVideoLayerEnabled(int layer, bool enable) {

if (layer > 4 || layer < 0) { return; } - GBA* gba = static_cast<GBA*>(m_threadContext.core->board); m_videoLayers[layer] = enable; - if (isLoaded()) { + if (isLoaded() && m_threadContext.core->platform(m_threadContext.core) == PLATFORM_GBA) { + GBA* gba = static_cast<GBA*>(m_threadContext.core->board); switch (layer) { case 0: case 1:
M src/platform/qt/ROMInfo.cppsrc/platform/qt/ROMInfo.cpp

@@ -29,23 +29,32 @@ const NoIntroDB* db = GBAApp::app()->gameDB();

controller->threadInterrupt(); mCore* core = controller->thread()->core; - GBA* gba = static_cast<GBA*>(core->board); char title[17] = {}; - GBAGetGameCode(gba, title); - m_ui.id->setText(QLatin1String(title)); core->getGameTitle(core, title); m_ui.title->setText(QLatin1String(title)); - m_ui.size->setText(QString::number(gba->pristineRomSize)); - m_ui.crc->setText(QString::number(gba->romCrc32, 16)); - if (db) { - NoIntroGame game; - if (NoIntroDBLookupGameByCRC(db, gba->romCrc32, &game)) { - m_ui.name->setText(game.name); + + if (controller->thread()->core->platform(controller->thread()->core) == PLATFORM_GBA) { + GBA* gba = static_cast<GBA*>(core->board); + GBAGetGameCode(gba, title); + m_ui.id->setText(QLatin1String(title)); + m_ui.size->setText(QString::number(gba->pristineRomSize)); + m_ui.crc->setText(QString::number(gba->romCrc32, 16)); + if (db) { + NoIntroGame game; + if (NoIntroDBLookupGameByCRC(db, gba->romCrc32, &game)) { + m_ui.name->setText(game.name); + } else { + m_ui.name->setText(tr("(unknown)")); + } } else { - m_ui.name->setText(tr("(unknown)")); + m_ui.name->setText(tr("(no database present)")); } } else { - m_ui.name->setText(tr("(no database present)")); + // TODO: GB + m_ui.id->setText(tr("(unknown)")); + m_ui.size->setText(tr("(unknown)")); + m_ui.crc->setText(tr("(unknown)")); + m_ui.name->setText(tr("(unknown)")); } controller->threadContinue(); }
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -153,7 +153,7 @@ m_screenWidget->unsetCursor();

}); connect(&m_inputController, SIGNAL(profileLoaded(const QString&)), m_shortcutController, SLOT(loadProfile(const QString&))); - m_log.setLevels(GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL | GBA_LOG_STATUS); + m_log.setLevels(mLOG_WARN | mLOG_ERROR | mLOG_FATAL); m_fpsTimer.setInterval(FPS_TIMER_INTERVAL); m_focusCheck.setInterval(200);

@@ -295,6 +295,7 @@

void Window::replaceROM() { QStringList formats{ "*.gba", + "*.gb", #if defined(USE_LIBZIP) || defined(USE_ZLIB) "*.zip", #endif

@@ -717,7 +718,8 @@ m_controller->threadInterrupt();

if (m_controller->isLoaded()) { const NoIntroDB* db = GBAApp::app()->gameDB(); NoIntroGame game; - if (db && NoIntroDBLookupGameByCRC(db, static_cast<GBA*>(m_controller->thread()->core->board)->romCrc32, &game)) { + if (m_controller->thread()->core->platform(m_controller->thread()->core) == PLATFORM_GBA && db && + NoIntroDBLookupGameByCRC(db, static_cast<GBA*>(m_controller->thread()->core->board)->romCrc32, &game)) { title = QLatin1String(game.name); } else { char gameTitle[17] = { '\0' };