Core: Game code should export platform info

This commit is contained in:
Jeffrey Pfau 2016-03-02 19:56:54 -08:00
parent 0c7b505aee
commit 8beac67f56
4 changed files with 13 additions and 6 deletions

View File

@ -357,7 +357,7 @@ void GBGetGameTitle(struct GB* gb, char* out) {
} }
void GBGetGameCode(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; const struct GBCartridge* cart = NULL;
if (gb->memory.rom) { if (gb->memory.rom) {
cart = (const struct GBCartridge*) &gb->memory.rom[0x100]; cart = (const struct GBCartridge*) &gb->memory.rom[0x100];
@ -368,7 +368,12 @@ void GBGetGameCode(struct GB* gb, char* out) {
if (!cart) { if (!cart) {
return; return;
} }
if (cart->cgb == 0xC0) {
memcpy(out, "CGB-????", 8);
} else {
memcpy(out, "DMG-????", 8);
}
if (cart->oldLicensee == 0x33) { if (cart->oldLicensee == 0x33) {
memcpy(out, cart->maker, 11); memcpy(&out[4], cart->maker, 4);
} }
} }

View File

@ -706,11 +706,13 @@ bool GBAIsBIOS(struct VFile* vf) {
} }
void GBAGetGameCode(struct GBA* gba, char* out) { void GBAGetGameCode(struct GBA* gba, char* out) {
memset(out, 0, 8);
if (!gba->memory.rom) { if (!gba->memory.rom) {
out[0] = '\0';
return; 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) { void GBAGetGameTitle(struct GBA* gba, char* out) {

View File

@ -38,8 +38,8 @@ ROMInfo::ROMInfo(GameController* controller, QWidget* parent)
char title[17] = {}; char title[17] = {};
core->getGameTitle(core, title); core->getGameTitle(core, title);
m_ui.title->setText(QLatin1String(title)); m_ui.title->setText(QLatin1String(title));
title[8] = '\0';
core->getGameCode(core, title); core->getGameCode(core, title);
title[4] = '\0';
if (title[0]) { if (title[0]) {
m_ui.id->setText(QLatin1String(title)); m_ui.id->setText(QLatin1String(title));
} else { } else {

View File

@ -141,7 +141,7 @@ bool _mPerfRunCore(const char* fname, const struct mArguments* args, const struc
} }
// TODO: Put back debugger // TODO: Put back debugger
char gameCode[5] = { 0 }; char gameCode[9] = { 0 };
core->init(core); core->init(core);
if (!perfOpts->noVideo) { if (!perfOpts->noVideo) {