duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

cd_subchannel_replacement.h (1181B)


      1 // SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
      2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
      3 
      4 #pragma once
      5 #include "cd_image.h"
      6 #include "common/types.h"
      7 #include <array>
      8 #include <cstdio>
      9 #include <unordered_map>
     10 
     11 class CDSubChannelReplacement
     12 {
     13 public:
     14   CDSubChannelReplacement();
     15   ~CDSubChannelReplacement();
     16 
     17   u32 GetReplacementSectorCount() const { return static_cast<u32>(m_replacement_subq.size()); }
     18 
     19   bool LoadFromImagePath(std::string_view image_path);
     20 
     21   /// Adds a sector to the replacement map.
     22   void AddReplacementSubChannelQ(u32 lba, const CDImage::SubChannelQ& subq);
     23 
     24   /// Returns the replacement subchannel data for the specified position (in BCD).
     25   bool GetReplacementSubChannelQ(u8 minute_bcd, u8 second_bcd, u8 frame_bcd, CDImage::SubChannelQ* subq) const;
     26 
     27   /// Returns the replacement subchannel data for the specified sector.
     28   bool GetReplacementSubChannelQ(u32 lba, CDImage::SubChannelQ* subq) const;
     29 
     30 private:
     31   using ReplacementMap = std::unordered_map<u32, CDImage::SubChannelQ>;
     32 
     33   bool LoadSBI(const std::string& path);
     34   bool LoadLSD(const std::string& path);
     35 
     36   ReplacementMap m_replacement_subq;
     37 };