CDROM: Reads appear to be functioning

This commit is contained in:
Connor McLaughlin
2019-09-22 01:12:16 +10:00
parent c988af453c
commit 2875a22987
8 changed files with 418 additions and 66 deletions

View File

@ -9,6 +9,16 @@ public:
CDImage();
~CDImage();
enum : u32
{
RAW_SECTOR_SIZE = 2352,
DATA_SECTOR_SIZE = 2048,
SECTOR_SYNC_SIZE = 12,
FRAMES_PER_SECOND = 75, // "sectors"
SECONDS_PER_MINUTE = 60,
FRAMES_PER_MINUTE = FRAMES_PER_SECOND * SECONDS_PER_MINUTE,
};
enum class ReadMode : u32
{
DataOnly, // 2048 bytes per sector.
@ -40,16 +50,6 @@ public:
u32 Read(ReadMode read_mode, u32 sector_count, void* buffer);
private:
enum : u32
{
RAW_SECTOR_SIZE = 2352,
DATA_SECTOR_SIZE = 2048,
SECTOR_SYNC_SIZE = 12,
FRAMES_PER_SECOND = 75, // "sectors"
SECONDS_PER_MINUTE = 60,
FRAMES_PER_MINUTE = FRAMES_PER_SECOND * SECONDS_PER_MINUTE,
};
// TODO: Multiple data files from cue sheet
ByteStream* m_data_file = nullptr;

View File

@ -16,8 +16,8 @@ class FIFOQueue
public:
const T* GetDataPointer() const { return m_ptr; }
T* GetDataPointer() { return m_ptr; }
const T* GetFrontPointer() const { return m_ptr[m_head]; }
T* GetFrontPointer() { return m_ptr[m_head]; }
const T* GetFrontPointer() const { return &m_ptr[m_head]; }
T* GetFrontPointer() { return &m_ptr[m_head]; }
constexpr u32 GetCapacity() const { return CAPACITY; }
u32 GetSize() const { return m_size; }
bool IsEmpty() const { return m_size == 0; }
@ -91,6 +91,17 @@ public:
const T& Peek() const { return m_ptr[m_head]; }
const T& Peek(u32 offset) { return m_ptr[(m_head + offset) % CAPACITY]; }
void Remove(u32 count)
{
Assert(m_size >= count);
for (u32 i = 0; i < count; i++)
{
m_ptr[m_head].~T();
m_head = (m_head + 1) % CAPACITY;
m_size--;
}
}
void RemoveOne()
{
Assert(m_size > 0);