Add option to report empty GC disc drive as closed (issue 11840)

This commit is contained in:
blåhaj 2021-04-08 21:24:37 +02:00 committed by Admiral H. Curtiss
parent 57e56f4bc2
commit 75c95ed05c
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
6 changed files with 29 additions and 3 deletions

View File

@ -44,6 +44,8 @@ const Info<int> MAIN_MAX_FALLBACK{{System::Main, "Core", "MaxFallback"}, 100};
const Info<int> MAIN_TIMING_VARIANCE{{System::Main, "Core", "TimingVariance"}, 40};
const Info<bool> MAIN_CPU_THREAD{{System::Main, "Core", "CPUThread"}, true};
const Info<bool> MAIN_SYNC_ON_SKIP_IDLE{{System::Main, "Core", "SyncOnSkipIdle"}, true};
const Info<bool> MAIN_GC_EMPTY_DRIVE_IS_CLOSED{{System::Main, "Core", "GCEmptyDriveIsClosed"},
false};
const Info<std::string> MAIN_DEFAULT_ISO{{System::Main, "Core", "DefaultISO"}, ""};
const Info<bool> MAIN_ENABLE_CHEATS{{System::Main, "Core", "EnableCheats"}, false};
const Info<int> MAIN_GC_LANGUAGE{{System::Main, "Core", "SelectedLanguage"}, 0};

View File

@ -63,6 +63,7 @@ extern const Info<int> MAIN_MAX_FALLBACK;
extern const Info<int> MAIN_TIMING_VARIANCE;
extern const Info<bool> MAIN_CPU_THREAD;
extern const Info<bool> MAIN_SYNC_ON_SKIP_IDLE;
extern const Info<bool> MAIN_GC_EMPTY_DRIVE_IS_CLOSED;
extern const Info<std::string> MAIN_DEFAULT_ISO;
extern const Info<bool> MAIN_ENABLE_CHEATS;
extern const Info<int> MAIN_GC_LANGUAGE;

View File

@ -257,7 +257,7 @@ void DVDInterface::Init()
m_system.GetDVDThread().Start();
m_DISR.Hex = 0;
m_DICVR.Hex = 1; // Disc Channel relies on cover being open when no disc is inserted
m_DICVR.Hex = ShouldLidBeOpen() ? 1 : 0;
m_DICMDBUF[0] = 0;
m_DICMDBUF[1] = 0;
m_DICMDBUF[2] = 0;
@ -304,7 +304,7 @@ void DVDInterface::ResetDrive(bool spinup)
// On the Wii, this can only happen if something other than a DVD is inserted into the disc
// drive (for instance, an audio CD) and only after it attempts to read it. Otherwise, it will
// report the cover as opened.
SetDriveState(DriveState::CoverOpened);
SetDriveState(ShouldLidBeOpen() ? DriveState::CoverOpened : DriveState::NoMediumPresent);
}
else if (!spinup)
{
@ -494,10 +494,19 @@ bool DVDInterface::AutoChangeDisc()
return true;
}
bool DVDInterface::ShouldLidBeOpen()
{
// Disc Channel relies on cover being open when no disc is inserted.
// The Wii also has no physical cover. (TODO: How does the Wii Mini behave?)
// Therefore, the behaviour is only customisable for the GameCube.
return (!IsDiscInside() &&
(SConfig::GetInstance().bWii || !Config::Get(Config::MAIN_GC_EMPTY_DRIVE_IS_CLOSED)));
}
void DVDInterface::SetLidOpen()
{
const u32 old_value = m_DICVR.CVR;
m_DICVR.CVR = IsDiscInside() ? 0 : 1;
m_DICVR.CVR = ShouldLidBeOpen() ? 1 : 0;
if (m_DICVR.CVR != old_value)
GenerateDIInterrupt(DIInterruptType::CVRINT);
}

View File

@ -182,6 +182,7 @@ private:
const std::vector<u8>& audio_data);
u32 AdvanceDTK(u32 maximum_blocks, u32* blocks_to_process);
bool ShouldLidBeOpen();
void SetLidOpen();
void UpdateInterrupts();
void GenerateDIInterrupt(DIInterruptType dvd_interrupt);

View File

@ -65,6 +65,9 @@ void GameCubePane::CreateWidgets()
QVBoxLayout* layout = new QVBoxLayout(this);
m_empty_drive_is_closed = new QCheckBox(
tr("Report disc drive as closed when empty (shows GameCube logo sequence)"), this);
// IPL Settings
QGroupBox* ipl_box = new QGroupBox(tr("IPL Settings"), this);
QVBoxLayout* ipl_box_layout = new QVBoxLayout(ipl_box);
@ -236,6 +239,7 @@ void GameCubePane::CreateWidgets()
layout->addWidget(ipl_box);
layout->addWidget(device_box);
layout->addWidget(m_empty_drive_is_closed);
#ifdef HAS_LIBMGBA
layout->addWidget(gba_box);
#endif
@ -247,6 +251,8 @@ void GameCubePane::CreateWidgets()
void GameCubePane::ConnectWidgets()
{
connect(m_empty_drive_is_closed, &QCheckBox::stateChanged, this, &GameCubePane::SaveSettings);
// IPL Settings
connect(m_skip_main_menu, &QCheckBox::stateChanged, this, &GameCubePane::SaveSettings);
connect(m_language_combo, qOverload<int>(&QComboBox::currentIndexChanged), this,
@ -701,6 +707,9 @@ void GameCubePane::BrowseGBASaves()
void GameCubePane::LoadSettings()
{
SignalBlocking(m_empty_drive_is_closed)
->setChecked(Config::Get(Config::MAIN_GC_EMPTY_DRIVE_IS_CLOSED));
// IPL Settings
SignalBlocking(m_skip_main_menu)->setChecked(Config::Get(Config::MAIN_SKIP_IPL));
SignalBlocking(m_language_combo)
@ -762,6 +771,9 @@ void GameCubePane::SaveSettings()
{
Config::ConfigChangeCallbackGuard config_guard;
Config::SetBaseOrCurrent(Config::MAIN_GC_EMPTY_DRIVE_IS_CLOSED,
m_empty_drive_is_closed->isChecked());
// IPL Settings
Config::SetBaseOrCurrent(Config::MAIN_SKIP_IPL, m_skip_main_menu->isChecked());
Config::SetBaseOrCurrent(Config::MAIN_GC_LANGUAGE, m_language_combo->currentData().toInt());

View File

@ -52,6 +52,7 @@ private:
void SaveRomPathChanged();
void BrowseGBASaves();
QCheckBox* m_empty_drive_is_closed;
QCheckBox* m_skip_main_menu;
QComboBox* m_language_combo;