CDImage: Add helper for checking for SBI

This commit is contained in:
Connor McLaughlin 2020-12-18 03:01:57 +10:00
parent 4232ef7bf3
commit 627008f34c
6 changed files with 32 additions and 0 deletions

View file

@ -255,6 +255,11 @@ bool CDImage::ReadSubChannelQ(SubChannelQ* subq)
return true;
}
bool CDImage::HasNonStandardSubchannel() const
{
return false;
}
const CDImage::Index* CDImage::GetIndexForDiscPosition(LBA pos)
{
for (const Index& index : m_indices)

View file

@ -242,6 +242,9 @@ public:
// Reads sub-channel Q for the current LBA.
virtual bool ReadSubChannelQ(SubChannelQ* subq);
// Returns true if the image has replacement subchannel data.
virtual bool HasNonStandardSubchannel() const;
// Reads a single sector from an index.
virtual bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) = 0;

View file

@ -14,6 +14,7 @@ public:
bool Open(const char* filename);
bool ReadSubChannelQ(SubChannelQ* subq) override;
bool HasNonStandardSubchannel() const override;
protected:
bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override;
@ -103,6 +104,11 @@ bool CDImageBin::ReadSubChannelQ(SubChannelQ* subq)
return CDImage::ReadSubChannelQ(subq);
}
bool CDImageBin::HasNonStandardSubchannel() const
{
return (m_sbi.GetReplacementSectorCount() > 0);
}
bool CDImageBin::ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index)
{
const u64 file_position = index.file_offset + (static_cast<u64>(lba_in_index) * index.file_sector_size);

View file

@ -49,6 +49,7 @@ public:
bool Open(const char* filename);
bool ReadSubChannelQ(SubChannelQ* subq) override;
bool HasNonStandardSubchannel() const override;
protected:
bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override;
@ -262,6 +263,11 @@ bool CDImageCHD::ReadSubChannelQ(SubChannelQ* subq)
return CDImage::ReadSubChannelQ(subq);
}
bool CDImageCHD::HasNonStandardSubchannel() const
{
return (m_sbi.GetReplacementSectorCount() > 0);
}
// There's probably a more efficient way of doing this with vectorization...
ALWAYS_INLINE static void CopyAndSwap(void* dst_ptr, const u8* src_ptr, u32 data_size)
{

View file

@ -18,6 +18,7 @@ public:
bool OpenAndParse(const char* filename);
bool ReadSubChannelQ(SubChannelQ* subq) override;
bool HasNonStandardSubchannel() const override;
protected:
bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override;
@ -258,6 +259,11 @@ bool CDImageCueSheet::ReadSubChannelQ(SubChannelQ* subq)
return CDImage::ReadSubChannelQ(subq);
}
bool CDImageCueSheet::HasNonStandardSubchannel() const
{
return (m_sbi.GetReplacementSectorCount() > 0);
}
bool CDImageCueSheet::ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index)
{
DebugAssert(index.file_index < m_files.size());

View file

@ -18,6 +18,7 @@ public:
bool CopyImage(CDImage* image, ProgressCallback* progress);
bool ReadSubChannelQ(SubChannelQ* subq) override;
bool HasNonStandardSubchannel() const override;
protected:
bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override;
@ -123,6 +124,11 @@ bool CDImageMemory::ReadSubChannelQ(SubChannelQ* subq)
return CDImage::ReadSubChannelQ(subq);
}
bool CDImageMemory::HasNonStandardSubchannel() const
{
return (m_sbi.GetReplacementSectorCount() > 0);
}
bool CDImageMemory::ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index)
{
DebugAssert(index.file_index == 0);