Core: Game code should export platform info
Jeffrey Pfau jeffrey@endrift.com
Wed, 02 Mar 2016 19:56:54 -0800
4 files changed,
13 insertions(+),
6 deletions(-)
M
src/gb/gb.c
→
src/gb/gb.c
@@ -357,7 +357,7 @@ }
} 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 @@ }
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); } }
M
src/gba/gba.c
→
src/gba/gba.c
@@ -706,11 +706,13 @@ return true;
} 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) {
M
src/platform/qt/ROMInfo.cpp
→
src/platform/qt/ROMInfo.cpp
@@ -38,8 +38,8 @@ mCore* core = controller->thread()->core;
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 {
M
src/platform/test/perf-main.c
→
src/platform/test/perf-main.c
@@ -141,7 +141,7 @@ return false;
} // TODO: Put back debugger - char gameCode[5] = { 0 }; + char gameCode[9] = { 0 }; core->init(core); if (!perfOpts->noVideo) {