VolumeGC.h 3.4 KB

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