Skip to content

Commit

Permalink
gdrom: don't rely on Status in libGDR_GetDiscType
Browse files Browse the repository at this point in the history
Status is Busy when disk swapping is in progress so libGDR_GetDiscType
always returns NoDisk/Open. Rely on the scheduler instead so that the
correct type is returned when disk swapping is finished.
Issue #1046
Issue #189
  • Loading branch information
flyinghead committed Jan 25, 2024
1 parent 10d3ffd commit 116dc0e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/imgread/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ void libGDR_ReadSubChannel(u8 * buff, u32 len)

u32 libGDR_GetDiscType()
{
if (SecNumber.Status != GD_BUSY && disc != nullptr)
// Pretend no disk is inserted if a disk swapping is in progress
if (!sh4_sched_is_scheduled(schedId) && disc != nullptr)
return disc->type;
else
return NullDriveDiscType;
Expand All @@ -319,8 +320,8 @@ static int discSwapCallback(int tag, int sch_cycl, int jitter, void *arg)
else
// No disc inserted at the time of power-on, reset or hard reset, or TOC cannot be read.
sns_asc = 0x29;
sns_ascq = 0x00;
sns_key = 0x6;
sns_ascq = 0;
sns_key = 6;
gd_setdisc();

return 0;
Expand All @@ -342,6 +343,7 @@ bool DiscSwap(const std::string& path)

void libGDR_init()
{
verify(schedId == -1);
schedId = sh4_sched_register(0, discSwapCallback);
}
void libGDR_term()
Expand Down

0 comments on commit 116dc0e

Please sign in to comment.