Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -rupN dolphin-orig/Source/Core/Core/Src/CoreParameter.cpp dolphin-patch/Source/Core/Core/Src/CoreParameter.cpp
- --- dolphin-orig/Source/Core/Core/Src/CoreParameter.cpp 2012-01-23 17:57:16.000000000 -0500
- +++ dolphin-patch/Source/Core/Core/Src/CoreParameter.cpp 2012-01-23 18:05:23.000000000 -0500
- @@ -126,6 +126,7 @@ bool SCoreStartupParameter::AutoSetup(EB
- std::string Extension;
- SplitPath(m_strFilename, NULL, NULL, &Extension);
- if (!strcasecmp(Extension.c_str(), ".gcm") ||
- + !strcasecmp(Extension.c_str(), ".wbfs") ||
- !strcasecmp(Extension.c_str(), ".iso") ||
- !strcasecmp(Extension.c_str(), ".ciso") ||
- !strcasecmp(Extension.c_str(), ".gcz") ||
- diff -rupN dolphin-orig/Source/Core/DiscIO/SConscript dolphin-patch/Source/Core/DiscIO/SConscript
- --- dolphin-orig/Source/Core/DiscIO/SConscript 2012-01-23 17:57:17.000000000 -0500
- +++ dolphin-patch/Source/Core/DiscIO/SConscript 2012-01-23 18:05:43.000000000 -0500
- @@ -24,6 +24,7 @@ files = [
- 'Src/VolumeWad.cpp',
- 'Src/VolumeWiiCrypted.cpp',
- 'Src/WiiWad.cpp',
- + 'Src/WbfsBlob.cpp',
- ]
- env['LIBS'] += env.StaticLibrary('discio', files)
- diff -rupN dolphin-orig/Source/Core/DiscIO/Src/Blob.cpp dolphin-patch/Source/Core/DiscIO/Src/Blob.cpp
- --- dolphin-orig/Source/Core/DiscIO/Src/Blob.cpp 2012-01-23 17:57:17.000000000 -0500
- +++ dolphin-patch/Source/Core/DiscIO/Src/Blob.cpp 2012-01-23 18:06:05.000000000 -0500
- @@ -23,6 +23,7 @@
- #include "FileBlob.h"
- #include "CISOBlob.h"
- #include "DriveBlob.h"
- +#include "WbfsBlob.h"
- namespace DiscIO
- {
- @@ -128,6 +129,9 @@ IBlobReader* CreateBlobReader(const char
- if (!File::Exists(filename))
- return 0;
- + if (IsWbfsBlob(filename))
- + return WbfsFileReader::Create(filename);
- +
- if (IsCompressedBlob(filename))
- return CompressedBlobReader::Create(filename);
- diff -rupN dolphin-orig/Source/Core/DiscIO/Src/WbfsBlob.cpp dolphin-patch/Source/Core/DiscIO/Src/WbfsBlob.cpp
- --- dolphin-orig/Source/Core/DiscIO/Src/WbfsBlob.cpp 1969-12-31 19:00:00.000000000 -0500
- +++ dolphin-patch/Source/Core/DiscIO/Src/WbfsBlob.cpp 2012-01-23 18:10:06.000000000 -0500
- @@ -0,0 +1,209 @@
- +// Copyright (C) 2003 Dolphin Project.
- +
- +// This program is free software: you can redistribute it and/or modify
- +// it under the terms of the GNU General Public License as published by
- +// the Free Software Foundation, version 2.0.
- +
- +// This program is distributed in the hope that it will be useful,
- +// but WITHOUT ANY WARRANTY; without even the implied warranty of
- +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- +// GNU General Public License 2.0 for more details.
- +
- +// A copy of the GPL 2.0 should have been included with the program.
- +// If not, see http://www.gnu.org/licenses/
- +
- +// Official SVN repository and contact information can be found at
- +// http://code.google.com/p/dolphin-emu/
- +
- +#include "WbfsBlob.h"
- +#include "FileUtil.h"
- +
- +namespace DiscIO
- +{
- +const u64 wii_sector_size = 0x8000;
- +const u64 wii_sector_count = 143432 * 2;
- +const u64 wii_sector_log2 = 15;
- +const u64 wii_disc_header_size = 256;
- +
- +static inline u64 align(u64 value, u64 bounds)
- +{
- + return (value + (bounds - 1)) & (~(bounds - 1));
- +}
- +
- +WbfsFileReader::WbfsFileReader(const char* filename)
- + : m_total_files(0), m_size(0), m_wlba_table(0), m_good(true)
- +{
- + if(!filename || (strlen(filename) < 4) || !OpenFiles(filename) || !ReadHeader())
- + {
- + m_good = false;
- + return;
- + }
- +
- + // Grab disc info (assume slot 0, checked in ReadHeader())
- + m_wlba_table = new u16[m_blocks_per_disc];
- + m_files[0]->file.Seek(hd_sector_size + wii_disc_header_size /*+ i * m_disc_info_size*/, SEEK_SET);
- + m_files[0]->file.ReadBytes(m_wlba_table, m_blocks_per_disc * sizeof(u16));
- +}
- +
- +WbfsFileReader::~WbfsFileReader()
- +{
- + for(u32 i = 0; i != m_files.size(); ++ i)
- + {
- + delete m_files[i];
- + }
- +
- + delete[] m_wlba_table;
- +}
- +
- +bool WbfsFileReader::OpenFiles(const char* filename)
- +{
- + m_total_files = 0;
- +
- + while(true)
- + {
- + file_entry* new_entry = new file_entry;
- +
- + // Replace last character with index (e.g. wbfs = wbf1)
- + std::string path = filename;
- + if(0 != m_total_files)
- + {
- + path[path.length() - 1] = '0' + m_total_files;
- + }
- +
- + if(!new_entry->file.Open(path, "rb"))
- + {
- + delete new_entry;
- + return 0 != m_total_files;
- + }
- +
- + new_entry->base_address = m_size;
- + new_entry->size = new_entry->file.GetSize();
- + m_size += new_entry->size;
- +
- + m_total_files ++;
- + m_files.push_back(new_entry);
- + }
- +}
- +
- +bool WbfsFileReader::ReadHeader()
- +{
- + m_files[0]->file.Seek(4, SEEK_SET);
- +
- + // Read hd size info
- + m_files[0]->file.ReadBytes(&hd_sector_count, 4);
- + hd_sector_count = Common::swap32(hd_sector_count);
- +
- + m_files[0]->file.ReadBytes(&hd_sector_shift, 1);
- + hd_sector_size = 1 << hd_sector_shift;
- +
- + if(m_size != hd_sector_count * hd_sector_size)
- + {
- + //printf("File size doesn't match expected size\n");
- + return false;
- + }
- +
- + // Read wbfs cluster info
- + m_files[0]->file.ReadBytes(&wbfs_sector_shift, 1);
- + wbfs_sector_size = 1 << wbfs_sector_shift;
- + wbfs_sector_count = m_size / wbfs_sector_size;
- +
- + if(wbfs_sector_size < wii_sector_size)
- + {
- + //Setting this too low would case a very large memory allocation
- + return false;
- + }
- +
- + m_blocks_per_disc = (wii_sector_count * wii_sector_size) / wbfs_sector_size;
- + m_disc_info_size = align(wii_disc_header_size + m_blocks_per_disc * 2, hd_sector_size);
- +
- + // Read disc table
- + m_files[0]->file.Seek(2, SEEK_CUR);
- + m_files[0]->file.ReadBytes(disc_table, 500);
- +
- + if(0 == disc_table[0])
- + {
- + //printf("Game must be in 'slot 0'\n");
- + return false;
- + }
- +
- + return true;
- +}
- +
- +bool WbfsFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
- +{
- + while(nbytes)
- + {
- + u64 read_size;
- + File::IOFile& data_file = SeekToCluster(offset, &read_size);
- + read_size = (read_size > nbytes) ? nbytes : read_size;
- +
- + data_file.ReadBytes(out_ptr, read_size);
- +
- + out_ptr += read_size;
- + nbytes -= read_size;
- + offset += read_size;
- + }
- +
- + return true;
- +}
- +
- +File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
- +{
- + u64 base_cluster = offset >> wbfs_sector_shift;
- + if(base_cluster < m_blocks_per_disc)
- + {
- + u64 cluster_address = wbfs_sector_size * Common::swap16(m_wlba_table[base_cluster]);
- + u64 cluster_offset = offset & (wbfs_sector_size - 1);
- + u64 final_address = cluster_address + cluster_offset;
- +
- + for(u32 i = 0; i != m_total_files; i ++)
- + {
- + if(final_address < (m_files[i]->base_address + m_files[i]->size))
- + {
- + m_files[i]->file.Seek(final_address - m_files[i]->base_address, SEEK_SET);
- + if(available)
- + {
- + u64 till_end_of_file = m_files[i]->size - (final_address - m_files[i]->base_address);
- + u64 till_end_of_sector = wbfs_sector_size - cluster_offset;
- + *available = std::min(till_end_of_file, till_end_of_sector);
- + }
- +
- + return m_files[i]->file;
- + }
- + }
- + }
- +
- + PanicAlert("Read beyond end of disc");
- + m_files[0]->file.Seek(0, SEEK_SET);
- + return m_files[0]->file;
- +}
- +
- +WbfsFileReader* WbfsFileReader::Create(const char* filename)
- +{
- + WbfsFileReader* reader = new WbfsFileReader(filename);
- +
- + if(reader->IsGood())
- + {
- + return reader;
- + }
- + else
- + {
- + delete reader;
- + return NULL;
- + }
- +}
- +
- +bool IsWbfsBlob(const char* filename)
- +{
- + File::IOFile f(filename, "rb");
- +
- + u8 magic[4] = {0, 0, 0, 0};
- + f.ReadBytes(&magic, 4);
- +
- + return (magic[0] == 'W') &&
- + (magic[1] == 'B') &&
- + (magic[2] == 'F') &&
- + (magic[3] == 'S');
- +}
- +
- +} // namespace
- diff -rupN dolphin-orig/Source/Core/DiscIO/Src/WbfsBlob.h dolphin-patch/Source/Core/DiscIO/Src/WbfsBlob.h
- --- dolphin-orig/Source/Core/DiscIO/Src/WbfsBlob.h 1969-12-31 19:00:00.000000000 -0500
- +++ dolphin-patch/Source/Core/DiscIO/Src/WbfsBlob.h 2012-01-23 18:06:45.000000000 -0500
- @@ -0,0 +1,82 @@
- +// Copyright (C) 2003 Dolphin Project.
- +
- +// This program is free software: you can redistribute it and/or modify
- +// it under the terms of the GNU General Public License as published by
- +// the Free Software Foundation, version 2.0.
- +
- +// This program is distributed in the hope that it will be useful,
- +// but WITHOUT ANY WARRANTY; without even the implied warranty of
- +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- +// GNU General Public License 2.0 for more details.
- +
- +// A copy of the GPL 2.0 should have been included with the program.
- +// If not, see http://www.gnu.org/licenses/
- +
- +// Official SVN repository and contact information can be found at
- +// http://code.google.com/p/dolphin-emu/
- +
- +#ifndef _WBFS_BLOB_H
- +#define _WBFS_BLOB_H
- +
- +#include "Blob.h"
- +#include "FileUtil.h"
- +
- +namespace DiscIO
- +{
- +
- +struct wbfs_head_t;
- +
- +class WbfsFileReader : public IBlobReader
- +{
- + WbfsFileReader(const char* filename);
- + ~WbfsFileReader();
- +
- + bool OpenFiles(const char* filename);
- + bool ReadHeader();
- +
- + File::IOFile& SeekToCluster(u64 offset, u64* available);
- + bool IsGood() {return m_good;}
- +
- +
- + struct file_entry
- + {
- + File::IOFile file;
- + u64 base_address;
- + u64 size;
- + };
- +
- + std::vector<file_entry*> m_files;
- +
- + u32 m_total_files;
- + u64 m_size;
- +
- + u64 hd_sector_size;
- + u8 hd_sector_shift;
- + u32 hd_sector_count;
- +
- + u64 wbfs_sector_size;
- + u64 wbfs_sector_shift;
- + u64 wbfs_sector_count;
- + u64 m_disc_info_size;
- +
- + u8 disc_table[500];
- +
- + u16* m_wlba_table;
- + u64 m_blocks_per_disc;
- +
- + bool m_good;
- +
- +public:
- + static WbfsFileReader* Create(const char* filename);
- +
- + u64 GetDataSize() const { return m_size; }
- + u64 GetRawSize() const { return m_size; }
- + bool Read(u64 offset, u64 nbytes, u8* out_ptr);
- +};
- +
- +bool IsWbfsBlob(const char* filename);
- +
- +
- +} // namespace
- +
- +#endif // _FILE_BLOB_H
- diff -rupN dolphin-orig/Source/Core/DolphinWX/Src/GameListCtrl.cpp dolphin-patch/Source/Core/DolphinWX/Src/GameListCtrl.cpp
- --- dolphin-orig/Source/Core/DolphinWX/Src/GameListCtrl.cpp 2012-01-23 17:57:17.000000000 -0500
- +++ dolphin-patch/Source/Core/DolphinWX/Src/GameListCtrl.cpp 2012-01-23 18:06:32.000000000 -0500
- @@ -602,6 +602,7 @@ void CGameListCtrl::ScanForISOs()
- Extensions.push_back("*.iso");
- Extensions.push_back("*.ciso");
- Extensions.push_back("*.gcz");
- + Extensions.push_back("*.wbfs");
- }
- if (SConfig::GetInstance().m_ListWad)
- Extensions.push_back("*.wad");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement