GBA Hardware: Game Boy Player detection is off by default

This commit is contained in:
Jeffrey Pfau 2015-07-25 12:19:19 -07:00
parent 97b82ae6cd
commit 3c55784c54
6 changed files with 164 additions and 92 deletions

View File

@ -787,7 +787,9 @@ void GBAFrameEnded(struct GBA* gba) {
gba->stream->postVideoFrame(gba->stream, gba->video.renderer); gba->stream->postVideoFrame(gba->stream, gba->video.renderer);
} }
GBAHardwarePlayerUpdate(gba); if (gba->memory.hw.devices & (HW_GB_PLAYER | HW_GB_PLAYER_DETECTION)) {
GBAHardwarePlayerUpdate(gba);
}
struct GBAThread* thread = GBAThreadGetContext(); struct GBAThread* thread = GBAThreadGetContext();
if (!thread) { if (!thread) {

View File

@ -44,6 +44,16 @@ static const int RTC_BYTES[8] = {
void GBAHardwareInit(struct GBACartridgeHardware* hw, uint16_t* base) { void GBAHardwareInit(struct GBACartridgeHardware* hw, uint16_t* base) {
hw->gpioBase = base; hw->gpioBase = base;
GBAHardwareClear(hw); GBAHardwareClear(hw);
hw->gbpCallback.d.readKeys = _gbpRead;
hw->gbpCallback.p = hw;
hw->gbpDriver.d.init = 0;
hw->gbpDriver.d.deinit = 0;
hw->gbpDriver.d.load = 0;
hw->gbpDriver.d.unload = 0;
hw->gbpDriver.d.writeRegister = _gbpSioWriteRegister;
hw->gbpDriver.d.processEvents = _gbpSioProcessEvents;
hw->gbpDriver.p = hw;
} }
void GBAHardwareClear(struct GBACartridgeHardware* hw) { void GBAHardwareClear(struct GBACartridgeHardware* hw) {
@ -516,15 +526,6 @@ void GBAHardwarePlayerUpdate(struct GBA* gba) {
} }
if (GBAHardwarePlayerCheckScreen(&gba->video)) { if (GBAHardwarePlayerCheckScreen(&gba->video)) {
gba->memory.hw.devices |= HW_GB_PLAYER; gba->memory.hw.devices |= HW_GB_PLAYER;
gba->memory.hw.gbpCallback.d.readKeys = _gbpRead;
gba->memory.hw.gbpCallback.p = &gba->memory.hw;
gba->memory.hw.gbpDriver.d.init = 0;
gba->memory.hw.gbpDriver.d.deinit = 0;
gba->memory.hw.gbpDriver.d.load = 0;
gba->memory.hw.gbpDriver.d.unload = 0;
gba->memory.hw.gbpDriver.d.writeRegister = _gbpSioWriteRegister;
gba->memory.hw.gbpDriver.d.processEvents = _gbpSioProcessEvents;
gba->memory.hw.gbpDriver.p = &gba->memory.hw;
gba->memory.hw.gbpInputsPosted = 0; gba->memory.hw.gbpInputsPosted = 0;
gba->memory.hw.gbpNextEvent = INT_MAX; gba->memory.hw.gbpNextEvent = INT_MAX;
gba->keyCallback = &gba->memory.hw.gbpCallback.d; gba->keyCallback = &gba->memory.hw.gbpCallback.d;

View File

@ -34,7 +34,8 @@ enum GBAHardwareDevice {
HW_LIGHT_SENSOR = 4, HW_LIGHT_SENSOR = 4,
HW_GYRO = 8, HW_GYRO = 8,
HW_TILT = 16, HW_TILT = 16,
HW_GB_PLAYER = 32 HW_GB_PLAYER = 32,
HW_GB_PLAYER_DETECTION = 64
}; };
enum GPIORegister { enum GPIORegister {

View File

@ -285,6 +285,12 @@ void GBAOverrideApply(struct GBA* gba, const struct GBACartridgeOverride* overri
if (override->hardware & HW_TILT) { if (override->hardware & HW_TILT) {
GBAHardwareInitTilt(&gba->memory.hw); GBAHardwareInitTilt(&gba->memory.hw);
} }
if (override->hardware & HW_GB_PLAYER_DETECTION) {
gba->memory.hw.devices |= HW_GB_PLAYER_DETECTION;
} else {
gba->memory.hw.devices &= ~HW_GB_PLAYER_DETECTION;
}
} }
if (override->idleLoop != IDLE_LOOP_NONE) { if (override->idleLoop != IDLE_LOOP_NONE) {

View File

@ -39,6 +39,7 @@ OverrideView::OverrideView(GameController* controller, ConfigController* config,
connect(m_ui.hwLight, SIGNAL(clicked()), this, SLOT(updateOverrides())); connect(m_ui.hwLight, SIGNAL(clicked()), this, SLOT(updateOverrides()));
connect(m_ui.hwTilt, SIGNAL(clicked()), this, SLOT(updateOverrides())); connect(m_ui.hwTilt, SIGNAL(clicked()), this, SLOT(updateOverrides()));
connect(m_ui.hwRumble, SIGNAL(clicked()), this, SLOT(updateOverrides())); connect(m_ui.hwRumble, SIGNAL(clicked()), this, SLOT(updateOverrides()));
connect(m_ui.hwGBPlayer, SIGNAL(clicked()), this, SLOT(updateOverrides()));
connect(m_ui.save, SIGNAL(clicked()), this, SLOT(saveOverride())); connect(m_ui.save, SIGNAL(clicked()), this, SLOT(saveOverride()));
@ -80,6 +81,9 @@ void OverrideView::updateOverrides() {
m_override.hardware |= HW_RUMBLE; m_override.hardware |= HW_RUMBLE;
} }
} }
if (m_ui.hwGBPlayer->isChecked()) {
m_override.hardware |= HW_GB_PLAYER_DETECTION;
}
bool ok; bool ok;
uint32_t parsedIdleLoop = m_ui.idleLoop->text().toInt(&ok, 16); uint32_t parsedIdleLoop = m_ui.idleLoop->text().toInt(&ok, 16);
@ -115,6 +119,7 @@ void OverrideView::gameStarted(GBAThread* thread) {
m_ui.hwLight->setChecked(thread->gba->memory.hw.devices & HW_LIGHT_SENSOR); m_ui.hwLight->setChecked(thread->gba->memory.hw.devices & HW_LIGHT_SENSOR);
m_ui.hwTilt->setChecked(thread->gba->memory.hw.devices & HW_TILT); m_ui.hwTilt->setChecked(thread->gba->memory.hw.devices & HW_TILT);
m_ui.hwRumble->setChecked(thread->gba->memory.hw.devices & HW_RUMBLE); m_ui.hwRumble->setChecked(thread->gba->memory.hw.devices & HW_RUMBLE);
m_ui.hwGBPlayer->setChecked(thread->gba->memory.hw.devices & HW_GB_PLAYER_DETECTION);
if (thread->gba->idleLoop != IDLE_LOOP_NONE) { if (thread->gba->idleLoop != IDLE_LOOP_NONE) {
m_ui.idleLoop->setText(QString::number(thread->gba->idleLoop, 16)); m_ui.idleLoop->setText(QString::number(thread->gba->idleLoop, 16));

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>409</width> <width>401</width>
<height>228</height> <height>203</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -23,13 +23,19 @@
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum> <enum>QLayout::SetFixedSize</enum>
</property> </property>
<item row="2" column="1"> <item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer> </spacer>
</item> </item>
<item> <item>
@ -44,7 +50,135 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="0" column="0" rowspan="3"> <item row="3" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Save type</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="savetype">
<item>
<property name="text">
<string>Autodetect</string>
</property>
</item>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>SRAM</string>
</property>
</item>
<item>
<property name="text">
<string>Flash 512kb</string>
</property>
</item>
<item>
<property name="text">
<string>Flash 1Mb</string>
</property>
</item>
<item>
<property name="text">
<string>EEPROM</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Idle loop</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="idleLoop"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="hwGBPlayer">
<property name="text">
<string>Game Boy Player features</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" rowspan="3">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string/> <string/>
@ -113,83 +247,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string/>
</property>
<layout class="QFormLayout" name="formLayout_5">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Save type</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="savetype">
<item>
<property name="text">
<string>Autodetect</string>
</property>
</item>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>SRAM</string>
</property>
</item>
<item>
<property name="text">
<string>Flash 512kb</string>
</property>
</item>
<item>
<property name="text">
<string>Flash 1Mb</string>
</property>
</item>
<item>
<property name="text">
<string>EEPROM</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Idle loop</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="idleLoop"/>
</item>
<item row="1" column="1">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>