mirror of https://github.com/mgba-emu/mgba.git
Qt: Update ROMInfo dialog
This commit is contained in:
parent
d232a538cc
commit
d7d8dacaa8
|
@ -88,6 +88,7 @@ struct mCore {
|
|||
int32_t (*frequency)(struct mCore*);
|
||||
|
||||
void (*getGameTitle)(struct mCore*, char* title);
|
||||
void (*getGameCode)(struct mCore*, char* title);
|
||||
|
||||
void (*setRTC)(struct mCore*, struct mRTCSource*);
|
||||
};
|
||||
|
|
|
@ -230,6 +230,10 @@ static void _GBCoreGetGameTitle(struct mCore* core, char* title) {
|
|||
GBGetGameTitle(core->board, title);
|
||||
}
|
||||
|
||||
static void _GBCoreGetGameCode(struct mCore* core, char* title) {
|
||||
GBGetGameCode(core->board, title);
|
||||
}
|
||||
|
||||
static void _GBCoreSetRTC(struct mCore* core, struct mRTCSource* rtc) {
|
||||
struct GB* gb = core->board;
|
||||
gb->memory.rtc = rtc;
|
||||
|
@ -272,6 +276,7 @@ struct mCore* GBCoreCreate(void) {
|
|||
core->frameCycles = _GBCoreFrameCycles;
|
||||
core->frequency = _GBCoreFrequency;
|
||||
core->getGameTitle = _GBCoreGetGameTitle;
|
||||
core->getGameCode = _GBCoreGetGameCode;
|
||||
core->setRTC = _GBCoreSetRTC;
|
||||
return core;
|
||||
}
|
||||
|
|
17
src/gb/gb.c
17
src/gb/gb.c
|
@ -342,3 +342,20 @@ void GBGetGameTitle(struct GB* gb, char* out) {
|
|||
memcpy(out, cart->titleShort, 11);
|
||||
}
|
||||
}
|
||||
|
||||
void GBGetGameCode(struct GB* gb, char* out) {
|
||||
memset(out, 0, 4);
|
||||
const struct GBCartridge* cart = NULL;
|
||||
if (gb->memory.rom) {
|
||||
cart = (const struct GBCartridge*) &gb->memory.rom[0x100];
|
||||
}
|
||||
if (gb->pristineRom) {
|
||||
cart = (const struct GBCartridge*) &gb->pristineRom[0x100];
|
||||
}
|
||||
if (!cart) {
|
||||
return;
|
||||
}
|
||||
if (cart->oldLicensee == 0x33) {
|
||||
memcpy(out, cart->maker, 11);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ void GBApplyPatch(struct GB* gb, struct Patch* patch);
|
|||
|
||||
bool GBIsROM(struct VFile* vf);
|
||||
void GBGetGameTitle(struct GB* gba, char* out);
|
||||
void GBGetGameCode(struct GB* gba, char* out);
|
||||
|
||||
void GBFrameStarted(struct GB* gb);
|
||||
void GBFrameEnded(struct GB* gb);
|
||||
|
|
|
@ -263,6 +263,10 @@ static void _GBACoreGetGameTitle(struct mCore* core, char* title) {
|
|||
GBAGetGameTitle(core->board, title);
|
||||
}
|
||||
|
||||
static void _GBACoreGetGameCode(struct mCore* core, char* title) {
|
||||
GBAGetGameCode(core->board, title);
|
||||
}
|
||||
|
||||
static void _GBACoreSetRTC(struct mCore* core, struct mRTCSource* rtc) {
|
||||
struct GBA* gba = core->board;
|
||||
gba->rtcSource = rtc;
|
||||
|
@ -305,6 +309,7 @@ struct mCore* GBACoreCreate(void) {
|
|||
core->frameCycles = _GBACoreFrameCycles;
|
||||
core->frequency = _GBACoreFrequency;
|
||||
core->getGameTitle = _GBACoreGetGameTitle;
|
||||
core->getGameCode = _GBACoreGetGameCode;
|
||||
core->setRTC = _GBACoreSetRTC;
|
||||
return core;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,12 @@
|
|||
|
||||
extern "C" {
|
||||
#include "core/core.h"
|
||||
#ifdef M_CORE_GB
|
||||
#include "gb/gb.h"
|
||||
#endif
|
||||
#ifdef M_CORE_GBA
|
||||
#include "gba/gba.h"
|
||||
#endif
|
||||
#include "util/nointro.h"
|
||||
}
|
||||
|
||||
|
@ -32,12 +37,19 @@ ROMInfo::ROMInfo(GameController* controller, QWidget* parent)
|
|||
char title[17] = {};
|
||||
core->getGameTitle(core, title);
|
||||
m_ui.title->setText(QLatin1String(title));
|
||||
|
||||
if (controller->thread()->core->platform(controller->thread()->core) == PLATFORM_GBA) {
|
||||
GBA* gba = static_cast<GBA*>(core->board);
|
||||
GBAGetGameCode(gba, title);
|
||||
core->getGameCode(core, title);
|
||||
title[4] = '\0';
|
||||
if (title[0]) {
|
||||
m_ui.id->setText(QLatin1String(title));
|
||||
m_ui.size->setText(QString::number(gba->pristineRomSize));
|
||||
} else {
|
||||
m_ui.id->setText(tr("(unknown)"));
|
||||
}
|
||||
|
||||
switch (controller->thread()->core->platform(controller->thread()->core)) {
|
||||
#ifdef M_CORE_GBA
|
||||
case PLATFORM_GBA: {
|
||||
GBA* gba = static_cast<GBA*>(core->board);
|
||||
m_ui.size->setText(QString::number(gba->pristineRomSize) + tr(" bytes"));
|
||||
m_ui.crc->setText(QString::number(gba->romCrc32, 16));
|
||||
if (db) {
|
||||
NoIntroGame game;
|
||||
|
@ -49,12 +61,23 @@ ROMInfo::ROMInfo(GameController* controller, QWidget* parent)
|
|||
} else {
|
||||
m_ui.name->setText(tr("(no database present)"));
|
||||
}
|
||||
} else {
|
||||
// TODO: GB
|
||||
m_ui.id->setText(tr("(unknown)"));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef M_CORE_GB
|
||||
case PLATFORM_GB: {
|
||||
GB* gb = static_cast<GB*>(core->board);
|
||||
m_ui.size->setText(QString::number(gb->pristineRomSize) + tr(" bytes"));
|
||||
m_ui.crc->setText(QString::number(gb->romCrc32, 16));
|
||||
m_ui.name->setText(tr("(unknown)"));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
m_ui.size->setText(tr("(unknown)"));
|
||||
m_ui.crc->setText(tr("(unknown)"));
|
||||
m_ui.name->setText(tr("(unknown)"));
|
||||
|
||||
}
|
||||
controller->threadContinue();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue