mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 22:05:38 +00:00
CDROM: Implement GetTN command
This commit is contained in:
parent
baf97cb864
commit
4959de9859
|
@ -24,7 +24,7 @@ std::unique_ptr<CDImage> CDImage::Open(const char* filename)
|
|||
|
||||
if (CASE_COMPARE(extension, ".cue") == 0)
|
||||
return OpenCueSheetImage(filename);
|
||||
else if (CASE_COMPARE(extension, ".bin") == 0)
|
||||
else if (CASE_COMPARE(extension, ".bin") == 0 || CASE_COMPARE(extension, ".img") == 0)
|
||||
return OpenBinImage(filename);
|
||||
|
||||
#undef CASE_COMPARE
|
||||
|
|
|
@ -90,7 +90,9 @@ public:
|
|||
LBA GetPositionInTrack() const { return m_position_in_track; }
|
||||
Position GetMSFPositionInTrack() const { return Position::FromLBA(m_position_in_track); }
|
||||
LBA GetLBACount() const { return m_lba_count; }
|
||||
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()); }
|
||||
|
||||
// Seek to data LBA.
|
||||
bool Seek(LBA lba);
|
||||
|
@ -120,6 +122,7 @@ protected:
|
|||
u32 file_sector_size;
|
||||
LBA start_lba_on_disc;
|
||||
u32 track_number;
|
||||
u32 index_number;
|
||||
LBA start_lba_in_track;
|
||||
u32 length;
|
||||
bool is_pregap;
|
||||
|
|
|
@ -48,6 +48,7 @@ bool CDImageBin::Open(const char* filename)
|
|||
pregap_index.start_lba_in_track = static_cast<LBA>(-static_cast<s32>(pregap_frames));
|
||||
pregap_index.length = pregap_frames;
|
||||
pregap_index.track_number = 1;
|
||||
pregap_index.index_number = 0;
|
||||
pregap_index.is_pregap = true;
|
||||
m_indices.push_back(pregap_index);
|
||||
|
||||
|
@ -58,6 +59,7 @@ bool CDImageBin::Open(const char* filename)
|
|||
data_index.file_sector_size = track_sector_size;
|
||||
data_index.start_lba_on_disc = pregap_index.length;
|
||||
data_index.track_number = 1;
|
||||
data_index.index_number = 1;
|
||||
data_index.start_lba_in_track = 0;
|
||||
data_index.length = m_lba_count;
|
||||
m_indices.push_back(data_index);
|
||||
|
|
|
@ -118,6 +118,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename)
|
|||
pregap_index.start_lba_in_track = static_cast<LBA>(static_cast<unsigned long>(-pregap_frames));
|
||||
pregap_index.length = pregap_frames;
|
||||
pregap_index.track_number = track_num;
|
||||
pregap_index.index_number = 0;
|
||||
pregap_index.is_pregap = true;
|
||||
m_indices.push_back(pregap_index);
|
||||
|
||||
|
@ -132,6 +133,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename)
|
|||
Index last_index;
|
||||
last_index.start_lba_on_disc = disc_lba;
|
||||
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;
|
||||
|
@ -156,6 +158,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename)
|
|||
}
|
||||
|
||||
last_index.file_offset = index_offset * last_index.file_sector_size;
|
||||
last_index.index_number = static_cast<u32>(index_num);
|
||||
last_index_offset = index_offset;
|
||||
}
|
||||
|
||||
|
|
|
@ -407,6 +407,13 @@ void CDROM::PushStatResponse(Interrupt interrupt /*= Interrupt::ACK*/)
|
|||
SetInterrupt(interrupt);
|
||||
}
|
||||
|
||||
void CDROM::SendErrorResponse(u8 reason /*= 0x80*/)
|
||||
{
|
||||
m_response_fifo.Push(m_secondary_status.bits | 0x01);
|
||||
m_response_fifo.Push(reason);
|
||||
SetInterrupt(Interrupt::INT5);
|
||||
}
|
||||
|
||||
void CDROM::UpdateStatusRegister()
|
||||
{
|
||||
m_status.ADPBUSY = false;
|
||||
|
@ -755,6 +762,25 @@ void CDROM::ExecuteCommand()
|
|||
}
|
||||
break;
|
||||
|
||||
case Command::GetTN:
|
||||
{
|
||||
Log_DebugPrintf("CDROM GetTN command");
|
||||
if (m_media)
|
||||
{
|
||||
m_response_fifo.Push(m_secondary_status.bits);
|
||||
m_response_fifo.Push(DecimalToBCD(Truncate8(m_media->GetTrackNumber())));
|
||||
m_response_fifo.Push(DecimalToBCD(Truncate8(m_media->GetTrackCount())));
|
||||
SetInterrupt(Interrupt::ACK);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendErrorResponse(0x80);
|
||||
}
|
||||
|
||||
EndCommand();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Panic("Unknown command");
|
||||
break;
|
||||
|
|
|
@ -170,6 +170,7 @@ private:
|
|||
bool HasPendingInterrupt() const { return m_interrupt_flag_register != 0; }
|
||||
void SetInterrupt(Interrupt interrupt);
|
||||
void PushStatResponse(Interrupt interrupt = Interrupt::ACK);
|
||||
void SendErrorResponse(u8 reason = 0x80);
|
||||
void UpdateStatusRegister();
|
||||
|
||||
u32 GetAckDelayForCommand() const;
|
||||
|
|
Loading…
Reference in a new issue