all repos — mgba @ 8beac67f5620196669fbef0c538e9d428c993ced

mGBA Game Boy Advance Emulator

Core: Game code should export platform info
Jeffrey Pfau jeffrey@endrift.com
Wed, 02 Mar 2016 19:56:54 -0800
commit

8beac67f5620196669fbef0c538e9d428c993ced

parent

0c7b505aee605e448a38bb1929675732d3089404

4 files changed, 13 insertions(+), 6 deletions(-)

jump to
M src/gb/gb.csrc/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.csrc/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.cppsrc/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.csrc/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) {