Debian Codegraph @

Source/Core/DiscIO/VolumeGC.h

raw symbols SCIP
1 // Copyright 2008 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <map>
7 #include <memory>
8 #include <optional>
9 #include <string>
10 #include <vector>
11
12 #include "Common/CommonTypes.h"
13 #include "Common/Lazy.h"
14 #include "DiscIO/Filesystem.h"
15 #include "DiscIO/Volume.h"
16 #include "DiscIO/VolumeDisc.h"
17
18 namespace DiscIO
19 {
20 class BlobReader;
21 enum class BlobType;
22 enum class Country;
23 class FileSystem;
24 enum class Language;
25 enum class Region;
26 enum class Platform;
27
28 class VolumeGC final : public VolumeDisc
29 {
30 public:
31 VolumeGC(std::unique_ptr<BlobReader> reader);
32 ~VolumeGC() override;
33 bool Read(u64 offset, u64 length, u8* buffer,
34 const Partition& partition = PARTITION_NONE) const override;
35 const FileSystem* GetFileSystem(const Partition& partition = PARTITION_NONE) const override;
36 std::string GetGameTDBID(const Partition& partition = PARTITION_NONE) const override;
37 std::map<Language, std::string> GetShortNames() const override;
38 std::map<Language, std::string> GetLongNames() const override;
39 std::map<Language, std::string> GetShortMakers() const override;
40 std::map<Language, std::string> GetLongMakers() const override;
41 std::map<Language, std::string> GetDescriptions() const override;
42 std::vector<u32> GetBanner(u32* width, u32* height) const override;
43
44 Platform GetVolumeType() const override;
45 bool IsDatelDisc() const override;
46 Region GetRegion() const override;
47 BlobType GetBlobType() const override;
48 u64 GetDataSize() const override;
49 DataSizeType GetDataSizeType() const override;
50 u64 GetRawSize() const override;
51 const BlobReader& GetBlobReader() const override;
52 std::array<u8, 20> GetSyncHash() const override;
53
54 const BootID* GetTriforceBootID() const { return &m_triforce_header; }
55
56 private:
57 static constexpr u32 GC_BANNER_WIDTH = 96;
58 static constexpr u32 GC_BANNER_HEIGHT = 32;
59
60 struct GCBannerInformation
61 {
62 char short_name[32]; // Short game title shown in IPL menu
63 char short_maker[32]; // Short developer, publisher names shown in IPL menu
64 char long_name[64]; // Long game title shown in IPL game start screen
65 char long_maker[64]; // Long developer, publisher names shown in IPL game
66 // start screen
67 char description[128]; // Game description shown in IPL game start screen in
68 // two lines.
69 };
70
71 struct GCBanner
72 {
73 u32 id; // "BNR1" for NTSC, "BNR2" for PAL
74 u32 padding[7];
75 u16 image[GC_BANNER_WIDTH * GC_BANNER_HEIGHT]; // RGB5A3 96x32 image
76 GCBannerInformation information[6]; // information comes in six languages
77 // (only one for BNR1 type)
78 };
79
80 struct ConvertedGCBanner
81 {
82 ConvertedGCBanner();
83 ~ConvertedGCBanner();
84
85 std::map<Language, std::string> short_names;
86 std::map<Language, std::string> long_names;
87 std::map<Language, std::string> short_makers;
88 std::map<Language, std::string> long_makers;
89 std::map<Language, std::string> descriptions;
90
91 std::vector<u32> image_buffer;
92 u32 image_height = 0;
93 u32 image_width = 0;
94 };
95
96 ConvertedGCBanner LoadBannerFile() const;
97 ConvertedGCBanner ExtractBannerInformation(const GCBanner& banner_file, bool is_bnr1) const;
98
99 static constexpr size_t BNR1_SIZE = sizeof(GCBanner) - sizeof(GCBannerInformation) * 5;
100 static constexpr size_t BNR2_SIZE = sizeof(GCBanner);
101
102 Common::Lazy<ConvertedGCBanner> m_converted_banner;
103
104 Common::Lazy<std::unique_ptr<FileSystem>> m_file_system;
105
106 std::unique_ptr<BlobReader> m_reader;
107
108 BootID m_triforce_header;
109
110 bool m_is_triforce;
111 };
112
113 } // namespace DiscIO