From 4cd00e366cd66c1f6e9ab32e49712cc7957a7f17 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 5 Apr 2015 10:09:48 +0200 Subject: [PATCH] Get rid of VolumeHandler VolumeHandler is basically just a wrapper around a single IVolume object. This change moves that object to DVDInterface, moves the Read32 function to IVolume, and gets rid of the rest of VolumeHandler. --- Source/Core/Core/Boot/Boot.cpp | 56 ++++++------ Source/Core/Core/Boot/Boot_BS2Emu.cpp | 17 ++-- Source/Core/Core/CMakeLists.txt | 1 - Source/Core/Core/Core.cpp | 2 - Source/Core/Core/Core.vcxproj | 2 - Source/Core/Core/Core.vcxproj.filters | 2 - Source/Core/Core/HW/DVDInterface.cpp | 49 +++++++++-- Source/Core/Core/HW/DVDInterface.h | 9 ++ .../Core/IPC_HLE/WII_IPC_HLE_Device_DI.cpp | 5 +- .../Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp | 8 +- .../Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp | 1 - Source/Core/Core/VolumeHandler.cpp | 88 ------------------- Source/Core/Core/VolumeHandler.h | 34 ------- Source/Core/DiscIO/Volume.h | 6 ++ Source/Core/DiscIO/VolumeDirectory.cpp | 1 - 15 files changed, 98 insertions(+), 183 deletions(-) delete mode 100644 Source/Core/Core/VolumeHandler.cpp delete mode 100644 Source/Core/Core/VolumeHandler.h diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index de08097463..f89324e847 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -14,7 +14,6 @@ #include "Core/Core.h" #include "Core/Host.h" #include "Core/PatchEngine.h" -#include "Core/VolumeHandler.h" #include "Core/Boot/Boot.h" #include "Core/Boot/Boot_DOL.h" #include "Core/Debugger/Debugger_SymbolMap.h" @@ -35,9 +34,11 @@ void CBoot::Load_FST(bool _bIsWii) { - if (!VolumeHandler::IsValid()) + if (!DVDInterface::VolumeIsValid()) return; + const DiscIO::IVolume& volume = DVDInterface::GetVolume(); + // copy first 20 bytes of disc to start of Mem 1 DVDInterface::DVDRead(/*offset*/0, /*address*/0, /*length*/0x20, false); @@ -48,9 +49,9 @@ void CBoot::Load_FST(bool _bIsWii) if (_bIsWii) shift = 2; - u32 fstOffset = VolumeHandler::Read32(0x0424, _bIsWii) << shift; - u32 fstSize = VolumeHandler::Read32(0x0428, _bIsWii) << shift; - u32 maxFstSize = VolumeHandler::Read32(0x042c, _bIsWii) << shift; + u32 fstOffset = volume.Read32(0x0424, _bIsWii) << shift; + u32 fstSize = volume.Read32(0x0428, _bIsWii) << shift; + u32 maxFstSize = volume.Read32(0x042c, _bIsWii) << shift; u32 arenaHigh = ROUND_DOWN(0x817FFFFF - maxFstSize, 0x20); Memory::Write_U32(arenaHigh, 0x00000034); @@ -229,33 +230,30 @@ bool CBoot::BootUp() // GCM and Wii case SCoreStartupParameter::BOOT_ISO: { - std::unique_ptr pVolume(DiscIO::CreateVolumeFromFilename(_StartupPara.m_strFilename)); - if (pVolume == nullptr) + DVDInterface::SetVolumeName(_StartupPara.m_strFilename); + DVDInterface::SetDiscInside(DVDInterface::VolumeIsValid()); + if (!DVDInterface::VolumeIsValid()) break; - if (pVolume->IsWiiDisc() != _StartupPara.bWii) + const DiscIO::IVolume& pVolume = DVDInterface::GetVolume(); + + if (pVolume.IsWiiDisc() != _StartupPara.bWii) { PanicAlertT("Warning - starting ISO in wrong console mode!"); } - // setup the map from ISOFile ID - VolumeHandler::SetVolumeName(_StartupPara.m_strFilename); - - std::string unique_id = VolumeHandler::GetVolume()->GetUniqueID(); + std::string unique_id = DVDInterface::GetVolume().GetUniqueID(); if (unique_id.size() >= 4) VideoInterface::SetRegionReg(unique_id.at(3)); - DVDInterface::SetDiscInside(VolumeHandler::IsValid()); - u32 tmd_size; - std::unique_ptr tmd_buf = pVolume->GetTMD(&tmd_size); + std::unique_ptr tmd_buf = pVolume.GetTMD(&tmd_size); if (tmd_size) { WII_IPC_HLE_Interface::ES_DIVerify(tmd_buf.get(), tmd_size); } - - _StartupPara.bWii = VolumeHandler::IsWiiDisc(); + _StartupPara.bWii = pVolume.IsWiiDisc(); // HLE BS2 or not if (_StartupPara.bHLE_BS2) @@ -311,20 +309,20 @@ bool CBoot::BootUp() { BS2Success = EmulatedBS2(dolWii); } - else if (!VolumeHandler::IsWiiDisc() && !_StartupPara.m_strDefaultISO.empty()) + else if ((!DVDInterface::VolumeIsValid() || !DVDInterface::GetVolume().IsWiiDisc()) && !_StartupPara.m_strDefaultISO.empty()) { - VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultISO); + DVDInterface::SetVolumeName(_StartupPara.m_strDefaultISO); BS2Success = EmulatedBS2(dolWii); } if (!_StartupPara.m_strDVDRoot.empty()) { NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str()); - VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, dolWii, _StartupPara.m_strApploader, _StartupPara.m_strFilename); + DVDInterface::SetVolumeDirectory(_StartupPara.m_strDVDRoot, dolWii, _StartupPara.m_strApploader, _StartupPara.m_strFilename); BS2Success = EmulatedBS2(dolWii); } - DVDInterface::SetDiscInside(VolumeHandler::IsValid()); + DVDInterface::SetDiscInside(DVDInterface::VolumeIsValid()); if (!BS2Success) { @@ -364,19 +362,19 @@ bool CBoot::BootUp() if (!_StartupPara.m_strDVDRoot.empty()) { NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str()); - VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, _StartupPara.bWii); + DVDInterface::SetVolumeDirectory(_StartupPara.m_strDVDRoot, _StartupPara.bWii); } else if (!_StartupPara.m_strDefaultISO.empty()) { NOTICE_LOG(BOOT, "Loading default ISO %s", _StartupPara.m_strDefaultISO.c_str()); - VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultISO); + DVDInterface::SetVolumeName(_StartupPara.m_strDefaultISO); } else { - VolumeHandler::SetVolumeDirectory(_StartupPara.m_strFilename, _StartupPara.bWii); + DVDInterface::SetVolumeDirectory(_StartupPara.m_strFilename, _StartupPara.bWii); } - DVDInterface::SetDiscInside(VolumeHandler::IsValid()); + DVDInterface::SetDiscInside(DVDInterface::VolumeIsValid()); // Poor man's bootup if(_StartupPara.bWii) @@ -402,18 +400,18 @@ bool CBoot::BootUp() // load default image or create virtual drive from directory if (!_StartupPara.m_strDVDRoot.empty()) - VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, true); + DVDInterface::SetVolumeDirectory(_StartupPara.m_strDVDRoot, true); else if (!_StartupPara.m_strDefaultISO.empty()) - VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultISO); + DVDInterface::SetVolumeName(_StartupPara.m_strDefaultISO); - DVDInterface::SetDiscInside(VolumeHandler::IsValid()); + DVDInterface::SetDiscInside(DVDInterface::VolumeIsValid()); break; // Bootstrap 2 (AKA: Initial Program Loader, "BIOS") case SCoreStartupParameter::BOOT_BS2: { - DVDInterface::SetDiscInside(VolumeHandler::IsValid()); + DVDInterface::SetDiscInside(DVDInterface::VolumeIsValid()); if (Load_BS2(_StartupPara.m_strBootROM)) { if (LoadMapFromFilename()) diff --git a/Source/Core/Core/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Boot/Boot_BS2Emu.cpp index 56f07e720b..01e7be90a7 100644 --- a/Source/Core/Core/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Boot/Boot_BS2Emu.cpp @@ -12,7 +12,6 @@ #include "Core/Core.h" #include "Core/MemTools.h" #include "Core/PatchEngine.h" -#include "Core/VolumeHandler.h" #include "Core/Boot/Boot.h" #include "Core/HLE/HLE.h" #include "Core/HW/CPU.h" @@ -84,9 +83,10 @@ bool CBoot::EmulatedBS2_GC(bool skipAppLoader) // Load Apploader to Memory - The apploader is hardcoded to begin at 0x2440 on the disc, // but the size can differ between discs. Compare with YAGCD chap 13. + const DiscIO::IVolume& volume = DVDInterface::GetVolume(); u32 iAppLoaderOffset = 0x2440; - u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10, false); - u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14, false) + VolumeHandler::Read32(iAppLoaderOffset + 0x18, false); + u32 iAppLoaderEntry = volume.Read32(iAppLoaderOffset + 0x10, false); + u32 iAppLoaderSize = volume.Read32(iAppLoaderOffset + 0x14, false) + volume.Read32(iAppLoaderOffset + 0x18, false); if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1) || skipAppLoader) { INFO_LOG(BOOT, "GC BS2: Not running apploader!"); @@ -308,8 +308,8 @@ bool CBoot::EmulatedBS2_Wii() // setup Wii memory DiscIO::IVolume::ECountry country_code = DiscIO::IVolume::COUNTRY_UNKNOWN; - if (VolumeHandler::IsValid()) - country_code = VolumeHandler::GetVolume()->GetCountry(); + if (DVDInterface::VolumeIsValid()) + country_code = DVDInterface::GetVolume().GetCountry(); if (SetupWiiMemory(country_code) == false) return false; @@ -321,7 +321,7 @@ bool CBoot::EmulatedBS2_Wii() // Execute the apploader bool apploaderRan = false; - if (VolumeHandler::IsValid() && VolumeHandler::IsWiiDisc()) + if (DVDInterface::VolumeIsValid() && DVDInterface::GetVolume().IsWiiDisc()) { // Set up MSR and the BAT SPR registers. UReg_MSR& m_MSR = ((UReg_MSR&)PowerPC::ppcState.msr); @@ -353,8 +353,9 @@ bool CBoot::EmulatedBS2_Wii() u32 iAppLoaderOffset = 0x2440; // 0x1c40; // Load Apploader to Memory - u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10, true); - u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14, true); + const DiscIO::IVolume& volume = DVDInterface::GetVolume(); + u32 iAppLoaderEntry = volume.Read32(iAppLoaderOffset + 0x10, true); + u32 iAppLoaderSize = volume.Read32(iAppLoaderOffset + 0x14, true); if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1)) { ERROR_LOG(BOOT, "Invalid apploader. Probably your image is corrupted."); diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index e98dbed7b7..94a8e3380a 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -16,7 +16,6 @@ set(SRCS ActionReplay.cpp NetPlayServer.cpp PatchEngine.cpp State.cpp - VolumeHandler.cpp Boot/Boot_BS2Emu.cpp Boot/Boot.cpp Boot/Boot_DOL.cpp diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 113ac0e553..e6a1e29a3a 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -31,7 +31,6 @@ #include "Core/NetPlayProto.h" #include "Core/PatchEngine.h" #include "Core/State.h" -#include "Core/VolumeHandler.h" #include "Core/Boot/Boot.h" #include "Core/FifoPlayer/FifoPlayer.h" @@ -542,7 +541,6 @@ void EmuThread() if (core_parameter.bCPUThread) g_video_backend->Video_Cleanup(); - VolumeHandler::EjectVolume(); FileMon::Close(); // Stop audio thread - Actually this does nothing when using HLE diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index bf021338fc..3b51bee474 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -253,7 +253,6 @@ - @@ -437,7 +436,6 @@ - diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index cb07bc9ee2..142fc63b7c 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -154,7 +154,6 @@ - ActionReplay @@ -751,7 +750,6 @@ - ActionReplay diff --git a/Source/Core/Core/HW/DVDInterface.cpp b/Source/Core/Core/HW/DVDInterface.cpp index 278c1d1ee5..9060e7911b 100644 --- a/Source/Core/Core/HW/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVDInterface.cpp @@ -4,6 +4,8 @@ #include #include +#include +#include #include "AudioCommon/AudioCommon.h" @@ -12,7 +14,6 @@ #include "Core/ConfigManager.h" #include "Core/CoreTiming.h" #include "Core/Movie.h" -#include "Core/VolumeHandler.h" #include "Core/HW/AudioInterface.h" #include "Core/HW/DVDInterface.h" #include "Core/HW/Memmap.h" @@ -22,6 +23,9 @@ #include "Core/HW/SystemTimers.h" #include "Core/PowerPC/PowerPC.h" +#include "DiscIO/Volume.h" +#include "DiscIO/VolumeCreator.h" + static const double PI = 3.14159265358979323846264338328; // Rate the drive can transfer data to main memory, given the data @@ -229,6 +233,7 @@ struct DVDReadCommand int callback_event_type; }; +static std::unique_ptr s_inserted_volume; // STATE_TO_SAVE // hardware registers @@ -373,7 +378,7 @@ static u32 ProcessDTKSamples(short *tempPCM, u32 num_samples) u8 tempADPCM[NGCADPCM::ONE_BLOCK_SIZE]; // TODO: What if we can't read from AudioPos? - VolumeHandler::ReadToPtr(tempADPCM, AudioPos, sizeof(tempADPCM), false); + s_inserted_volume->Read(AudioPos, sizeof(tempADPCM), tempADPCM, false); AudioPos += sizeof(tempADPCM); NGCADPCM::DecodeBlock(tempPCM + samples_processed * 2, tempADPCM); samples_processed += NGCADPCM::SAMPLES_PER_BLOCK; @@ -449,6 +454,29 @@ void Init() void Shutdown() { + s_inserted_volume.reset(); +} + +const DiscIO::IVolume& GetVolume() +{ + return *s_inserted_volume; +} + +bool SetVolumeName(const std::string& disc_path) +{ + s_inserted_volume = std::unique_ptr(DiscIO::CreateVolumeFromFilename(disc_path)); + return VolumeIsValid(); +} + +bool SetVolumeDirectory(const std::string& full_path, bool is_wii, const std::string& apploader_path, const std::string& DOL_path) +{ + s_inserted_volume = std::unique_ptr(DiscIO::CreateVolumeFromDirectory(full_path, is_wii, apploader_path, DOL_path)); + return VolumeIsValid(); +} + +bool VolumeIsValid() +{ + return s_inserted_volume != nullptr; } void SetDiscInside(bool _DiscInside) @@ -472,7 +500,7 @@ void EjectDiscCallback(u64 userdata, int cyclesLate) { // Empty the drive SetDiscInside(false); - VolumeHandler::EjectVolume(); + s_inserted_volume.reset(); } void InsertDiscCallback(u64 userdata, int cyclesLate) @@ -480,13 +508,13 @@ void InsertDiscCallback(u64 userdata, int cyclesLate) std::string& SavedFileName = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strFilename; std::string *_FileName = (std::string *)userdata; - if (!VolumeHandler::SetVolumeName(*_FileName)) + if (!SetVolumeName(*_FileName)) { // Put back the old one - VolumeHandler::SetVolumeName(SavedFileName); + SetVolumeName(SavedFileName); PanicAlertT("Invalid file"); } - SetDiscInside(VolumeHandler::IsValid()); + SetDiscInside(VolumeIsValid()); delete _FileName; } @@ -518,7 +546,12 @@ void SetLidOpen(bool _bOpen) bool DVDRead(u64 _iDVDOffset, u32 _iRamAddress, u32 _iLength, bool decrypt) { - return VolumeHandler::ReadToPtr(Memory::GetPointer(_iRamAddress), _iDVDOffset, _iLength, decrypt); + return s_inserted_volume->Read(_iDVDOffset, _iLength, Memory::GetPointer(_iRamAddress), decrypt); +} + +bool ChangePartition(u64 offset) +{ + return s_inserted_volume->ChangePartition(offset); } void RegisterMMIO(MMIO::Mapping* mmio, u32 base) @@ -1398,7 +1431,7 @@ s64 CalculateRawDiscReadTime(u64 offset, s64 length) // Note that the speed at a track (in bytes per second) is the same as // the radius of that track because of the length unit used. double speed; - if (VolumeHandler::IsWiiDisc()) + if (s_inserted_volume->IsWiiDisc()) { speed = std::sqrt(((average_offset - WII_DISC_LOCATION_1_OFFSET) / WII_BYTES_PER_AREA_UNIT + WII_DISC_AREA_UP_TO_LOCATION_1) / PI); diff --git a/Source/Core/Core/HW/DVDInterface.h b/Source/Core/Core/HW/DVDInterface.h index 3f9337a9e6..f246f583d2 100644 --- a/Source/Core/Core/HW/DVDInterface.h +++ b/Source/Core/Core/HW/DVDInterface.h @@ -5,7 +5,9 @@ #pragma once #include + #include "Common/CommonTypes.h" +#include "DiscIO/Volume.h" class PointerWrap; namespace MMIO { class Mapping; } @@ -91,6 +93,12 @@ void DoState(PointerWrap &p); void RegisterMMIO(MMIO::Mapping* mmio, u32 base); +// Direct disc access +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(); @@ -99,6 +107,7 @@ void ChangeDisc(const std::string& fileName); // DVD Access Functions bool DVDRead(u64 _iDVDOffset, u32 _iRamAddress, u32 _iLength, bool decrypt); extern bool g_bStream; +bool ChangePartition(u64 offset); void ExecuteCommand(u32 command_0, u32 command_1, u32 command_2, u32 output_address, u32 output_length, bool write_to_DIIMMBUF, int callback_event_type); diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.cpp index 07a22b79a2..4ce39ee2ce 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.cpp @@ -10,7 +10,6 @@ #include "Core/ConfigManager.h" #include "Core/CoreTiming.h" -#include "Core/VolumeHandler.h" #include "Core/HW/DVDInterface.h" #include "Core/HW/Memmap.h" #include "Core/HW/SystemTimers.h" @@ -162,13 +161,13 @@ IPCCommandResult CWII_IPC_HLE_Device_di::IOCtlV(u32 _CommandAddress) _dbg_assert_msg_(WII_IPC_DVD, CommandBuffer.InBuffer[2].m_Address == 0, "DVDLowOpenPartition with cert chain"); u64 const partition_offset = ((u64)Memory::Read_U32(CommandBuffer.InBuffer[0].m_Address + 4) << 2); - VolumeHandler::GetVolume()->ChangePartition(partition_offset); + DVDInterface::ChangePartition(partition_offset); INFO_LOG(WII_IPC_DVD, "DVDLowOpenPartition: partition_offset 0x%016" PRIx64, partition_offset); // Read TMD to the buffer u32 tmd_size; - std::unique_ptr tmd_buf = VolumeHandler::GetVolume()->GetTMD(&tmd_size); + std::unique_ptr tmd_buf = DVDInterface::GetVolume().GetTMD(&tmd_size); Memory::CopyToEmu(CommandBuffer.PayloadBuffer[0].m_Address, tmd_buf.get(), tmd_size); WII_IPC_HLE_Interface::ES_DIVerify(tmd_buf.get(), tmd_size); diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp index 7c53f8fafd..e827a2a308 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -48,8 +48,8 @@ #include "Core/ConfigManager.h" #include "Core/ec_wii.h" #include "Core/Movie.h" -#include "Core/VolumeHandler.h" #include "Core/Boot/Boot_DOL.h" +#include "Core/HW/DVDInterface.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device_es.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device_usb.h" #include "Core/PowerPC/PowerPC.h" @@ -110,11 +110,11 @@ void CWII_IPC_HLE_Device_es::OpenInternal() // m_TitleIDsOwned.clear(); // DiscIO::cUIDsys::AccessInstance().GetTitleIDs(m_TitleIDsOwned, true); } - else if (VolumeHandler::IsValid()) + else if (DVDInterface::VolumeIsValid()) { // blindly grab the titleID from the disc - it's unencrypted at: // offset 0x0F8001DC and 0x0F80044C - VolumeHandler::GetVolume()->GetTitleID((u8*)&m_TitleID); + DVDInterface::GetVolume().GetTitleID((u8*)&m_TitleID); m_TitleID = Common::swap64(m_TitleID); } else @@ -1093,7 +1093,7 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz) { u64 titleID = 0xDEADBEEFDEADBEEFull; u64 tmdTitleID = Common::swap64(*(u64*)(_pTMD+0x18c)); - VolumeHandler::GetVolume()->GetTitleID((u8*)&titleID); + DVDInterface::GetVolume().GetTitleID((u8*)&titleID); if (Common::swap64(titleID) != tmdTitleID) { return -1; diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp index 260bac9f43..f9c4dccf98 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp @@ -10,7 +10,6 @@ #include "Common/NandPaths.h" #include "Common/StringUtil.h" -#include "Core/VolumeHandler.h" #include "Core/HW/SystemTimers.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device_fs.h" diff --git a/Source/Core/Core/VolumeHandler.cpp b/Source/Core/Core/VolumeHandler.cpp deleted file mode 100644 index e46f14f70f..0000000000 --- a/Source/Core/Core/VolumeHandler.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#include "Common/CommonFuncs.h" -#include "Core/VolumeHandler.h" -#include "DiscIO/VolumeCreator.h" - -namespace VolumeHandler -{ - -static DiscIO::IVolume* g_pVolume = nullptr; - -DiscIO::IVolume *GetVolume() -{ - return g_pVolume; -} - -void EjectVolume() -{ - if (g_pVolume) - { - // This code looks scary. Can the try/catch stuff be removed? - // This cause a "Unhandled exception ... Access violation - // reading location ..." after you have started and stopped two - // or three games - delete g_pVolume; - g_pVolume = nullptr; - } -} - -bool SetVolumeName(const std::string& _rFullPath) -{ - if (g_pVolume) - { - delete g_pVolume; - g_pVolume = nullptr; - } - - g_pVolume = DiscIO::CreateVolumeFromFilename(_rFullPath); - - return (g_pVolume != nullptr); -} - -void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii, const std::string& _rApploader, const std::string& _rDOL) -{ - if (g_pVolume) - { - delete g_pVolume; - g_pVolume = nullptr; - } - - g_pVolume = DiscIO::CreateVolumeFromDirectory(_rFullPath, _bIsWii, _rApploader, _rDOL); -} - -u32 Read32(u64 _Offset, bool decrypt) -{ - if (g_pVolume != nullptr) - { - u32 Temp; - g_pVolume->Read(_Offset, 4, (u8*)&Temp, decrypt); - return Common::swap32(Temp); - } - return 0; -} - -bool ReadToPtr(u8* ptr, u64 _dwOffset, u64 _dwLength, bool decrypt) -{ - if (g_pVolume != nullptr && ptr) - return g_pVolume->Read(_dwOffset, _dwLength, ptr, decrypt); - - return false; -} - -bool IsValid() -{ - return (g_pVolume != nullptr); -} - -bool IsWiiDisc() -{ - if (g_pVolume) - return g_pVolume->IsWiiDisc(); - - return false; -} - -} // end of namespace VolumeHandler diff --git a/Source/Core/Core/VolumeHandler.h b/Source/Core/Core/VolumeHandler.h deleted file mode 100644 index b8446c40a7..0000000000 --- a/Source/Core/Core/VolumeHandler.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - - -// Disc volume handler. It's here because Wii discs can consist of multiple volumes. -// GC discs are seen as one big volume. - -#pragma once - -#include - -#include "Common/CommonTypes.h" -#include "DiscIO/Volume.h" - -namespace VolumeHandler -{ - -bool SetVolumeName(const std::string& _rFullPath); -void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii, const std::string& _rApploader = "", const std::string& _rDOL = ""); - -// decrypt parameter must be false if not reading a Wii disc -u32 Read32(u64 _Offset, bool decrypt); -// decrypt parameter must be false if not reading a Wii disc -bool ReadToPtr(u8* ptr, u64 _dwOffset, u64 _dwLength, bool decrypt); - -bool IsValid(); -bool IsWiiDisc(); - -DiscIO::IVolume *GetVolume(); - -void EjectVolume(); - -} // end of namespace VolumeHandler diff --git a/Source/Core/DiscIO/Volume.h b/Source/Core/DiscIO/Volume.h index 01a45b294a..ad3654f0c3 100644 --- a/Source/Core/DiscIO/Volume.h +++ b/Source/Core/DiscIO/Volume.h @@ -20,6 +20,12 @@ public: // decrypt parameter must be false if not reading a Wii disc virtual bool Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const = 0; + virtual u32 Read32(u64 _Offset, bool decrypt) const + { + u32 temp; + Read(_Offset, sizeof(u32), (u8*)&temp, decrypt); + return Common::swap32(temp); + } virtual bool GetTitleID(u8*) const { return false; } virtual std::unique_ptr GetTMD(u32 *_sz) const diff --git a/Source/Core/DiscIO/VolumeDirectory.cpp b/Source/Core/DiscIO/VolumeDirectory.cpp index e970d27836..6f3e4ccb7f 100644 --- a/Source/Core/DiscIO/VolumeDirectory.cpp +++ b/Source/Core/DiscIO/VolumeDirectory.cpp @@ -15,7 +15,6 @@ #include "Common/CommonTypes.h" #include "Common/FileUtil.h" #include "Common/MathUtil.h" -#include "Core/VolumeHandler.h" #include "DiscIO/FileBlob.h" #include "DiscIO/FileMonitor.h" #include "DiscIO/Volume.h"