From 8beac67f5620196669fbef0c538e9d428c993ced Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 2 Mar 2016 19:56:54 -0800 Subject: [PATCH] Core: Game code should export platform info --- src/gb/gb.c | 9 +++++++-- src/gba/gba.c | 6 ++++-- src/platform/qt/ROMInfo.cpp | 2 +- src/platform/test/perf-main.c | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gb/gb.c b/src/gb/gb.c index b50e9e371..d366b1516 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -357,7 +357,7 @@ void GBGetGameTitle(struct GB* gb, char* out) { } void GBGetGameCode(struct GB* gb, char* out) { - memset(out, 0, 4); + memset(out, 0, 8); const struct GBCartridge* cart = NULL; if (gb->memory.rom) { cart = (const struct GBCartridge*) &gb->memory.rom[0x100]; @@ -368,7 +368,12 @@ void GBGetGameCode(struct GB* gb, char* out) { if (!cart) { return; } + if (cart->cgb == 0xC0) { + memcpy(out, "CGB-????", 8); + } else { + memcpy(out, "DMG-????", 8); + } if (cart->oldLicensee == 0x33) { - memcpy(out, cart->maker, 11); + memcpy(&out[4], cart->maker, 4); } } diff --git a/src/gba/gba.c b/src/gba/gba.c index b97e4846d..52fbb0b60 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -706,11 +706,13 @@ bool GBAIsBIOS(struct VFile* vf) { } void GBAGetGameCode(struct GBA* gba, char* out) { + memset(out, 0, 8); if (!gba->memory.rom) { - out[0] = '\0'; return; } - memcpy(out, &((struct GBACartridge*) gba->memory.rom)->id, 4); + + memcpy(out, "AGB-", 4); + memcpy(&out[4], &((struct GBACartridge*) gba->memory.rom)->id, 4); } void GBAGetGameTitle(struct GBA* gba, char* out) { diff --git a/src/platform/qt/ROMInfo.cpp b/src/platform/qt/ROMInfo.cpp index 08764beba..70e1ffdb0 100644 --- a/src/platform/qt/ROMInfo.cpp +++ b/src/platform/qt/ROMInfo.cpp @@ -38,8 +38,8 @@ ROMInfo::ROMInfo(GameController* controller, QWidget* parent) char title[17] = {}; core->getGameTitle(core, title); m_ui.title->setText(QLatin1String(title)); + title[8] = '\0'; core->getGameCode(core, title); - title[4] = '\0'; if (title[0]) { m_ui.id->setText(QLatin1String(title)); } else { diff --git a/src/platform/test/perf-main.c b/src/platform/test/perf-main.c index ece368e3d..78aca7eaa 100644 --- a/src/platform/test/perf-main.c +++ b/src/platform/test/perf-main.c @@ -141,7 +141,7 @@ bool _mPerfRunCore(const char* fname, const struct mArguments* args, const struc } // TODO: Put back debugger - char gameCode[5] = { 0 }; + char gameCode[9] = { 0 }; core->init(core); if (!perfOpts->noVideo) {