CDROM: Implement GetTD command
This commit is contained in:
parent
4959de9859
commit
9433e08782
|
@ -33,6 +33,18 @@ std::unique_ptr<CDImage> CDImage::Open(const char* filename)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
CDImage::LBA CDImage::GetTrackStartPosition(u8 track) const
|
||||
{
|
||||
Assert(track > 0 && track <= m_tracks.size());
|
||||
return m_tracks[track - 1].start_lba;
|
||||
}
|
||||
|
||||
CDImage::Position CDImage::GetTrackStartMSFPosition(u8 track) const
|
||||
{
|
||||
Assert(track > 0 && track <= m_tracks.size());
|
||||
return Position::FromLBA(m_tracks[track - 1].start_lba);
|
||||
}
|
||||
|
||||
bool CDImage::Seek(LBA lba)
|
||||
{
|
||||
const Index* new_index;
|
||||
|
|
|
@ -93,6 +93,8 @@ public:
|
|||
u32 GetIndexNumber() const { return m_current_index->index_number; }
|
||||
u32 GetTrackNumber() const { return m_current_index->track_number; }
|
||||
u32 GetTrackCount() const { return static_cast<u32>(m_tracks.size()); }
|
||||
LBA GetTrackStartPosition(u8 track) const;
|
||||
Position GetTrackStartMSFPosition(u8 track) const;
|
||||
|
||||
// Seek to data LBA.
|
||||
bool Seek(LBA lba);
|
||||
|
|
|
@ -132,11 +132,13 @@ bool CDImageCueSheet::OpenAndParse(const char* filename)
|
|||
// how many indices in this track?
|
||||
Index last_index;
|
||||
last_index.start_lba_on_disc = disc_lba;
|
||||
last_index.start_lba_in_track = 0;
|
||||
last_index.track_number = track_num;
|
||||
last_index.index_number = 1;
|
||||
last_index.file = it->second;
|
||||
last_index.file_sector_size = track_sector_size;
|
||||
last_index.file_offset = 0;
|
||||
last_index.is_pregap = false;
|
||||
|
||||
long last_index_offset = track_start;
|
||||
for (int index_num = 1;; index_num++)
|
||||
|
|
|
@ -628,7 +628,7 @@ void CDROM::ExecuteCommand()
|
|||
{
|
||||
const u8 file = m_param_fifo.Peek(0);
|
||||
const u8 channel = m_param_fifo.Peek(1);
|
||||
Log_WarningPrintf("CDROM setfilter command 0x%02X 0x%02X", ZeroExtend32(file), ZeroExtend32(channel));
|
||||
Log_DebugPrintf("CDROM setfilter command 0x%02X 0x%02X", ZeroExtend32(file), ZeroExtend32(channel));
|
||||
m_filter_file_number = file;
|
||||
m_filter_channel_number = channel;
|
||||
PushStatResponse(Interrupt::ACK);
|
||||
|
@ -781,6 +781,38 @@ void CDROM::ExecuteCommand()
|
|||
}
|
||||
break;
|
||||
|
||||
case Command::GetTD:
|
||||
{
|
||||
Log_DebugPrintf("CDROM GetTD command");
|
||||
Assert(m_param_fifo.GetSize() >= 1);
|
||||
const u8 track = BCDToDecimal(m_param_fifo.Peek());
|
||||
|
||||
if (!m_media)
|
||||
{
|
||||
SendErrorResponse(0x80);
|
||||
}
|
||||
else if (track > m_media->GetTrackCount())
|
||||
{
|
||||
SendErrorResponse(0x10);
|
||||
}
|
||||
else
|
||||
{
|
||||
CDImage::Position pos;
|
||||
if (track == 0)
|
||||
pos = CDImage::Position::FromLBA(m_media->GetLBACount());
|
||||
else
|
||||
pos = m_media->GetTrackStartMSFPosition(track);
|
||||
|
||||
m_response_fifo.Push(m_secondary_status.bits);
|
||||
m_response_fifo.Push(DecimalToBCD(Truncate8(pos.minute)));
|
||||
m_response_fifo.Push(DecimalToBCD(Truncate8(pos.second)));
|
||||
SetInterrupt(Interrupt::ACK);
|
||||
}
|
||||
|
||||
EndCommand();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Panic("Unknown command");
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue