Move DiscIO enums to a new file

At first there weren't many enums in Volume.h, but the number has been
growing, and I'm planning to add one more for regions. To not make
Volume.h too large, and to avoid needing to include Volume.h in code
that doesn't use volume objects, I'm moving the enums to a new file.
I'm also turning them into enum classes while I'm at it.
This commit is contained in:
JosJuice
2016-07-06 20:33:05 +02:00
parent baf9abe911
commit 0a15aaaa12
49 changed files with 665 additions and 574 deletions

View File

@ -22,7 +22,7 @@
namespace DiscIO
{
// Increment CACHE_REVISION if the enum below is modified (ISOFile.cpp & GameFile.cpp)
// Increment CACHE_REVISION (ISOFile.cpp & GameFile.cpp) if the enum below is modified
enum class BlobType
{
PLAIN,

View File

@ -4,12 +4,13 @@ set(SRCS Blob.cpp
CompressedBlob.cpp
DiscScrubber.cpp
DriveBlob.cpp
Enums.cpp
FileBlob.cpp
FileMonitor.cpp
FileSystemGCWii.cpp
Filesystem.cpp
NANDContentLoader.cpp
VolumeCommon.cpp
Volume.cpp
VolumeCreator.cpp
VolumeDirectory.cpp
VolumeGC.cpp

View File

@ -40,12 +40,13 @@
<ClCompile Include="CompressedBlob.cpp" />
<ClCompile Include="DiscScrubber.cpp" />
<ClCompile Include="DriveBlob.cpp" />
<ClCompile Include="Enums.cpp" />
<ClCompile Include="FileBlob.cpp" />
<ClCompile Include="FileMonitor.cpp" />
<ClCompile Include="Filesystem.cpp" />
<ClCompile Include="FileSystemGCWii.cpp" />
<ClCompile Include="NANDContentLoader.cpp" />
<ClCompile Include="VolumeCommon.cpp" />
<ClCompile Include="Volume.cpp" />
<ClCompile Include="VolumeCreator.cpp" />
<ClCompile Include="VolumeDirectory.cpp" />
<ClCompile Include="VolumeGC.cpp" />
@ -60,6 +61,7 @@
<ClInclude Include="CompressedBlob.h" />
<ClInclude Include="DiscScrubber.h" />
<ClInclude Include="DriveBlob.h" />
<ClInclude Include="Enums.h" />
<ClInclude Include="FileBlob.h" />
<ClInclude Include="FileMonitor.h" />
<ClInclude Include="Filesystem.h" />
@ -91,4 +93,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -54,9 +54,6 @@
<ClCompile Include="FileMonitor.cpp">
<Filter>Volume</Filter>
</ClCompile>
<ClCompile Include="VolumeCommon.cpp">
<Filter>Volume</Filter>
</ClCompile>
<ClCompile Include="VolumeCreator.cpp">
<Filter>Volume</Filter>
</ClCompile>
@ -72,6 +69,12 @@
<ClCompile Include="VolumeWiiCrypted.cpp">
<Filter>Volume</Filter>
</ClCompile>
<ClCompile Include="Enums.cpp">
<Filter>Volume</Filter>
</ClCompile>
<ClCompile Include="Volume.cpp">
<Filter>Volume</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="DiscScrubber.h">
@ -128,6 +131,9 @@
<ClInclude Include="VolumeWiiCrypted.h">
<Filter>Volume</Filter>
</ClInclude>
<ClInclude Include="Enums.h">
<Filter>Volume</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />

View File

@ -1,146 +1,83 @@
// Copyright 2009 Dolphin Emulator Project
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <algorithm>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include "Common/ColorUtil.h"
#include "Common/CommonFuncs.h"
#include "DiscIO/Enums.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
#include "DiscIO/Volume.h"
namespace DiscIO
{
static const unsigned int WII_BANNER_WIDTH = 192;
static const unsigned int WII_BANNER_HEIGHT = 64;
static const unsigned int WII_BANNER_SIZE = WII_BANNER_WIDTH * WII_BANNER_HEIGHT * 2;
static const unsigned int WII_BANNER_OFFSET = 0xA0;
// Increment CACHE_REVISION (ISOFile.cpp & GameFile.cpp) if the code below is modified
std::vector<u32> IVolume::GetWiiBanner(int* width, int* height, u64 title_id)
{
*width = 0;
*height = 0;
std::string file_name = StringFromFormat("%s/title/%08x/%08x/data/banner.bin",
File::GetUserPath(D_WIIROOT_IDX).c_str(),
(u32)(title_id >> 32), (u32)title_id);
if (!File::Exists(file_name))
return std::vector<u32>();
if (File::GetSize(file_name) < WII_BANNER_OFFSET + WII_BANNER_SIZE)
return std::vector<u32>();
File::IOFile file(file_name, "rb");
if (!file.Seek(WII_BANNER_OFFSET, SEEK_SET))
return std::vector<u32>();
std::vector<u8> banner_file(WII_BANNER_SIZE);
if (!file.ReadBytes(banner_file.data(), banner_file.size()))
return std::vector<u32>();
std::vector<u32> image_buffer(WII_BANNER_WIDTH * WII_BANNER_HEIGHT);
ColorUtil::decode5A3image(image_buffer.data(), (u16*)banner_file.data(), WII_BANNER_WIDTH,
WII_BANNER_HEIGHT);
*width = WII_BANNER_WIDTH;
*height = WII_BANNER_HEIGHT;
return image_buffer;
}
std::map<IVolume::ELanguage, std::string> IVolume::ReadWiiNames(const std::vector<u8>& data)
{
std::map<IVolume::ELanguage, std::string> names;
for (size_t i = 0; i < NUMBER_OF_LANGUAGES; ++i)
{
size_t name_start = NAME_BYTES_LENGTH * i;
size_t name_end = name_start + NAME_BYTES_LENGTH;
if (data.size() >= name_end)
{
u16* temp = (u16*)(data.data() + name_start);
std::wstring out_temp(NAME_STRING_LENGTH, '\0');
std::transform(temp, temp + out_temp.size(), out_temp.begin(), (u16(&)(u16))Common::swap16);
out_temp.erase(std::find(out_temp.begin(), out_temp.end(), 0x00), out_temp.end());
std::string name = UTF16ToUTF8(out_temp);
if (!name.empty())
names[(IVolume::ELanguage)i] = name;
}
}
return names;
}
// Increment CACHE_REVISION if the code below is modified (ISOFile.cpp & GameFile.cpp)
IVolume::ECountry CountrySwitch(u8 country_code)
Country CountrySwitch(u8 country_code)
{
switch (country_code)
{
// Worldwide
case 'A':
return IVolume::COUNTRY_WORLD;
return Country::COUNTRY_WORLD;
// PAL
case 'D':
return IVolume::COUNTRY_GERMANY;
return Country::COUNTRY_GERMANY;
case 'X': // Used by a couple PAL games
case 'Y': // German, French
case 'L': // Japanese import to PAL regions
case 'M': // Japanese import to PAL regions
case 'P':
return IVolume::COUNTRY_EUROPE;
return Country::COUNTRY_EUROPE;
case 'U':
return IVolume::COUNTRY_AUSTRALIA;
return Country::COUNTRY_AUSTRALIA;
case 'F':
return IVolume::COUNTRY_FRANCE;
return Country::COUNTRY_FRANCE;
case 'I':
return IVolume::COUNTRY_ITALY;
return Country::COUNTRY_ITALY;
case 'H':
return IVolume::COUNTRY_NETHERLANDS;
return Country::COUNTRY_NETHERLANDS;
case 'R':
return IVolume::COUNTRY_RUSSIA;
return Country::COUNTRY_RUSSIA;
case 'S':
return IVolume::COUNTRY_SPAIN;
return Country::COUNTRY_SPAIN;
// NTSC
case 'E':
case 'N': // Japanese import to USA and other NTSC regions
case 'Z': // Prince of Persia - The Forgotten Sands (Wii)
case 'B': // Ufouria: The Saga (Virtual Console)
return IVolume::COUNTRY_USA;
return Country::COUNTRY_USA;
case 'J':
return IVolume::COUNTRY_JAPAN;
return Country::COUNTRY_JAPAN;
case 'K':
case 'Q': // Korea with Japanese language
case 'T': // Korea with English language
return IVolume::COUNTRY_KOREA;
return Country::COUNTRY_KOREA;
case 'W':
return IVolume::COUNTRY_TAIWAN;
return Country::COUNTRY_TAIWAN;
default:
if (country_code > 'A') // Silently ignore IOS wads
WARN_LOG(DISCIO, "Unknown Country Code! %c", country_code);
return IVolume::COUNTRY_UNKNOWN;
return Country::COUNTRY_UNKNOWN;
}
}
u8 GetSysMenuRegion(u16 _TitleVersion)
u8 GetSysMenuRegion(u16 title_version)
{
switch (_TitleVersion)
switch (title_version)
{
case 128:
case 192:

View File

@ -0,0 +1,62 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "Common/CommonTypes.h"
namespace DiscIO
{
// Increment CACHE_REVISION (ISOFile.cpp & GameFile.cpp) if these enums are modified
enum class Platform
{
GAMECUBE_DISC = 0,
WII_DISC,
WII_WAD,
ELF_DOL,
NUMBER_OF_PLATFORMS
};
enum class Country
{
COUNTRY_EUROPE = 0,
COUNTRY_JAPAN,
COUNTRY_USA,
COUNTRY_AUSTRALIA,
COUNTRY_FRANCE,
COUNTRY_GERMANY,
COUNTRY_ITALY,
COUNTRY_KOREA,
COUNTRY_NETHERLANDS,
COUNTRY_RUSSIA,
COUNTRY_SPAIN,
COUNTRY_TAIWAN,
COUNTRY_WORLD,
COUNTRY_UNKNOWN,
NUMBER_OF_COUNTRIES
};
// Languages 0 - 9 match Nintendo's Wii language numbering.
// Languages 1 - 6 match Nintendo's PAL GameCube languages 0 - 5.
// NTSC GameCubes only support one language and thus don't number languages.
enum class Language
{
LANGUAGE_JAPANESE = 0,
LANGUAGE_ENGLISH = 1,
LANGUAGE_GERMAN = 2,
LANGUAGE_FRENCH = 3,
LANGUAGE_SPANISH = 4,
LANGUAGE_ITALIAN = 5,
LANGUAGE_DUTCH = 6,
LANGUAGE_SIMPLIFIED_CHINESE = 7,
LANGUAGE_TRADITIONAL_CHINESE = 8,
LANGUAGE_KOREAN = 9,
LANGUAGE_UNKNOWN
};
Country CountrySwitch(u8 country_code);
u8 GetSysMenuRegion(u16 title_version);
std::string GetCompanyFromID(const std::string& company_id);
}

View File

@ -18,6 +18,7 @@
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "DiscIO/Enums.h"
#include "DiscIO/FileMonitor.h"
#include "DiscIO/Filesystem.h"
#include "DiscIO/Volume.h"
@ -67,7 +68,7 @@ void ReadFileSystem(const std::string& filename)
if (!s_open_iso)
return;
if (s_open_iso->GetVolumeType() != DiscIO::IVolume::WII_WAD)
if (s_open_iso->GetVolumeType() != DiscIO::Platform::WII_WAD)
{
s_filesystem = DiscIO::CreateFileSystem(s_open_iso.get());

View File

@ -23,8 +23,8 @@
#include "Common/NandPaths.h"
#include "Common/StringUtil.h"
#include "DiscIO/Enums.h"
#include "DiscIO/NANDContentLoader.h"
#include "DiscIO/Volume.h"
#include "DiscIO/WiiWad.h"
namespace DiscIO
@ -303,10 +303,10 @@ std::vector<u8> CNANDContentLoader::GetKeyFromTicket(const std::vector<u8>& tick
return AESDecode(common_key, iv, &ticket[0x01BF], 16);
}
DiscIO::IVolume::ECountry CNANDContentLoader::GetCountry() const
DiscIO::Country CNANDContentLoader::GetCountry() const
{
if (!IsValid())
return DiscIO::IVolume::COUNTRY_UNKNOWN;
return DiscIO::Country::COUNTRY_UNKNOWN;
return CountrySwitch(m_Country);
}

View File

@ -5,13 +5,18 @@
#pragma once
#include <cstddef>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "Common/CommonTypes.h"
#include "Common/NandPaths.h"
#include "DiscIO/Volume.h"
namespace DiscIO
{
enum class Country;
}
namespace DiscIO
{
@ -86,7 +91,7 @@ public:
const std::vector<SNANDContent>& GetContent() const { return m_Content; }
u16 GetTitleVersion() const { return m_TitleVersion; }
u16 GetNumEntries() const { return m_NumEntries; }
DiscIO::IVolume::ECountry GetCountry() const;
DiscIO::Country GetCountry() const;
u8 GetCountryChar() const { return m_Country; }
enum
{

View File

@ -0,0 +1,77 @@
// Copyright 2009 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <algorithm>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include "Common/ColorUtil.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
#include "DiscIO/Enums.h"
#include "DiscIO/Volume.h"
namespace DiscIO
{
static const unsigned int WII_BANNER_WIDTH = 192;
static const unsigned int WII_BANNER_HEIGHT = 64;
static const unsigned int WII_BANNER_SIZE = WII_BANNER_WIDTH * WII_BANNER_HEIGHT * 2;
static const unsigned int WII_BANNER_OFFSET = 0xA0;
std::vector<u32> IVolume::GetWiiBanner(int* width, int* height, u64 title_id)
{
*width = 0;
*height = 0;
std::string file_name = StringFromFormat("%s/title/%08x/%08x/data/banner.bin",
File::GetUserPath(D_WIIROOT_IDX).c_str(),
(u32)(title_id >> 32), (u32)title_id);
if (!File::Exists(file_name))
return std::vector<u32>();
if (File::GetSize(file_name) < WII_BANNER_OFFSET + WII_BANNER_SIZE)
return std::vector<u32>();
File::IOFile file(file_name, "rb");
if (!file.Seek(WII_BANNER_OFFSET, SEEK_SET))
return std::vector<u32>();
std::vector<u8> banner_file(WII_BANNER_SIZE);
if (!file.ReadBytes(banner_file.data(), banner_file.size()))
return std::vector<u32>();
std::vector<u32> image_buffer(WII_BANNER_WIDTH * WII_BANNER_HEIGHT);
ColorUtil::decode5A3image(image_buffer.data(), (u16*)banner_file.data(), WII_BANNER_WIDTH,
WII_BANNER_HEIGHT);
*width = WII_BANNER_WIDTH;
*height = WII_BANNER_HEIGHT;
return image_buffer;
}
std::map<Language, std::string> IVolume::ReadWiiNames(const std::vector<u8>& data)
{
std::map<Language, std::string> names;
for (size_t i = 0; i < NUMBER_OF_LANGUAGES; ++i)
{
size_t name_start = NAME_BYTES_LENGTH * i;
size_t name_end = name_start + NAME_BYTES_LENGTH;
if (data.size() >= name_end)
{
u16* temp = (u16*)(data.data() + name_start);
std::wstring out_temp(NAME_STRING_LENGTH, '\0');
std::transform(temp, temp + out_temp.size(), out_temp.begin(), (u16(&)(u16))Common::swap16);
out_temp.erase(std::find(out_temp.begin(), out_temp.end(), 0x00), out_temp.end());
std::string name = UTF16ToUTF8(out_temp);
if (!name.empty())
names[static_cast<Language>(i)] = name;
}
}
return names;
}
}

View File

@ -12,59 +12,15 @@
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/StringUtil.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
namespace DiscIO
{
enum class BlobType;
class IVolume
{
public:
// Increment CACHE_REVISION if the enums below are modified (ISOFile.cpp & GameFile.cpp)
enum EPlatform
{
GAMECUBE_DISC = 0,
WII_DISC,
WII_WAD,
ELF_DOL,
NUMBER_OF_PLATFORMS
};
enum ECountry
{
COUNTRY_EUROPE = 0,
COUNTRY_JAPAN,
COUNTRY_USA,
COUNTRY_AUSTRALIA,
COUNTRY_FRANCE,
COUNTRY_GERMANY,
COUNTRY_ITALY,
COUNTRY_KOREA,
COUNTRY_NETHERLANDS,
COUNTRY_RUSSIA,
COUNTRY_SPAIN,
COUNTRY_TAIWAN,
COUNTRY_WORLD,
COUNTRY_UNKNOWN,
NUMBER_OF_COUNTRIES
};
// Languages 0 - 9 match the official Wii language numbering.
// Languages 1 - 6 match the official GC PAL languages 0 - 5.
enum ELanguage
{
LANGUAGE_JAPANESE = 0,
LANGUAGE_ENGLISH = 1,
LANGUAGE_GERMAN = 2,
LANGUAGE_FRENCH = 3,
LANGUAGE_SPANISH = 4,
LANGUAGE_ITALIAN = 5,
LANGUAGE_DUTCH = 6,
LANGUAGE_SIMPLIFIED_CHINESE = 7,
LANGUAGE_TRADITIONAL_CHINESE = 8,
LANGUAGE_KOREAN = 9,
LANGUAGE_UNKNOWN
};
IVolume() {}
virtual ~IVolume() {}
// decrypt parameter must be false if not reading a Wii disc
@ -85,36 +41,21 @@ public:
virtual std::string GetMakerID() const = 0;
virtual u16 GetRevision() const = 0;
virtual std::string GetInternalName() const = 0;
virtual std::map<ELanguage, std::string> GetShortNames() const
{
return std::map<ELanguage, std::string>();
}
virtual std::map<ELanguage, std::string> GetLongNames() const
{
return std::map<ELanguage, std::string>();
}
virtual std::map<ELanguage, std::string> GetShortMakers() const
{
return std::map<ELanguage, std::string>();
}
virtual std::map<ELanguage, std::string> GetLongMakers() const
{
return std::map<ELanguage, std::string>();
}
virtual std::map<ELanguage, std::string> GetDescriptions() const
{
return std::map<ELanguage, std::string>();
}
virtual std::map<Language, std::string> GetShortNames() const { return {{}}; }
virtual std::map<Language, std::string> GetLongNames() const { return {{}}; }
virtual std::map<Language, std::string> GetShortMakers() const { return {{}}; }
virtual std::map<Language, std::string> GetLongMakers() const { return {{}}; }
virtual std::map<Language, std::string> GetDescriptions() const { return {{}}; }
virtual std::vector<u32> GetBanner(int* width, int* height) const = 0;
virtual u64 GetFSTSize() const = 0;
virtual std::string GetApploaderDate() const = 0;
// 0 is the first disc, 1 is the second disc
virtual u8 GetDiscNumber() const { return 0; }
virtual EPlatform GetVolumeType() const = 0;
virtual Platform GetVolumeType() const = 0;
virtual bool SupportsIntegrityCheck() const { return false; }
virtual bool CheckIntegrity() const { return false; }
virtual bool ChangePartition(u64 offset) { return false; }
virtual ECountry GetCountry() const = 0;
virtual Country GetCountry() const = 0;
virtual BlobType GetBlobType() const = 0;
// Size of virtual disc (not always accurate)
virtual u64 GetSize() const = 0;
@ -132,7 +73,8 @@ protected:
// There doesn't seem to be any GC discs with the country set to Taiwan...
// But maybe they would use Shift_JIS if they existed? Not sure
bool use_shift_jis = (COUNTRY_JAPAN == GetCountry() || COUNTRY_TAIWAN == GetCountry());
bool use_shift_jis =
(Country::COUNTRY_JAPAN == GetCountry() || Country::COUNTRY_TAIWAN == GetCountry());
if (use_shift_jis)
return SHIFTJISToUTF8(string);
@ -140,7 +82,7 @@ protected:
return CP1252ToUTF8(string);
}
static std::map<IVolume::ELanguage, std::string> ReadWiiNames(const std::vector<u8>& data);
static std::map<Language, std::string> ReadWiiNames(const std::vector<u8>& data);
static const size_t NUMBER_OF_LANGUAGES = 10;
static const size_t NAME_STRING_LENGTH = 42;
@ -148,9 +90,4 @@ protected:
static const size_t NAMES_TOTAL_BYTES = NAME_BYTES_LENGTH * NUMBER_OF_LANGUAGES;
};
// Generic Switch function for all volumes
IVolume::ECountry CountrySwitch(u8 country_code);
u8 GetSysMenuRegion(u16 _TitleVersion);
std::string GetCompanyFromID(const std::string& company_id);
} // namespace

View File

@ -17,6 +17,7 @@
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "DiscIO/FileMonitor.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeDirectory.h"
@ -163,7 +164,7 @@ void CVolumeDirectory::SetUniqueID(const std::string& id)
memcpy(m_diskHeader.data(), id.c_str(), std::min(id.length(), MAX_ID_LENGTH));
}
IVolume::ECountry CVolumeDirectory::GetCountry() const
Country CVolumeDirectory::GetCountry() const
{
return CountrySwitch(m_diskHeader[3]);
}
@ -183,12 +184,12 @@ std::string CVolumeDirectory::GetInternalName() const
return "";
}
std::map<IVolume::ELanguage, std::string> CVolumeDirectory::GetLongNames() const
std::map<Language, std::string> CVolumeDirectory::GetLongNames() const
{
std::string name = GetInternalName();
if (name.empty())
return {{}};
return {{IVolume::LANGUAGE_UNKNOWN, name}};
return {{Language::LANGUAGE_UNKNOWN, name}};
}
std::vector<u32> CVolumeDirectory::GetBanner(int* width, int* height) const
@ -218,9 +219,9 @@ std::string CVolumeDirectory::GetApploaderDate() const
return "VOID";
}
IVolume::EPlatform CVolumeDirectory::GetVolumeType() const
Platform CVolumeDirectory::GetVolumeType() const
{
return m_is_wii ? WII_DISC : GAMECUBE_DISC;
return m_is_wii ? Platform::WII_DISC : Platform::GAMECUBE_DISC;
}
BlobType CVolumeDirectory::GetBlobType() const

View File

@ -10,7 +10,6 @@
#include <vector>
#include "Common/CommonTypes.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Volume.h"
namespace File
@ -24,6 +23,11 @@ struct FSTEntry;
namespace DiscIO
{
enum class BlobType;
enum class Country;
enum class Language;
enum class Platform;
class CVolumeDirectory : public IVolume
{
public:
@ -43,16 +47,16 @@ public:
u16 GetRevision() const override { return 0; }
std::string GetInternalName() const override;
std::map<IVolume::ELanguage, std::string> GetLongNames() const override;
std::map<Language, std::string> GetLongNames() const override;
std::vector<u32> GetBanner(int* width, int* height) const override;
void SetName(const std::string&);
u64 GetFSTSize() const override;
std::string GetApploaderDate() const override;
EPlatform GetVolumeType() const override;
Platform GetVolumeType() const override;
ECountry GetCountry() const override;
Country GetCountry() const override;
BlobType GetBlobType() const override;
u64 GetSize() const override;

View File

@ -15,6 +15,7 @@
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "DiscIO/FileMonitor.h"
#include "DiscIO/Filesystem.h"
#include "DiscIO/Volume.h"
@ -60,10 +61,10 @@ std::string CVolumeGC::GetUniqueID() const
return DecodeString(ID);
}
IVolume::ECountry CVolumeGC::GetCountry() const
Country CVolumeGC::GetCountry() const
{
if (!m_pReader)
return COUNTRY_UNKNOWN;
return Country::COUNTRY_UNKNOWN;
u8 country_code;
m_pReader->Read(3, 1, &country_code);
@ -104,31 +105,31 @@ std::string CVolumeGC::GetInternalName() const
return "";
}
std::map<IVolume::ELanguage, std::string> CVolumeGC::GetShortNames() const
std::map<Language, std::string> CVolumeGC::GetShortNames() const
{
LoadBannerFile();
return m_short_names;
}
std::map<IVolume::ELanguage, std::string> CVolumeGC::GetLongNames() const
std::map<Language, std::string> CVolumeGC::GetLongNames() const
{
LoadBannerFile();
return m_long_names;
}
std::map<IVolume::ELanguage, std::string> CVolumeGC::GetShortMakers() const
std::map<Language, std::string> CVolumeGC::GetShortMakers() const
{
LoadBannerFile();
return m_short_makers;
}
std::map<IVolume::ELanguage, std::string> CVolumeGC::GetLongMakers() const
std::map<Language, std::string> CVolumeGC::GetLongMakers() const
{
LoadBannerFile();
return m_long_makers;
}
std::map<IVolume::ELanguage, std::string> CVolumeGC::GetDescriptions() const
std::map<Language, std::string> CVolumeGC::GetDescriptions() const
{
LoadBannerFile();
return m_descriptions;
@ -194,9 +195,9 @@ u8 CVolumeGC::GetDiscNumber() const
return disc_number;
}
IVolume::EPlatform CVolumeGC::GetVolumeType() const
Platform CVolumeGC::GetVolumeType() const
{
return GAMECUBE_DISC;
return Platform::GAMECUBE_DISC;
}
void CVolumeGC::LoadBannerFile() const
@ -241,18 +242,18 @@ void CVolumeGC::LoadBannerFile() const
void CVolumeGC::ExtractBannerInformation(const GCBanner& banner_file, bool is_bnr1) const
{
u32 number_of_languages = 0;
ELanguage start_language = LANGUAGE_UNKNOWN;
bool is_japanese = GetCountry() == ECountry::COUNTRY_JAPAN;
Language start_language = Language::LANGUAGE_UNKNOWN;
if (is_bnr1) // NTSC
{
bool is_japanese = GetCountry() == Country::COUNTRY_JAPAN;
number_of_languages = 1;
start_language = is_japanese ? ELanguage::LANGUAGE_JAPANESE : ELanguage::LANGUAGE_ENGLISH;
start_language = is_japanese ? Language::LANGUAGE_JAPANESE : Language::LANGUAGE_ENGLISH;
}
else // PAL
{
number_of_languages = 6;
start_language = ELanguage::LANGUAGE_ENGLISH;
start_language = Language::LANGUAGE_ENGLISH;
}
m_image_width = GC_BANNER_WIDTH;
@ -264,7 +265,7 @@ void CVolumeGC::ExtractBannerInformation(const GCBanner& banner_file, bool is_bn
for (u32 i = 0; i < number_of_languages; ++i)
{
const GCBannerInformation& info = banner_file.information[i];
ELanguage language = static_cast<ELanguage>(start_language + i);
Language language = static_cast<Language>(static_cast<int>(start_language) + i);
std::string description = DecodeString(info.description);
if (!description.empty())

View File

@ -10,13 +10,17 @@
#include <vector>
#include "Common/CommonTypes.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Volume.h"
// --- this volume type is used for GC disc images ---
namespace DiscIO
{
enum class BlobType;
enum class Country;
enum class Language;
enum class Platform;
class CVolumeGC : public IVolume
{
public:
@ -27,18 +31,18 @@ public:
std::string GetMakerID() const override;
u16 GetRevision() const override;
std::string GetInternalName() const override;
std::map<ELanguage, std::string> GetShortNames() const override;
std::map<ELanguage, std::string> GetLongNames() const override;
std::map<ELanguage, std::string> GetShortMakers() const override;
std::map<ELanguage, std::string> GetLongMakers() const override;
std::map<ELanguage, std::string> GetDescriptions() const override;
std::map<Language, std::string> GetShortNames() const override;
std::map<Language, std::string> GetLongNames() const override;
std::map<Language, std::string> GetShortMakers() const override;
std::map<Language, std::string> GetLongMakers() const override;
std::map<Language, std::string> GetDescriptions() const override;
std::vector<u32> GetBanner(int* width, int* height) const override;
u64 GetFSTSize() const override;
std::string GetApploaderDate() const override;
u8 GetDiscNumber() const override;
EPlatform GetVolumeType() const override;
ECountry GetCountry() const override;
Platform GetVolumeType() const override;
Country GetCountry() const override;
BlobType GetBlobType() const override;
u64 GetSize() const override;
u64 GetRawSize() const override;
@ -73,12 +77,12 @@ private:
static const size_t BNR1_SIZE = sizeof(GCBanner) - sizeof(GCBannerInformation) * 5;
static const size_t BNR2_SIZE = sizeof(GCBanner);
mutable std::map<ELanguage, std::string> m_short_names;
mutable std::map<Language, std::string> m_short_names;
mutable std::map<ELanguage, std::string> m_long_names;
mutable std::map<ELanguage, std::string> m_short_makers;
mutable std::map<ELanguage, std::string> m_long_makers;
mutable std::map<ELanguage, std::string> m_descriptions;
mutable std::map<Language, std::string> m_long_names;
mutable std::map<Language, std::string> m_short_makers;
mutable std::map<Language, std::string> m_long_makers;
mutable std::map<Language, std::string> m_descriptions;
mutable bool m_banner_loaded = false;
mutable std::vector<u32> m_image_buffer;

View File

@ -16,6 +16,7 @@
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeWad.h"
@ -54,10 +55,10 @@ bool CVolumeWAD::Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) cons
return m_pReader->Read(_Offset, _Length, _pBuffer);
}
IVolume::ECountry CVolumeWAD::GetCountry() const
Country CVolumeWAD::GetCountry() const
{
if (!m_pReader)
return COUNTRY_UNKNOWN;
return Country::COUNTRY_UNKNOWN;
// read the last digit of the titleID in the ticket
u8 country_code;
@ -114,16 +115,16 @@ u16 CVolumeWAD::GetRevision() const
return Common::swap16(revision);
}
IVolume::EPlatform CVolumeWAD::GetVolumeType() const
Platform CVolumeWAD::GetVolumeType() const
{
return WII_WAD;
return Platform::WII_WAD;
}
std::map<IVolume::ELanguage, std::string> CVolumeWAD::GetLongNames() const
std::map<Language, std::string> CVolumeWAD::GetLongNames() const
{
std::vector<u8> name_data(NAMES_TOTAL_BYTES);
if (!Read(m_opening_bnr_offset + 0x9C, NAMES_TOTAL_BYTES, name_data.data()))
return std::map<IVolume::ELanguage, std::string>();
return std::map<Language, std::string>();
return ReadWiiNames(name_data);
}

View File

@ -10,7 +10,6 @@
#include <vector>
#include "Common/CommonTypes.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Volume.h"
// --- this volume type is used for Wad files ---
@ -19,6 +18,11 @@
namespace DiscIO
{
enum class BlobType;
enum class Country;
enum class Language;
enum class Platform;
class CVolumeWAD : public IVolume
{
public:
@ -30,12 +34,12 @@ public:
std::string GetMakerID() const override;
u16 GetRevision() const override;
std::string GetInternalName() const override { return ""; }
std::map<IVolume::ELanguage, std::string> GetLongNames() const override;
std::map<Language, std::string> GetLongNames() const override;
std::vector<u32> GetBanner(int* width, int* height) const override;
u64 GetFSTSize() const override { return 0; }
std::string GetApploaderDate() const override { return ""; }
EPlatform GetVolumeType() const override;
ECountry GetCountry() const override;
Platform GetVolumeType() const override;
Country GetCountry() const override;
BlobType GetBlobType() const override;
u64 GetSize() const override;

View File

@ -17,6 +17,7 @@
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "DiscIO/FileMonitor.h"
#include "DiscIO/Filesystem.h"
#include "DiscIO/Volume.h"
@ -152,53 +153,49 @@ std::string CVolumeWiiCrypted::GetUniqueID() const
return DecodeString(ID);
}
IVolume::ECountry CVolumeWiiCrypted::GetCountry() const
Country CVolumeWiiCrypted::GetCountry() const
{
if (!m_pReader)
return COUNTRY_UNKNOWN;
return Country::COUNTRY_UNKNOWN;
u8 country_byte;
if (!m_pReader->Read(3, 1, &country_byte))
{
return COUNTRY_UNKNOWN;
}
return Country::COUNTRY_UNKNOWN;
IVolume::ECountry country_value = CountrySwitch(country_byte);
Country country_value = CountrySwitch(country_byte);
u32 region_code;
if (!ReadSwapped(0x4E000, &region_code, false))
{
return country_value;
}
switch (region_code)
{
case 0:
switch (country_value)
{
case IVolume::COUNTRY_TAIWAN:
return IVolume::COUNTRY_TAIWAN;
case Country::COUNTRY_TAIWAN:
return Country::COUNTRY_TAIWAN;
default:
return IVolume::COUNTRY_JAPAN;
return Country::COUNTRY_JAPAN;
}
case 1:
return IVolume::COUNTRY_USA;
return Country::COUNTRY_USA;
case 2:
switch (country_value)
{
case IVolume::COUNTRY_FRANCE:
case IVolume::COUNTRY_GERMANY:
case IVolume::COUNTRY_ITALY:
case IVolume::COUNTRY_NETHERLANDS:
case IVolume::COUNTRY_RUSSIA:
case IVolume::COUNTRY_SPAIN:
case IVolume::COUNTRY_AUSTRALIA:
case Country::COUNTRY_FRANCE:
case Country::COUNTRY_GERMANY:
case Country::COUNTRY_ITALY:
case Country::COUNTRY_NETHERLANDS:
case Country::COUNTRY_RUSSIA:
case Country::COUNTRY_SPAIN:
case Country::COUNTRY_AUSTRALIA:
return country_value;
default:
return IVolume::COUNTRY_EUROPE;
return Country::COUNTRY_EUROPE;
}
case 4:
return IVolume::COUNTRY_KOREA;
return Country::COUNTRY_KOREA;
default:
return country_value;
}
@ -238,12 +235,12 @@ std::string CVolumeWiiCrypted::GetInternalName() const
return "";
}
std::map<IVolume::ELanguage, std::string> CVolumeWiiCrypted::GetLongNames() const
std::map<Language, std::string> CVolumeWiiCrypted::GetLongNames() const
{
std::unique_ptr<IFileSystem> file_system(CreateFileSystem(this));
std::vector<u8> opening_bnr(NAMES_TOTAL_BYTES);
opening_bnr.resize(
file_system->ReadFile("opening.bnr", opening_bnr.data(), opening_bnr.size(), 0x5C));
size_t size = file_system->ReadFile("opening.bnr", opening_bnr.data(), opening_bnr.size(), 0x5C);
opening_bnr.resize(size);
return ReadWiiNames(opening_bnr);
}
@ -285,9 +282,9 @@ std::string CVolumeWiiCrypted::GetApploaderDate() const
return DecodeString(date);
}
IVolume::EPlatform CVolumeWiiCrypted::GetVolumeType() const
Platform CVolumeWiiCrypted::GetVolumeType() const
{
return WII_DISC;
return Platform::WII_DISC;
}
u8 CVolumeWiiCrypted::GetDiscNumber() const

View File

@ -11,13 +11,17 @@
#include <vector>
#include "Common/CommonTypes.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Volume.h"
// --- this volume type is used for encrypted Wii images ---
namespace DiscIO
{
enum class BlobType;
enum class Country;
enum class Language;
enum class Platform;
class CVolumeWiiCrypted : public IVolume
{
public:
@ -31,18 +35,18 @@ public:
std::string GetMakerID() const override;
u16 GetRevision() const override;
std::string GetInternalName() const override;
std::map<IVolume::ELanguage, std::string> GetLongNames() const override;
std::map<Language, std::string> GetLongNames() const override;
std::vector<u32> GetBanner(int* width, int* height) const override;
u64 GetFSTSize() const override;
std::string GetApploaderDate() const override;
u8 GetDiscNumber() const override;
EPlatform GetVolumeType() const override;
Platform GetVolumeType() const override;
bool SupportsIntegrityCheck() const override { return true; }
bool CheckIntegrity() const override;
bool ChangePartition(u64 offset) override;
ECountry GetCountry() const override;
Country GetCountry() const override;
BlobType GetBlobType() const override;
u64 GetSize() const override;
u64 GetRawSize() const override;