From 0abf875a3f05719412b0adfe2691d40e9dcd1c63 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 30 Jan 2016 18:35:19 +0100 Subject: [PATCH] DVDInterface: Call SetDiscInside when setting volume SetDiscInside is an implementation detail that callers shouldn't have to call on their own. --- Source/Core/Core/Boot/Boot.cpp | 7 ------- Source/Core/Core/HW/DVDInterface.cpp | 8 ++++++-- Source/Core/Core/HW/DVDInterface.h | 10 +++++----- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index 6e0ffebba6..f7dd454484 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -267,7 +267,6 @@ bool CBoot::BootUp() case SConfig::BOOT_ISO: { DVDInterface::SetVolumeName(_StartupPara.m_strFilename); - DVDInterface::SetDiscInside(DVDInterface::VolumeIsValid()); if (!DVDInterface::VolumeIsValid()) return false; @@ -353,8 +352,6 @@ bool CBoot::BootUp() BS2Success = EmulatedBS2(dolWii); } - DVDInterface::SetDiscInside(DVDInterface::VolumeIsValid()); - if (!BS2Success) { // Set up MSR and the BAT SPR registers. @@ -414,8 +411,6 @@ bool CBoot::BootUp() DVDInterface::SetVolumeDirectory(_StartupPara.m_strFilename, _StartupPara.bWii); } - DVDInterface::SetDiscInside(DVDInterface::VolumeIsValid()); - // Poor man's bootup if (_StartupPara.bWii) { @@ -450,13 +445,11 @@ bool CBoot::BootUp() else if (!_StartupPara.m_strDefaultISO.empty()) DVDInterface::SetVolumeName(_StartupPara.m_strDefaultISO); - DVDInterface::SetDiscInside(DVDInterface::VolumeIsValid()); break; // Bootstrap 2 (AKA: Initial Program Loader, "BIOS") case SConfig::BOOT_BS2: { - DVDInterface::SetDiscInside(DVDInterface::VolumeIsValid()); if (Load_BS2(_StartupPara.m_strBootROM)) { if (LoadMapFromFilename()) diff --git a/Source/Core/Core/HW/DVDInterface.cpp b/Source/Core/Core/HW/DVDInterface.cpp index bcf3bba2ac..c333627b8a 100644 --- a/Source/Core/Core/HW/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVDInterface.cpp @@ -264,7 +264,8 @@ static void EjectDiscCallback(u64 userdata, s64 cyclesLate); static void InsertDiscCallback(u64 userdata, s64 cyclesLate); static void FinishExecutingCommandCallback(u64 userdata, s64 cycles_late); -void SetLidOpen(bool _bOpen); +void SetDiscInside(bool disc_inside); +void SetLidOpen(bool open); void UpdateInterrupts(); void GenerateDIInterrupt(DIInterruptType _DVDInterrupt); @@ -418,6 +419,8 @@ static void DTKStreamingCallback(const std::vector& audio_data, s64 cycles_l void Init() { + _assert_(!VolumeIsValid()); + DVDThread::Start(); Reset(); @@ -483,6 +486,7 @@ bool SetVolumeName(const std::string& disc_path) { DVDThread::WaitUntilIdle(); s_inserted_volume = DiscIO::CreateVolumeFromFilename(disc_path); + SetDiscInside(VolumeIsValid()); return VolumeIsValid(); } @@ -492,6 +496,7 @@ bool SetVolumeDirectory(const std::string& full_path, bool is_wii, DVDThread::WaitUntilIdle(); s_inserted_volume = DiscIO::CreateVolumeFromDirectory(full_path, is_wii, apploader_path, DOL_path); + SetDiscInside(VolumeIsValid()); return VolumeIsValid(); } @@ -534,7 +539,6 @@ static void InsertDiscCallback(u64 userdata, s64 cyclesLate) SetVolumeName(old_path); PanicAlertT("The disc that was about to be inserted couldn't be found."); } - SetDiscInside(VolumeIsValid()); s_disc_path_to_insert.clear(); } diff --git a/Source/Core/Core/HW/DVDInterface.h b/Source/Core/Core/HW/DVDInterface.h index 410aee8f3e..fb6c97aea5 100644 --- a/Source/Core/Core/HW/DVDInterface.h +++ b/Source/Core/Core/HW/DVDInterface.h @@ -108,23 +108,23 @@ void DoState(PointerWrap& p); void RegisterMMIO(MMIO::Mapping* mmio, u32 base); -// Direct disc access +// Disc access (don't call GetVolume unless you know that VolumeIsValid() == true) const DiscIO::IVolume& GetVolume(); bool SetVolumeName(const std::string& disc_path); bool SetVolumeDirectory(const std::string& disc_path, bool is_wii, const std::string& apploader_path = "", const std::string& DOL_path = ""); bool VolumeIsValid(); - -// Disc detection and swapping -void SetDiscInside(bool _DiscInside); bool IsDiscInside(); void ChangeDiscAsHost(const std::string& new_path); // Can only be called by the host thread void ChangeDiscAsCPU(const std::string& new_path); // Can only be called by the CPU thread -// DVD Access Functions +// Direct access to DI for IOS HLE (simpler to implement than how real IOS accesses DI, +// and lets us skip encrypting/decrypting in some cases) bool ChangePartition(u64 offset); void ExecuteCommand(u32 command_0, u32 command_1, u32 command_2, u32 output_address, u32 output_length, bool reply_to_ios); + +// Used by DVDThread void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type, s64 cycles_late, const std::vector& data = std::vector());