DVDInterface: Remove s_disc_inside
There's no point in having a variable for whether there is a disc when it's simpler to just directly check whether there is a disc.
This commit is contained in:
parent
740e4d0992
commit
900793ef1d
|
@ -244,7 +244,6 @@ static u32 s_pending_samples;
|
||||||
|
|
||||||
// Disc drive state
|
// Disc drive state
|
||||||
static u32 s_error_code = 0;
|
static u32 s_error_code = 0;
|
||||||
static bool s_disc_inside = false;
|
|
||||||
|
|
||||||
// Disc drive timing
|
// Disc drive timing
|
||||||
static u64 s_read_buffer_start_time;
|
static u64 s_read_buffer_start_time;
|
||||||
|
@ -283,6 +282,8 @@ u64 CalculateRawDiscReadTime(u64 offset, u64 length);
|
||||||
|
|
||||||
void DoState(PointerWrap& p)
|
void DoState(PointerWrap& p)
|
||||||
{
|
{
|
||||||
|
bool disc_inside = IsDiscInside();
|
||||||
|
|
||||||
p.DoPOD(s_DISR);
|
p.DoPOD(s_DISR);
|
||||||
p.DoPOD(s_DICVR);
|
p.DoPOD(s_DICVR);
|
||||||
p.DoArray(s_DICMDBUF);
|
p.DoArray(s_DICMDBUF);
|
||||||
|
@ -302,7 +303,7 @@ void DoState(PointerWrap& p)
|
||||||
p.Do(s_pending_samples);
|
p.Do(s_pending_samples);
|
||||||
|
|
||||||
p.Do(s_error_code);
|
p.Do(s_error_code);
|
||||||
p.Do(s_disc_inside);
|
p.Do(disc_inside);
|
||||||
|
|
||||||
p.Do(s_read_buffer_start_time);
|
p.Do(s_read_buffer_start_time);
|
||||||
p.Do(s_read_buffer_end_time);
|
p.Do(s_read_buffer_end_time);
|
||||||
|
@ -314,13 +315,13 @@ void DoState(PointerWrap& p)
|
||||||
DVDThread::DoState(p);
|
DVDThread::DoState(p);
|
||||||
|
|
||||||
// s_inserted_volume isn't savestated (because it points to
|
// s_inserted_volume isn't savestated (because it points to
|
||||||
// files on the local system). Instead, we check that
|
// files on the local system). Instead, we check that the
|
||||||
// s_disc_inside matches the status of s_inserted_volume.
|
// savestated disc_inside matches our IsDiscInside(). This
|
||||||
// This won't catch cases of having the wrong disc inserted, though.
|
// won't catch cases of having the wrong disc inserted, though.
|
||||||
// TODO: Check the game ID, disc number, revision?
|
// TODO: Check the game ID, disc number, revision?
|
||||||
if (s_disc_inside != (s_inserted_volume != nullptr))
|
if (disc_inside != IsDiscInside())
|
||||||
{
|
{
|
||||||
if (s_disc_inside)
|
if (disc_inside)
|
||||||
PanicAlertT("An inserted disc was expected but not found.");
|
PanicAlertT("An inserted disc was expected but not found.");
|
||||||
else
|
else
|
||||||
s_inserted_volume.reset();
|
s_inserted_volume.reset();
|
||||||
|
@ -425,7 +426,6 @@ void Init()
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
s_DICVR.Hex = 1; // Disc Channel relies on cover being open when no disc is inserted
|
s_DICVR.Hex = 1; // Disc Channel relies on cover being open when no disc is inserted
|
||||||
s_disc_inside = false;
|
|
||||||
|
|
||||||
s_eject_disc = CoreTiming::RegisterEvent("EjectDisc", EjectDiscCallback);
|
s_eject_disc = CoreTiming::RegisterEvent("EjectDisc", EjectDiscCallback);
|
||||||
s_insert_disc = CoreTiming::RegisterEvent("InsertDisc", InsertDiscCallback);
|
s_insert_disc = CoreTiming::RegisterEvent("InsertDisc", InsertDiscCallback);
|
||||||
|
@ -508,12 +508,11 @@ bool VolumeIsValid()
|
||||||
void SetDiscInside(bool disc_inside)
|
void SetDiscInside(bool disc_inside)
|
||||||
{
|
{
|
||||||
SetLidOpen(!disc_inside);
|
SetLidOpen(!disc_inside);
|
||||||
s_disc_inside = disc_inside;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsDiscInside()
|
bool IsDiscInside()
|
||||||
{
|
{
|
||||||
return s_disc_inside;
|
return s_inserted_volume != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take care of all logic of "swapping discs"
|
// Take care of all logic of "swapping discs"
|
||||||
|
@ -702,7 +701,7 @@ void WriteImmediate(u32 value, u32 output_address, bool reply_to_ios)
|
||||||
bool ExecuteReadCommand(u64 DVD_offset, u32 output_address, u32 DVD_length, u32 output_length,
|
bool ExecuteReadCommand(u64 DVD_offset, u32 output_address, u32 DVD_length, u32 output_length,
|
||||||
bool decrypt, ReplyType reply_type, DIInterruptType* interrupt_type)
|
bool decrypt, ReplyType reply_type, DIInterruptType* interrupt_type)
|
||||||
{
|
{
|
||||||
if (!s_disc_inside)
|
if (!IsDiscInside())
|
||||||
{
|
{
|
||||||
// Disc read fails
|
// Disc read fails
|
||||||
s_error_code = ERROR_NO_DISK | ERROR_COVER_H;
|
s_error_code = ERROR_NO_DISK | ERROR_COVER_H;
|
||||||
|
@ -817,8 +816,8 @@ void ExecuteCommand(u32 command_0, u32 command_1, u32 command_2, u32 output_addr
|
||||||
|
|
||||||
// Probably only used by Wii
|
// Probably only used by Wii
|
||||||
case DVDLowGetCoverStatus:
|
case DVDLowGetCoverStatus:
|
||||||
WriteImmediate(s_disc_inside ? 2 : 1, output_address, reply_to_ios);
|
WriteImmediate(IsDiscInside() ? 2 : 1, output_address, reply_to_ios);
|
||||||
INFO_LOG(DVDINTERFACE, "DVDLowGetCoverStatus: Disc %sInserted", s_disc_inside ? "" : "Not ");
|
INFO_LOG(DVDINTERFACE, "DVDLowGetCoverStatus: Disc %sInserted", IsDiscInside() ? "" : "Not ");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Probably only used by Wii
|
// Probably only used by Wii
|
||||||
|
|
Loading…
Reference in New Issue