From f61c0ce02f47218f795803e0fc1562a35fd84411 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 2 Aug 2017 17:00:29 -0700 Subject: [PATCH] GB: Support SGB boot ROM --- include/mgba/gb/interface.h | 10 ++++---- src/gb/core.c | 15 ++++++++++-- src/gb/overrides.c | 11 ++++++++- src/platform/qt/SettingsView.cpp | 6 +++++ src/platform/qt/SettingsView.ui | 40 +++++++++++++++++++++++++++----- 5 files changed, 69 insertions(+), 13 deletions(-) diff --git a/include/mgba/gb/interface.h b/include/mgba/gb/interface.h index 73996746c..77e7eef17 100644 --- a/include/mgba/gb/interface.h +++ b/include/mgba/gb/interface.h @@ -12,10 +12,12 @@ CXX_GUARD_START enum GBModel { GB_MODEL_AUTODETECT = 0xFF, - GB_MODEL_DMG = 0x00, - GB_MODEL_SGB = 0x40, - GB_MODEL_CGB = 0x80, - GB_MODEL_AGB = 0xC0 + GB_MODEL_DMG = 0x00, + GB_MODEL_SGB = 0x20, + GB_MODEL_MGB = 0x40, + GB_MODEL_SGB2 = 0x60, + GB_MODEL_CGB = 0x80, + GB_MODEL_AGB = 0xC0 }; enum GBMemoryBankControllerType { diff --git a/src/gb/core.c b/src/gb/core.c index aa2b61e87..a90479d86 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -181,6 +181,7 @@ static void _GBCoreLoadConfig(struct mCore* core, const struct mCoreConfig* conf } mCoreConfigCopyValue(&core->config, config, "gb.bios"); + mCoreConfigCopyValue(&core->config, config, "sgb.bios"); mCoreConfigCopyValue(&core->config, config, "gbc.bios"); #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 @@ -345,9 +346,13 @@ static void _GBCoreReset(struct mCore* core) { switch (gb->model) { case GB_MODEL_DMG: - case GB_MODEL_SGB: // TODO + case GB_MODEL_MGB: // TODO configPath = mCoreConfigGetValue(&core->config, "gb.bios"); break; + case GB_MODEL_SGB: + case GB_MODEL_SGB2: // TODO + configPath = mCoreConfigGetValue(&core->config, "sgb.bios"); + break; case GB_MODEL_CGB: case GB_MODEL_AGB: configPath = mCoreConfigGetValue(&core->config, "gbc.bios"); @@ -370,9 +375,13 @@ static void _GBCoreReset(struct mCore* core) { mCoreConfigDirectory(path, PATH_MAX); switch (gb->model) { case GB_MODEL_DMG: - case GB_MODEL_SGB: // TODO + case GB_MODEL_MGB: // TODO strncat(path, PATH_SEP "gb_bios.bin", PATH_MAX - strlen(path)); break; + case GB_MODEL_SGB: + case GB_MODEL_SGB2: // TODO + strncat(path, PATH_SEP "sgb_bios.bin", PATH_MAX - strlen(path)); + break; case GB_MODEL_CGB: case GB_MODEL_AGB: strncat(path, PATH_SEP "gbc_bios.bin", PATH_MAX - strlen(path)); @@ -566,7 +575,9 @@ size_t _GBListMemoryBlocks(const struct mCore* core, const struct mCoreMemoryBlo const struct GB* gb = core->board; switch (gb->model) { case GB_MODEL_DMG: + case GB_MODEL_MGB: case GB_MODEL_SGB: + case GB_MODEL_SGB2: default: *blocks = _GBMemoryBlocks; return sizeof(_GBMemoryBlocks) / sizeof(*_GBMemoryBlocks); diff --git a/src/gb/overrides.c b/src/gb/overrides.c index 8efd4c1b9..63adadf0b 100644 --- a/src/gb/overrides.c +++ b/src/gb/overrides.c @@ -57,7 +57,10 @@ bool GBOverrideFind(const struct Configuration* config, struct GBCartridgeOverri override->model = GB_MODEL_SGB; } else if (strcasecmp(model, "MGB") == 0) { found = true; - override->model = GB_MODEL_DMG; // TODO + override->model = GB_MODEL_MGB; + } else if (strcasecmp(model, "SGB2") == 0) { + found = true; + override->model = GB_MODEL_SGB2; } } @@ -99,6 +102,12 @@ void GBOverrideSave(struct Configuration* config, const struct GBCartridgeOverri case GB_MODEL_SGB: model = "SGB"; break; + case GB_MODEL_MGB: + model = "MGB"; + break; + case GB_MODEL_SGB2: + model = "SGB2"; + break; case GB_MODEL_CGB: model = "CGB"; break; diff --git a/src/platform/qt/SettingsView.cpp b/src/platform/qt/SettingsView.cpp index 4dd9bc143..7102ad767 100644 --- a/src/platform/qt/SettingsView.cpp +++ b/src/platform/qt/SettingsView.cpp @@ -159,6 +159,9 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC connect(m_ui.gbcBiosBrowse, &QPushButton::clicked, [this]() { selectBios(m_ui.gbcBios); }); + connect(m_ui.sgbBiosBrowse, &QPushButton::clicked, [this]() { + selectBios(m_ui.sgbBios); + }); QList defaultColors; defaultColors.append(QColor(0xF8, 0xF8, 0xF8)); @@ -190,6 +193,7 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC #else m_ui.gbBiosBrowse->hide(); m_ui.gbcBiosBrowse->hide(); + m_ui.sgbBiosBrowse->hide(); m_ui.gb->hide(); #endif @@ -275,6 +279,7 @@ void SettingsView::updateConfig() { saveSetting("gba.bios", m_ui.gbaBios); saveSetting("gb.bios", m_ui.gbBios); saveSetting("gbc.bios", m_ui.gbcBios); + saveSetting("sgb.bios", m_ui.sgbBios); saveSetting("useBios", m_ui.useBios); saveSetting("skipBios", m_ui.skipBios); saveSetting("audioBuffers", m_ui.audioBufferSize); @@ -377,6 +382,7 @@ void SettingsView::reloadConfig() { loadSetting("gba.bios", m_ui.gbaBios); loadSetting("gb.bios", m_ui.gbBios); loadSetting("gbc.bios", m_ui.gbcBios); + loadSetting("sgb.bios", m_ui.sgbBios); loadSetting("useBios", m_ui.useBios); loadSetting("skipBios", m_ui.skipBios); loadSetting("audioBuffers", m_ui.audioBufferSize); diff --git a/src/platform/qt/SettingsView.ui b/src/platform/qt/SettingsView.ui index 6a2379302..7b2510018 100644 --- a/src/platform/qt/SettingsView.ui +++ b/src/platform/qt/SettingsView.ui @@ -748,7 +748,7 @@ - + Use BIOS file if found @@ -758,14 +758,14 @@ - + Skip BIOS intro - + @@ -786,21 +786,21 @@ - + GBA BIOS file: - + GBC BIOS file: - + @@ -821,6 +821,34 @@ + + + + SGB BIOS file: + + + + + + + + + + 0 + 0 + + + + + + + + Browse + + + + +