CDROM: Implement motor on command

This commit is contained in:
Connor McLaughlin 2019-10-28 17:25:04 +10:00
parent c15822d745
commit a1ed2d1d77
2 changed files with 33 additions and 11 deletions

View file

@ -512,8 +512,8 @@ void CDROM::Execute(TickCount ticks)
{
switch (m_drive_state)
{
case DriveState::Initializing:
DoInitComplete();
case DriveState::SpinningUp:
DoSpinUpComplete();
break;
case DriveState::Seeking:
@ -750,8 +750,11 @@ void CDROM::ExecuteCommand()
Log_DebugPrintf("CDROM init command");
SendACKAndStat();
m_drive_state = DriveState::Initializing;
m_drive_remaining_ticks = 8000;
m_secondary_status.ClearActiveBits();
m_mode.bits = 0;
m_drive_state = DriveState::SpinningUp;
m_drive_remaining_ticks = 80000;
m_system->SetDowncount(m_drive_remaining_ticks);
EndCommand();
@ -759,6 +762,27 @@ void CDROM::ExecuteCommand()
}
break;
case Command::MotorOn:
{
Log_DebugPrintf("CDROM motor on command");
if (m_secondary_status.motor_on)
{
SendErrorResponse(0x20);
}
else
{
SendACKAndStat();
m_drive_state = DriveState::SpinningUp;
m_drive_remaining_ticks = 80000;
m_system->SetDowncount(m_drive_remaining_ticks);
}
EndCommand();
return;
}
break;
case Command::Mute:
{
Log_DebugPrintf("CDROM mute command");
@ -945,12 +969,10 @@ void CDROM::BeginSeeking()
m_system->SetDowncount(m_drive_remaining_ticks);
}
void CDROM::DoInitComplete()
void CDROM::DoSpinUpComplete()
{
m_drive_state = DriveState::Idle;
m_mode.bits = 0;
m_secondary_status.bits = 0;
m_secondary_status.motor_on = true;
m_async_response_fifo.Clear();
@ -1326,7 +1348,7 @@ void CDROM::DrawDebugWindow()
if (ImGui::CollapsingHeader("Status/Mode", ImGuiTreeNodeFlags_DefaultOpen))
{
static constexpr std::array<const char*, 8> drive_state_names = {
{"Idle", "Initializing", "Seeking", "Reading ID", "Reading", "Playing", "Pausing", "Stopping"}};
{"Idle", "Spinning Up", "Seeking", "Reading ID", "Reading", "Playing", "Pausing", "Stopping"}};
ImGui::Columns(3);

View file

@ -109,13 +109,13 @@ private:
enum class DriveState : u8
{
Idle,
Initializing,
SpinningUp,
Seeking,
ReadingID,
Reading,
Playing,
Pausing,
Stopping,
Stopping
};
union StatusRegister
@ -195,7 +195,7 @@ private:
void ExecuteCommand();
void ExecuteTestCommand(u8 subcommand);
void BeginReading(bool cdda);
void DoInitComplete();
void DoSpinUpComplete();
void DoSeekComplete();
void DoPauseComplete();
void DoStopComplete();