mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-21 21:35:38 +00:00
CDImage: Support reading MODE1 sectors
This commit is contained in:
parent
e7e0b03a70
commit
655fdf8061
|
@ -267,9 +267,26 @@ u32 CDImage::Read(ReadMode read_mode, u32 sector_count, void* buffer)
|
|||
switch (read_mode)
|
||||
{
|
||||
case ReadMode::DataOnly:
|
||||
std::memcpy(buffer_ptr, raw_sector + 24, DATA_SECTOR_SIZE);
|
||||
{
|
||||
const SectorHeader* header = reinterpret_cast<const SectorHeader*>(raw_sector + SECTOR_SYNC_SIZE);
|
||||
if (header->sector_mode == 1)
|
||||
{
|
||||
std::memcpy(buffer_ptr, raw_sector + SECTOR_SYNC_SIZE + MODE1_HEADER_SIZE, DATA_SECTOR_SIZE);
|
||||
}
|
||||
else if (header->sector_mode == 2)
|
||||
{
|
||||
std::memcpy(buffer_ptr, raw_sector + SECTOR_SYNC_SIZE + MODE2_HEADER_SIZE, DATA_SECTOR_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG("Invalid sector mode {} at LBA {}", header->sector_mode,
|
||||
m_current_index->start_lba_on_disc + m_position_in_track);
|
||||
break;
|
||||
}
|
||||
|
||||
buffer_ptr += DATA_SECTOR_SIZE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ReadMode::RawNoSync:
|
||||
std::memcpy(buffer_ptr, raw_sector + SECTOR_SYNC_SIZE, RAW_SECTOR_SIZE - SECTOR_SYNC_SIZE);
|
||||
|
|
|
@ -30,6 +30,8 @@ public:
|
|||
DATA_SECTOR_SIZE = 2048,
|
||||
SECTOR_SYNC_SIZE = 12,
|
||||
SECTOR_HEADER_SIZE = 4,
|
||||
MODE1_HEADER_SIZE = 4,
|
||||
MODE2_HEADER_SIZE = 12,
|
||||
FRAMES_PER_SECOND = 75, // "sectors", or "timecode frames" (not "channel frames")
|
||||
SECONDS_PER_MINUTE = 60,
|
||||
FRAMES_PER_MINUTE = FRAMES_PER_SECOND * SECONDS_PER_MINUTE,
|
||||
|
|
Loading…
Reference in a new issue