mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-05 18:40:22 +00:00
37c09343d8
This lets VolumeDirectory/DirectoryBlob skip implementing various volume functions like GetGameID, GetBanner, etc. It also lets us view extracted discs in the game list. This ends up breaking the boot process for Wii DirectoryBlobs due to workarounds being removed from the boot process, but that will be fixed later by adding proper DirectoryBlob support for things like TMDs. We now expect the directories to be laid out in a certain format (based on the format that WIT uses) instead of requiring the user to set the DVD root and apploader path settings.
136 lines
3.4 KiB
C++
136 lines
3.4 KiB
C++
// Copyright 2008 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "Common/CommonTypes.h"
|
|
#include "Common/FileUtil.h"
|
|
#include "DiscIO/Blob.h"
|
|
|
|
namespace File
|
|
{
|
|
struct FSTEntry;
|
|
class IOFile;
|
|
}
|
|
|
|
namespace DiscIO
|
|
{
|
|
class DirectoryBlobReader : public BlobReader
|
|
{
|
|
public:
|
|
static bool IsValidDirectoryBlob(const std::string& dol_path);
|
|
static std::unique_ptr<DirectoryBlobReader> Create(File::IOFile dol, const std::string& dol_path);
|
|
|
|
bool Read(u64 offset, u64 length, u8* buffer) override;
|
|
bool SupportsReadWiiDecrypted() const override;
|
|
bool ReadWiiDecrypted(u64 offset, u64 size, u8* buffer, u64 partition_offset) override;
|
|
|
|
BlobType GetBlobType() const override;
|
|
u64 GetRawSize() const override;
|
|
u64 GetDataSize() const override;
|
|
|
|
void SetGameID(const std::string& id);
|
|
void SetName(const std::string&);
|
|
|
|
void BuildFST();
|
|
|
|
private:
|
|
DirectoryBlobReader(File::IOFile dol_file, const std::string& root_directory);
|
|
|
|
bool ReadPartition(u64 offset, u64 length, u8* buffer);
|
|
bool ReadNonPartition(u64 offset, u64 length, u8* buffer);
|
|
|
|
void SetDiskTypeWii();
|
|
void SetDiskTypeGC();
|
|
|
|
bool SetApploader(const std::string& apploader);
|
|
|
|
void SetDOLAndDiskType(File::IOFile dol_file);
|
|
|
|
// writing to read buffer
|
|
void WriteToBuffer(u64 source_start_address, u64 source_length, const u8* source, u64* address,
|
|
u64* length, u8** buffer) const;
|
|
|
|
void PadToAddress(u64 start_address, u64* address, u64* length, u8** buffer) const;
|
|
|
|
void Write32(u32 data, u32 offset, std::vector<u8>* const buffer);
|
|
|
|
// FST creation
|
|
void WriteEntryData(u32* entry_offset, u8 type, u32 name_offset, u64 data_offset, u64 length,
|
|
u32 address_shift);
|
|
void WriteEntryName(u32* name_offset, const std::string& name);
|
|
void WriteDirectory(const File::FSTEntry& parent_entry, u32* fst_offset, u32* name_offset,
|
|
u64* data_offset, u32 parent_entry_index);
|
|
|
|
std::string m_root_directory;
|
|
|
|
std::map<u64, std::string> m_virtual_disk;
|
|
|
|
bool m_is_wii = false;
|
|
|
|
// GameCube has no shift, Wii has 2 bit shift
|
|
u32 m_address_shift = 0;
|
|
|
|
// first address on disk containing file data
|
|
u64 m_data_start_address;
|
|
|
|
u64 m_fst_name_offset;
|
|
std::vector<u8> m_fst_data;
|
|
|
|
std::vector<u8> m_disk_header;
|
|
|
|
#pragma pack(push, 1)
|
|
struct SDiskHeaderInfo
|
|
{
|
|
u32 debug_monitor_size;
|
|
u32 simulated_mem_size;
|
|
u32 arg_offset;
|
|
u32 debug_flag;
|
|
u32 track_location;
|
|
u32 track_size;
|
|
u32 country_code;
|
|
u32 unknown;
|
|
u32 unknown2;
|
|
|
|
// All the data is byteswapped
|
|
SDiskHeaderInfo()
|
|
{
|
|
debug_monitor_size = 0;
|
|
simulated_mem_size = 0;
|
|
arg_offset = 0;
|
|
debug_flag = 0;
|
|
track_location = 0;
|
|
track_size = 0;
|
|
country_code = 0;
|
|
unknown = 0;
|
|
unknown2 = 0;
|
|
}
|
|
};
|
|
#pragma pack(pop)
|
|
std::unique_ptr<SDiskHeaderInfo> m_disk_header_info;
|
|
|
|
std::vector<u8> m_apploader;
|
|
std::vector<u8> m_dol;
|
|
|
|
u64 m_fst_address;
|
|
u64 m_dol_address;
|
|
|
|
static constexpr u8 ENTRY_SIZE = 0x0c;
|
|
static constexpr u8 FILE_ENTRY = 0;
|
|
static constexpr u8 DIRECTORY_ENTRY = 1;
|
|
static constexpr u64 DISKHEADER_ADDRESS = 0;
|
|
static constexpr u64 DISKHEADERINFO_ADDRESS = 0x440;
|
|
static constexpr u64 APPLOADER_ADDRESS = 0x2440;
|
|
static const size_t MAX_NAME_LENGTH = 0x3df;
|
|
static const size_t MAX_ID_LENGTH = 6;
|
|
};
|
|
|
|
} // namespace
|