diff --git a/core/imgread/common.cpp b/core/imgread/common.cpp index 1a841372b..1566fae7a 100644 --- a/core/imgread/common.cpp +++ b/core/imgread/common.cpp @@ -135,9 +135,6 @@ void DiscOpenLid() TermDrive(); NullDriveDiscType = Open; gd_setdisc(); - sns_asc = 0x29; - sns_ascq = 0x00; - sns_key = 0x6; } static bool doDiscSwap(const std::string& path) diff --git a/core/reios/gdrom_hle.cpp b/core/reios/gdrom_hle.cpp index 04d77d453..1795ab471 100644 --- a/core/reios/gdrom_hle.cpp +++ b/core/reios/gdrom_hle.cpp @@ -135,36 +135,36 @@ static void GDROM_HLE_ReadPIO() gd_hle_state.result[3] = 0; } -static void GDCC_HLE_GETSCD() { +static void GDCC_HLE_GETSCD() +{ u32 format = gd_hle_state.params[0]; u32 size = gd_hle_state.params[1]; u32 dest = gd_hle_state.params[2]; // params[3] 0 DEBUG_LOG(REIOS, "GDROM: GETSCD format %x size %x dest %08x", format, size, dest); - - if (libGDR_GetDiscType() == Open || libGDR_GetDiscType() == NoDisk) - { - gd_hle_state.status = GDC_ERR; - gd_hle_state.result[0] = 6; // GDC_ERR_UNITATTENTION - gd_hle_state.result[1] = 0; - gd_hle_state.result[2] = 0; - gd_hle_state.result[3] = 0; - return; - } if (sns_asc != 0) { // Helps D2 detect the disk change gd_hle_state.status = GDC_ERR; gd_hle_state.result[0] = sns_key; - gd_hle_state.result[1] = sns_asc; - gd_hle_state.result[2] = 0x18; // ? - gd_hle_state.result[3] = sns_ascq; // ? + gd_hle_state.result[1] = sns_asc | (sns_ascq << 8); + gd_hle_state.result[2] = 0x18; // ? + gd_hle_state.result[3] = 0; sns_key = 0; sns_asc = 0; sns_ascq = 0; return; } + if (SecNumber.Status != GD_BUSY && (libGDR_GetDiscType() == Open || libGDR_GetDiscType() == NoDisk)) + { + gd_hle_state.status = GDC_ERR; + gd_hle_state.result[0] = 2; + gd_hle_state.result[1] = 0x3a; // Media operation command was received but no media is inserted. + gd_hle_state.result[2] = 0; + gd_hle_state.result[3] = 0; + return; + } if (cdda.status == cdda_t::Playing) gd_hle_state.cur_sector = cdda.CurrAddr.FAD; u8 scd[100]; @@ -688,25 +688,34 @@ void gdrom_hle_op() // // Returns: 0 OK, -1 ERR, 1 BUSY, 2 COMPLETE, 3 CONTINUE gd_drv_stat status; - u32 discType = libGDR_GetDiscType(); - switch (discType) + u32 discType; + if (SecNumber.Status == GD_BUSY) { - case Open: - status = GD_STAT_OPEN; + status = GD_STAT_BUSY; discType = 0; - break; - case NoDisk: - status = GD_STAT_NODISC; - discType = 0; - break; - default: - if (gd_hle_state.status == GDC_CONTINUE || SecNumber.Status == GD_PLAY) - status = GD_STAT_PLAY; - else - status = GD_STAT_PAUSE; - if (memcmp(ip_meta.disk_type, "GD-ROM", sizeof(ip_meta.disk_type)) == 0) - discType = GdRom; - break; + } + else + { + discType = libGDR_GetDiscType(); + switch (discType) + { + case Open: + status = GD_STAT_OPEN; + discType = 0; + break; + case NoDisk: + status = GD_STAT_NODISC; + discType = 0; + break; + default: + if (gd_hle_state.status == GDC_CONTINUE || SecNumber.Status == GD_PLAY) + status = GD_STAT_PLAY; + else + status = GD_STAT_PAUSE; + if (memcmp(ip_meta.disk_type, "GD-ROM", sizeof(ip_meta.disk_type)) == 0) + discType = GdRom; + break; + } } WriteMem32(r[4], (u32)status); WriteMem32(r[4] + 4, discType);