all repos — mgba @ 965f2745398f08f115de731fbcf50d4be52a49ac

mGBA Game Boy Advance Emulator

src/platform/qt/ROMInfo.cpp (view raw)

 1/* Copyright (c) 2013-2015 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "ROMInfo.h"
 7
 8#include "GBAApp.h"
 9#include "GameController.h"
10
11extern "C" {
12#include "core/core.h"
13#include "gba/gba.h"
14#include "util/nointro.h"
15}
16
17using namespace QGBA;
18
19ROMInfo::ROMInfo(GameController* controller, QWidget* parent)
20	: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
21{
22	m_ui.setupUi(this);
23
24	if (!controller->isLoaded()) {
25		return;
26	}
27
28	const NoIntroDB* db = GBAApp::app()->gameDB();
29
30	controller->threadInterrupt();
31	mCore* core = controller->thread()->core;
32	char title[17] = {};
33	core->getGameTitle(core, title);
34	m_ui.title->setText(QLatin1String(title));
35
36	if (controller->thread()->core->platform(controller->thread()->core) == PLATFORM_GBA) {
37		GBA* gba = static_cast<GBA*>(core->board);
38		GBAGetGameCode(gba, title);
39		m_ui.id->setText(QLatin1String(title));
40		m_ui.size->setText(QString::number(gba->pristineRomSize));
41		m_ui.crc->setText(QString::number(gba->romCrc32, 16));
42		if (db) {
43			NoIntroGame game;
44			if (NoIntroDBLookupGameByCRC(db, gba->romCrc32, &game)) {
45				m_ui.name->setText(game.name);
46			} else {
47				m_ui.name->setText(tr("(unknown)"));
48			}
49		} else {
50			m_ui.name->setText(tr("(no database present)"));
51		}
52	} else {
53		// TODO: GB
54		m_ui.id->setText(tr("(unknown)"));
55		m_ui.size->setText(tr("(unknown)"));
56		m_ui.crc->setText(tr("(unknown)"));
57		m_ui.name->setText(tr("(unknown)"));
58	}
59	controller->threadContinue();
60}