all repos — mgba @ f61c0ce02f47218f795803e0fc1562a35fd84411

mGBA Game Boy Advance Emulator

GB: Support SGB boot ROM
Vicki Pfau vi@endrift.com
Wed, 02 Aug 2017 17:00:29 -0700
commit

f61c0ce02f47218f795803e0fc1562a35fd84411

parent

6ab7e178be1cd076965b035276e66491c41ee454

M include/mgba/gb/interface.hinclude/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 {
M src/gb/core.csrc/gb/core.c

@@ -181,6 +181,7 @@ GBVideoSetPalette(&gb->video, 3, color);

} 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,8 +346,12 @@ const char* configPath = NULL;

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:

@@ -370,8 +375,12 @@ char path[PATH_MAX];

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:

@@ -566,7 +575,9 @@ size_t _GBListMemoryBlocks(const struct mCore* core, const struct mCoreMemoryBlock** blocks) {

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);
M src/gb/overrides.csrc/gb/overrides.c

@@ -57,7 +57,10 @@ found = true;

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; } }

@@ -98,6 +101,12 @@ model = "DMG";

break; 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";
M src/platform/qt/SettingsView.cppsrc/platform/qt/SettingsView.cpp

@@ -159,6 +159,9 @@ });

connect(m_ui.gbcBiosBrowse, &QPushButton::clicked, [this]() { selectBios(m_ui.gbcBios); }); + connect(m_ui.sgbBiosBrowse, &QPushButton::clicked, [this]() { + selectBios(m_ui.sgbBios); + }); QList<QColor> defaultColors; defaultColors.append(QColor(0xF8, 0xF8, 0xF8));

@@ -190,6 +193,7 @@ }

#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 @@ loadSetting("bios", m_ui.gbaBios);

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);
M src/platform/qt/SettingsView.uisrc/platform/qt/SettingsView.ui

@@ -748,7 +748,7 @@ </widget>

</item> </layout> </item> - <item row="3" column="1"> + <item row="4" column="1"> <widget class="QCheckBox" name="useBios"> <property name="text"> <string>Use BIOS file if found</string>

@@ -758,14 +758,14 @@ <bool>true</bool>

</property> </widget> </item> - <item row="4" column="1"> + <item row="5" column="1"> <widget class="QCheckBox" name="skipBios"> <property name="text"> <string>Skip BIOS intro</string> </property> </widget> </item> - <item row="2" column="1"> + <item row="3" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_8"> <item> <widget class="QLineEdit" name="gbaBios">

@@ -786,21 +786,21 @@ </widget>

</item> </layout> </item> - <item row="2" column="0"> + <item row="3" column="0"> <widget class="QLabel" name="label_4"> <property name="text"> <string>GBA BIOS file:</string> </property> </widget> </item> - <item row="1" column="0"> + <item row="2" column="0"> <widget class="QLabel" name="label_5"> <property name="text"> <string>GBC BIOS file:</string> </property> </widget> </item> - <item row="1" column="1"> + <item row="2" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_30"> <item> <widget class="QLineEdit" name="gbcBios">

@@ -814,6 +814,34 @@ </widget>

</item> <item> <widget class="QPushButton" name="gbcBiosBrowse"> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_30"> + <property name="text"> + <string>SGB BIOS file:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_12"> + <item> + <widget class="QLineEdit" name="sgbBios"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="sgbBiosBrowse"> <property name="text"> <string>Browse</string> </property>