Qt: Update ROMInfo dialog
Jeffrey Pfau jeffrey@endrift.com
Tue, 16 Feb 2016 22:18:09 -0800
6 files changed,
59 insertions(+),
7 deletions(-)
M
src/core/core.h
→
src/core/core.h
@@ -88,6 +88,7 @@ int32_t (*frameCycles)(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*); };
M
src/gb/core.c
→
src/gb/core.c
@@ -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 @@ core->frameCounter = _GBCoreFrameCounter;
core->frameCycles = _GBCoreFrameCycles; core->frequency = _GBCoreFrequency; core->getGameTitle = _GBCoreGetGameTitle; + core->getGameCode = _GBCoreGetGameCode; core->setRTC = _GBCoreSetRTC; return core; }
M
src/gb/gb.c
→
src/gb/gb.c
@@ -342,3 +342,20 @@ } else {
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); + } +}
M
src/gb/gb.h
→
src/gb/gb.h
@@ -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);
M
src/gba/core.c
→
src/gba/core.c
@@ -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 @@ core->frameCounter = _GBACoreFrameCounter;
core->frameCycles = _GBACoreFrameCycles; core->frequency = _GBACoreFrequency; core->getGameTitle = _GBACoreGetGameTitle; + core->getGameCode = _GBACoreGetGameCode; core->setRTC = _GBACoreSetRTC; return core; }
M
src/platform/qt/ROMInfo.cpp
→
src/platform/qt/ROMInfo.cpp
@@ -10,7 +10,12 @@ #include "GameController.h"
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 @@ mCore* core = controller->thread()->core;
char title[17] = {}; core->getGameTitle(core, title); m_ui.title->setText(QLatin1String(title)); + core->getGameCode(core, title); + title[4] = '\0'; + if (title[0]) { + m_ui.id->setText(QLatin1String(title)); + } else { + m_ui.id->setText(tr("(unknown)")); + } - if (controller->thread()->core->platform(controller->thread()->core) == PLATFORM_GBA) { + switch (controller->thread()->core->platform(controller->thread()->core)) { +#ifdef M_CORE_GBA + case 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.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 @@ }
} 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(); }