2022-12-04 11:03:45 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
|
|
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
|
|
|
2019-12-06 06:23:08 +00:00
|
|
|
#pragma once
|
|
|
|
#include "cd_image.h"
|
2022-07-08 12:43:38 +00:00
|
|
|
#include "common/types.h"
|
2019-12-06 06:23:08 +00:00
|
|
|
#include <array>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
class CDSubChannelReplacement
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CDSubChannelReplacement();
|
|
|
|
~CDSubChannelReplacement();
|
|
|
|
|
|
|
|
u32 GetReplacementSectorCount() const { return static_cast<u32>(m_replacement_subq.size()); }
|
|
|
|
|
|
|
|
bool LoadSBI(const char* path);
|
2021-04-24 06:03:28 +00:00
|
|
|
bool LoadSBIFromImagePath(const char* image_path);
|
2019-12-06 06:23:08 +00:00
|
|
|
|
2020-07-21 14:02:44 +00:00
|
|
|
/// Adds a sector to the replacement map.
|
|
|
|
void AddReplacementSubChannelQ(u32 lba, const CDImage::SubChannelQ& subq);
|
|
|
|
|
2019-12-06 06:23:08 +00:00
|
|
|
/// Returns the replacement subchannel data for the specified position (in BCD).
|
2020-07-21 14:02:44 +00:00
|
|
|
bool GetReplacementSubChannelQ(u8 minute_bcd, u8 second_bcd, u8 frame_bcd, CDImage::SubChannelQ* subq) const;
|
2019-12-06 06:23:08 +00:00
|
|
|
|
|
|
|
/// Returns the replacement subchannel data for the specified sector.
|
2020-07-21 14:02:44 +00:00
|
|
|
bool GetReplacementSubChannelQ(u32 lba, CDImage::SubChannelQ* subq) const;
|
2019-12-06 06:23:08 +00:00
|
|
|
|
|
|
|
private:
|
2020-07-21 14:02:44 +00:00
|
|
|
using ReplacementMap = std::unordered_map<u32, CDImage::SubChannelQ>;
|
2019-12-06 06:23:08 +00:00
|
|
|
|
2020-06-23 09:04:16 +00:00
|
|
|
ReplacementMap m_replacement_subq;
|
2019-12-06 06:23:08 +00:00
|
|
|
};
|