diff options
| author | skidau <skidau@gmail.com> | 2013-03-27 13:19:23 +1100 |
|---|---|---|
| committer | skidau <skidau@gmail.com> | 2013-03-27 13:19:23 +1100 |
| commit | 7784fa4c67cc8d2545f45694d83805e7e89cd583 (patch) | |
| tree | 7724133aabe971ec417d1dea0977a525bb8debfb /Source/Core/DiscIO/Src/CISOBlob.cpp | |
| parent | d33c19b0cd2bae982c8d35e86a9d3551f9e5c72f (diff) | |
| parent | 5cea0d9defeaa23e7af94adf7615a44fb2c9c173 (diff) | |
Merge branch 'master' into wii-network
# By Ryan Houdek (185) and others
# Via degasus (12) and others
* master: (625 commits)
Revert "Don't open/close file for every file operation." as it was crashing PokePark in Windows builds.
Array overrun fixed in VertexShaderCache for the DX11 plugin.
Fixed DSPTool build.
Windows build fix
Go back to assuming every HID device is a wiimote on Windows. Fixed issue 6117. Unfixed issue 6031.
VideoSoftware: Improve fog range adjustment by using less magic and more comments.
revert RasterFont for VideoSoftware
ogl: fix virtual xfb
Windows build fix from web interface...
Adjusted the audio loop criteria, using >= on the Wii and == on GC. This fixes the audio static that occurred in Wii games after hours of play.
Forced the exception check only for ARAM DMA transfers. Removed the Eternal Darkness boot hack and replaced it with an exception check.
VideoSoftware: Implement fog range adjustment, fixing issue 6147.
implement 4xSSAA for OGL
move ogl-only settings into backend
Fix description of disable fog, and move it to enhancements tab.
Reverted rd76ca5783743 as it was made obsolete by r1d550f4496e4.
Removed the tracking of the FIFO Writes as it was made obsolete by r1d550f4496e4.
Forced the external exception check to occur sooner by changing the downcount.
Mark the Direct3D9 backend deprecated.
Prefer D3D11 and OpenGL over D3D9 by default.
...
Conflicts:
CMakeLists.txt
Source/Core/Common/Common.vcxproj.filters
Source/Core/Common/Src/CommonPaths.h
Source/Core/Core/Core.vcxproj.filters
Source/Core/Core/Src/Core.cpp
Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp
Source/VSProps/Dolphin.Win32.props
Source/VSProps/Dolphin.x64.props
Diffstat (limited to 'Source/Core/DiscIO/Src/CISOBlob.cpp')
| -rw-r--r-- | Source/Core/DiscIO/Src/CISOBlob.cpp | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/Source/Core/DiscIO/Src/CISOBlob.cpp b/Source/Core/DiscIO/Src/CISOBlob.cpp index b3a2e31b2b..8d267c15fb 100644 --- a/Source/Core/DiscIO/Src/CISOBlob.cpp +++ b/Source/Core/DiscIO/Src/CISOBlob.cpp @@ -15,24 +15,30 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ +#include <algorithm> +#include <cmath> + #include "Blob.h" #include "CISOBlob.h" namespace DiscIO { +static const char CISO_MAGIC[] = "CISO"; + CISOFileReader::CISOFileReader(std::FILE* file) : m_file(file) { m_size = m_file.GetSize(); - - memset(&header, 0, sizeof(header)); + + CISOHeader header; m_file.ReadArray(&header, 1); + + m_block_size = header.block_size; - CISO_Map_t count = 0; - int idx; - for (idx = 0; idx < CISO_MAP_SIZE; idx++) - ciso_map[idx] = (header.map[idx] == 1) ? count++ : CISO_UNUSED_BLOCK; + MapType count = 0; + for (u32 idx = 0; idx < CISO_MAP_SIZE; idx++) + m_ciso_map[idx] = (1 == header.map[idx]) ? count++ : UNUSED_BLOCK_ID; } CISOFileReader* CISOFileReader::Create(const char* filename) @@ -46,34 +52,45 @@ CISOFileReader* CISOFileReader::Create(const char* filename) return NULL; } +u64 CISOFileReader::GetDataSize() const +{ + return GetRawSize(); +} + +u64 CISOFileReader::GetRawSize() const +{ + return m_size; +} + bool CISOFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr) { - u64 bytesRead = 0; - while (bytesRead < nbytes) + while (nbytes != 0) { - u32 block = (u32)(offset / header.block_size); - u32 data_offset = offset % header.block_size; - u32 bytes_to_read = (u32)min((u64)(header.block_size - data_offset), nbytes); - if ((block >= CISO_MAP_SIZE) || (ciso_map[block] == CISO_UNUSED_BLOCK)) + auto const block = offset / m_block_size; + auto const data_offset = offset % m_block_size; + + auto const bytes_to_read = std::min(m_block_size - data_offset, nbytes); + if (block < CISO_MAP_SIZE && UNUSED_BLOCK_ID != m_ciso_map[block]) { - memset(out_ptr, 0, bytes_to_read); + // calcualte the base address + auto const file_off = CISO_HEADER_SIZE + m_ciso_map[block] * m_block_size + data_offset; + + if (!(m_file.Seek(file_off, SEEK_SET) && m_file.ReadArray(out_ptr, bytes_to_read))) + return false; + out_ptr += bytes_to_read; offset += bytes_to_read; - bytesRead += bytes_to_read; + nbytes -= bytes_to_read; } else { - // calcualte the base address - u64 file_off = CISO_HEAD_SIZE + ciso_map[block] * (u64)header.block_size + data_offset; - - if (!(m_file.Seek(file_off, SEEK_SET) && m_file.ReadBytes(out_ptr, bytes_to_read))) - return false; - + std::fill_n(out_ptr, bytes_to_read, 0); out_ptr += bytes_to_read; offset += bytes_to_read; - bytesRead += bytes_to_read; + nbytes -= bytes_to_read; } } + return true; } @@ -81,8 +98,9 @@ bool IsCISOBlob(const char* filename) { File::IOFile f(filename, "rb"); - CISO_Head_t header; - return (f.ReadArray(&header, 1) && (memcmp(header.magic, CISO_MAGIC, sizeof(header.magic)) == 0)); + CISOHeader header; + return (f.ReadArray(&header, 1) && + std::equal(header.magic, header.magic + sizeof(header.magic), CISO_MAGIC)); } } // namespace |
