diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp index 8e9dd2c85c..0797c8f4e0 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp @@ -98,10 +98,28 @@ bool CWII_IPC_HLE_Device_di::IOCtl(u32 _CommandAddress) bool CWII_IPC_HLE_Device_di::IOCtlV(u32 _CommandAddress) { - PanicAlert("CWII_IPC_HLE_Device_di::IOCtlV() unknown"); +// PanicAlert("CWII_IPC_HLE_Device_di::IOCtlV() unknown"); +// DumpCommands(_CommandAddress); + u32 ReturnValue = 0; - DumpCommands(_CommandAddress); + SIOCtlVBuffer CommandBuffer(_CommandAddress); + switch (CommandBuffer.Parameter) + { + // DVDLowOpenPartition??? + case 0x8b: + { + LOG(WII_IPC_DVD, "DVD IOCtlV: DVDLowOpenPartition"); + _dbg_assert_msg_(WII_IPC_DVD, 0, "DVD IOCtlV: DVDLowOpenPartition"); + } + break; + default: + LOG(WII_IPC_DVD, "DVD IOCtlV: %i", CommandBuffer.Parameter); + _dbg_assert_msg_(WII_IPC_DVD, 0, "DVD: %i", CommandBuffer.Parameter); + break; + } + + Memory::Write_U32(ReturnValue, _CommandAddress+4); return true; } @@ -278,15 +296,35 @@ u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32 case 0x8c: //PanicAlert("DVDLowClosePartition"); break; - + // DVDLowUnencryptedRead case 0x8d: - PanicAlert("DVDLowUnencryptedRead"); + //PanicAlert("DVDLowUnencryptedRead"); + { + if (_BufferOut == 0) + { + PanicAlert("DVDLowRead : _BufferOut == 0"); + return 0; + } + u32 Size = Memory::Read_U32(_BufferIn + 0x04); + u64 DVDAddress = (u64)Memory::Read_U32(_BufferIn + 0x08) << 2; + + if (Size > _BufferOutSize) + { + PanicAlert("Detected attempt to read more data from the DVD than fit inside the out buffer. Clamp."); + Size = _BufferOutSize; + } + + if (VolumeHandler::RAWReadToPtr(Memory::GetPointer(_BufferOut), DVDAddress, Size) != true) + { + PanicAlert("Cant read from DVD_Plugin - DVD-Interface: Fatal Error"); + } + } break; // DVDLowSeek case 0xab: - // PanicAlert("DVDLowSeek"); + //PanicAlert("DVDLowSeek"); break; case 0xe0: diff --git a/Source/Core/Core/Src/VolumeHandler.cpp b/Source/Core/Core/Src/VolumeHandler.cpp index 35b9587dae..18d7bb1eb3 100644 --- a/Source/Core/Core/Src/VolumeHandler.cpp +++ b/Source/Core/Core/Src/VolumeHandler.cpp @@ -77,6 +77,17 @@ bool ReadToPtr(u8* ptr, u64 _dwOffset, u64 _dwLength) return false; } +bool RAWReadToPtr( u8* ptr, u64 _dwOffset, u64 _dwLength ) +{ + if (g_pVolume != NULL && ptr) + { + g_pVolume->RAWRead(_dwOffset, _dwLength, ptr); + return true; + } + + return false; +} + bool IsValid() { return g_pVolume != NULL; diff --git a/Source/Core/Core/Src/VolumeHandler.h b/Source/Core/Core/Src/VolumeHandler.h index 0428b3e835..815b1af100 100644 --- a/Source/Core/Core/Src/VolumeHandler.h +++ b/Source/Core/Core/Src/VolumeHandler.h @@ -33,6 +33,7 @@ void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii); u32 Read32(u64 _Offset); bool ReadToPtr(u8* ptr, u64 _dwOffset, u64 _dwLength); +bool RAWReadToPtr(u8* ptr, u64 _dwOffset, u64 _dwLength); bool IsValid(); bool IsWii(); diff --git a/Source/Core/DiscIO/Src/Volume.h b/Source/Core/DiscIO/Src/Volume.h index 8d2f4f9f05..d915f1f0a6 100644 --- a/Source/Core/DiscIO/Src/Volume.h +++ b/Source/Core/DiscIO/Src/Volume.h @@ -38,6 +38,7 @@ class IVolume virtual bool Read(u64 _Offset, u64 _Length, u8* _pBuffer) const = 0; + virtual bool RAWRead(u64 _Offset, u64 _Length, u8* _pBuffer) const = 0; virtual std::string GetUniqueID() const = 0; virtual std::string GetMakerID() const = 0; virtual std::string GetName() const = 0; diff --git a/Source/Core/DiscIO/Src/VolumeDirectory.cpp b/Source/Core/DiscIO/Src/VolumeDirectory.cpp index 37fe0b8f4d..4619650b86 100644 --- a/Source/Core/DiscIO/Src/VolumeDirectory.cpp +++ b/Source/Core/DiscIO/Src/VolumeDirectory.cpp @@ -69,6 +69,11 @@ bool CVolumeDirectory::IsValidDirectory(const std::string& _rDirectory) return File::IsDirectory(directoryName.c_str()); } +bool CVolumeDirectory::RAWRead( u64 _Offset, u64 _Length, u8* _pBuffer ) const +{ + return false; +} + bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const { if(_Offset < FST_ADDRESS) diff --git a/Source/Core/DiscIO/Src/VolumeDirectory.h b/Source/Core/DiscIO/Src/VolumeDirectory.h index 1cc0931031..6f8d827d0d 100644 --- a/Source/Core/DiscIO/Src/VolumeDirectory.h +++ b/Source/Core/DiscIO/Src/VolumeDirectory.h @@ -42,6 +42,7 @@ class CVolumeDirectory static bool IsValidDirectory(const std::string& _rDirectory); bool Read(u64 _Offset, u64 _Length, u8* _pBuffer) const; + bool RAWRead(u64 _Offset, u64 _Length, u8* _pBuffer) const; std::string GetUniqueID() const; void SetUniqueID(std::string _ID); diff --git a/Source/Core/DiscIO/Src/VolumeGC.cpp b/Source/Core/DiscIO/Src/VolumeGC.cpp index 5d5a80ebd4..93ff459b52 100644 --- a/Source/Core/DiscIO/Src/VolumeGC.cpp +++ b/Source/Core/DiscIO/Src/VolumeGC.cpp @@ -55,6 +55,11 @@ bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const return m_pReader->Read(_Offset, _Length, _pBuffer); } +bool CVolumeGC::RAWRead( u64 _Offset, u64 _Length, u8* _pBuffer ) const +{ + return false; +} + std::string CVolumeGC::GetUniqueID() const { static const std::string NO_UID("NO_UID"); diff --git a/Source/Core/DiscIO/Src/VolumeGC.h b/Source/Core/DiscIO/Src/VolumeGC.h index 33452c39f7..941ceb64ee 100644 --- a/Source/Core/DiscIO/Src/VolumeGC.h +++ b/Source/Core/DiscIO/Src/VolumeGC.h @@ -30,6 +30,7 @@ public: CVolumeGC(IBlobReader* _pReader); ~CVolumeGC(); bool Read(u64 _Offset, u64 _Length, u8* _pBuffer) const; + bool RAWRead(u64 _Offset, u64 _Length, u8* _pBuffer) const; std::string GetUniqueID() const; std::string GetMakerID() const; std::string GetName() const; diff --git a/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp b/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp index 662f3f7f02..dfbf49f0d2 100644 --- a/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp +++ b/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp @@ -41,6 +41,17 @@ CVolumeWiiCrypted::~CVolumeWiiCrypted() m_pBuffer = NULL; } +bool CVolumeWiiCrypted::RAWRead( u64 _Offset, u64 _Length, u8* _pBuffer ) const +{ + // HyperIris: hack for DVDLowUnencryptedRead + // Medal Of Honor Heroes 2 read this DVD offset for PartitionsInfo + // and, PartitionsInfo is not encrypted, let's read it directly. + if (!m_pReader->Read(_Offset, _Length, _pBuffer)) + { + return(false); + } + return true; +} bool CVolumeWiiCrypted::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer) const @@ -255,4 +266,6 @@ CVolumeWiiCrypted::GetSize() const return(0); } } + + } // namespace diff --git a/Source/Core/DiscIO/Src/VolumeWiiCrypted.h b/Source/Core/DiscIO/Src/VolumeWiiCrypted.h index 696d609114..64435ba2cc 100644 --- a/Source/Core/DiscIO/Src/VolumeWiiCrypted.h +++ b/Source/Core/DiscIO/Src/VolumeWiiCrypted.h @@ -32,6 +32,7 @@ public: CVolumeWiiCrypted(IBlobReader* _pReader, u64 _VolumeOffset, const unsigned char* _pVolumeKey); ~CVolumeWiiCrypted(); bool Read(u64 _Offset, u64 _Length, u8* _pBuffer) const; + bool RAWRead(u64 _Offset, u64 _Length, u8* _pBuffer) const; std::string GetUniqueID() const; std::string GetMakerID() const; std::string GetName() const;