2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:09:55 +00:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
#include <map>
|
2014-08-26 03:40:05 +00:00
|
|
|
#include <memory>
|
2013-10-18 07:32:56 +00:00
|
|
|
#include <string>
|
2014-02-21 00:47:53 +00:00
|
|
|
#include <vector>
|
2013-10-18 07:32:56 +00:00
|
|
|
|
2014-02-21 00:47:53 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DiscIO/Volume.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
namespace File
|
|
|
|
{
|
|
|
|
struct FSTEntry;
|
|
|
|
}
|
2014-02-21 00:47:53 +00:00
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
//
|
2016-06-25 16:07:10 +00:00
|
|
|
// --- this volume type is used for reading files directly from the hard drive ---
|
2008-12-08 04:46:09 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
namespace DiscIO
|
|
|
|
{
|
2016-07-06 18:33:05 +00:00
|
|
|
enum class BlobType;
|
|
|
|
enum class Country;
|
|
|
|
enum class Language;
|
|
|
|
enum class Platform;
|
|
|
|
|
2009-08-31 22:42:10 +00:00
|
|
|
class CVolumeDirectory : public IVolume
|
2008-12-08 04:46:09 +00:00
|
|
|
{
|
2009-12-10 09:16:10 +00:00
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
CVolumeDirectory(const std::string& _rDirectory, bool _bIsWii,
|
|
|
|
const std::string& _rApploader = "", const std::string& _rDOL = "");
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
~CVolumeDirectory();
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
static bool IsValidDirectory(const std::string& _rDirectory);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
bool Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const override;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-10-29 12:42:43 +00:00
|
|
|
std::string GetGameID() const override;
|
|
|
|
void SetGameID(const std::string& _ID);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
std::string GetMakerID() const override;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
u16 GetRevision() const override { return 0; }
|
|
|
|
std::string GetInternalName() const override;
|
2016-07-06 18:33:05 +00:00
|
|
|
std::map<Language, std::string> GetLongNames() const override;
|
2016-06-24 08:43:46 +00:00
|
|
|
std::vector<u32> GetBanner(int* width, int* height) const override;
|
|
|
|
void SetName(const std::string&);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
u64 GetFSTSize() const override;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
std::string GetApploaderDate() const override;
|
2016-07-06 18:33:05 +00:00
|
|
|
Platform GetVolumeType() const override;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-07-06 18:33:05 +00:00
|
|
|
Country GetCountry() const override;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
BlobType GetBlobType() const override;
|
|
|
|
u64 GetSize() const override;
|
|
|
|
u64 GetRawSize() const override;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
void BuildFST();
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-12-10 09:16:10 +00:00
|
|
|
private:
|
2016-06-24 08:43:46 +00:00
|
|
|
static std::string ExtractDirectoryName(const std::string& _rDirectory);
|
|
|
|
|
|
|
|
void SetDiskTypeWii();
|
|
|
|
void SetDiskTypeGC();
|
|
|
|
|
|
|
|
bool SetApploader(const std::string& _rApploader);
|
|
|
|
|
|
|
|
void SetDOL(const std::string& _rDOL);
|
|
|
|
|
|
|
|
// writing to read buffer
|
2016-12-26 08:52:18 +00:00
|
|
|
void WriteToBuffer(u64 _SrcStartAddress, u64 _SrcLength, const u8* _Src, u64* _Address,
|
|
|
|
u64* _Length, u8** _pBuffer) const;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-12-26 08:52:18 +00:00
|
|
|
void PadToAddress(u64 _StartAddress, u64* _Address, u64* _Length, u8** _pBuffer) const;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
void Write32(u32 data, u32 offset, std::vector<u8>* const buffer);
|
|
|
|
|
|
|
|
// FST creation
|
2016-12-26 08:52:18 +00:00
|
|
|
void WriteEntryData(u32* entryOffset, u8 type, u32 nameOffset, u64 dataOffset, u64 length);
|
|
|
|
void WriteEntryName(u32* nameOffset, const std::string& name);
|
|
|
|
void WriteDirectory(const File::FSTEntry& parent_entry, u32* fstOffset, u32* nameOffset,
|
|
|
|
u64* dataOffset, u32 parentEntryNum);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
std::string m_rootDirectory;
|
|
|
|
|
|
|
|
std::map<u64, std::string> m_virtualDisk;
|
|
|
|
|
|
|
|
bool m_is_wii;
|
|
|
|
|
|
|
|
// GameCube has no shift, Wii has 2 bit shift
|
|
|
|
u32 m_addressShift;
|
|
|
|
|
|
|
|
// first address on disk containing file data
|
|
|
|
u64 m_dataStartAddress;
|
|
|
|
|
|
|
|
u64 m_fstNameOffset;
|
|
|
|
std::vector<u8> m_FSTData;
|
|
|
|
|
|
|
|
std::vector<u8> m_diskHeader;
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
struct SDiskHeaderInfo
|
|
|
|
{
|
|
|
|
u32 debug_mntr_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_mntr_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_diskHeaderInfo;
|
|
|
|
|
|
|
|
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;
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
} // namespace
|