Qt: GBA refactoring and cleanup

This commit is contained in:
Jeffrey Pfau 2016-02-09 22:03:31 -08:00
parent a75c019fab
commit 5bcf56c5ca
6 changed files with 57 additions and 30 deletions

View File

@ -46,6 +46,8 @@ struct mCore {
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*);

View File

@ -55,6 +55,11 @@ static void _GBCoreDeinit(struct mCore* core) {
#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 @@ struct mCore* GBCoreCreate(void) {
core->board = 0;
core->init = _GBCoreInit;
core->deinit = _GBCoreDeinit;
core->platform = _GBCorePlatform;
core->setSync = _GBCoreSetSync;
core->loadConfig = _GBCoreLoadConfig;
core->desiredVideoDimensions = _GBCoreDesiredVideoDimensions;

View File

@ -64,6 +64,11 @@ static void _GBACoreDeinit(struct mCore* core) {
#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 @@ struct mCore* GBACoreCreate(void) {
core->board = 0;
core->init = _GBACoreInit;
core->deinit = _GBACoreDeinit;
core->platform = _GBACorePlatform;
core->setSync = _GBACoreSetSync;
core->loadConfig = _GBACoreLoadConfig;
core->desiredVideoDimensions = _GBACoreDesiredVideoDimensions;

View File

@ -86,21 +86,23 @@ GameController::GameController(QObject* parent)
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:

View File

@ -29,23 +29,32 @@ ROMInfo::ROMInfo(GameController* controller, QWidget* parent)
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();
}

View File

@ -153,7 +153,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent)
});
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::selectROM() {
void Window::replaceROM() {
QStringList formats{
"*.gba",
"*.gb",
#if defined(USE_LIBZIP) || defined(USE_ZLIB)
"*.zip",
#endif
@ -717,7 +718,8 @@ void Window::updateTitle(float fps) {
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' };