- More changes to media change detection.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3438 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
ramapcsx2 2010-07-09 15:26:34 +00:00
parent d536cc5cde
commit 405bd329a3
3 changed files with 36 additions and 34 deletions

View File

@ -476,45 +476,42 @@ s32 cdvdReadSubQ(s32 lsn, cdvdSubQ* subq)
return ret; return ret;
} }
void openVirtualTray()
{
trayState = 1;
DiscSwapTimerSeconds = cdvd.RTC.second;
cdvd.Status = CDVD_STATUS_TRAY_OPEN;
cdvd.Ready = CDVD_NOTREADY;
}
// Only trayState is needed right now.
s32 cdvdCtrlTrayOpen() s32 cdvdCtrlTrayOpen()
{ {
Console.Warning("Open virtual disk tray");
DiscSwapTimerSeconds = cdvd.RTC.second; // remember the PS2 time when this happened
cdvd.Status = CDVD_STATUS_TRAY_OPEN;
cdvd.Ready = CDVD_NOTREADY;
trayState = 1; trayState = 1;
s32 ret = CDVD->ctrlTrayOpen();
if (ret == -1) ret = 0x80; return 0; // needs to be 0 for success according to homebrew test "CDVD"
return ret;
} }
// Only trayState is needed right now.
s32 cdvdCtrlTrayClose() s32 cdvdCtrlTrayClose()
{ {
Console.Warning("Close virtual disk tray");
cdvd.Status = CDVD_STATUS_PAUSE;
cdvd.Ready = CDVD_READY1;
trayState = 0; trayState = 0;
s32 ret = CDVD->ctrlTrayClose();
if (ret == -1) ret = 0x80; return 0; // needs to be 0 for success according to homebrew test "CDVD"
return ret;
} }
// Modified by (efp) - 16/01/2006 // Some legacy function, not used anymore
// checks if tray was opened since last call to this func
// Outdated and not doing anything.. much.. I hope (rama)
s32 cdvdGetTrayStatus() s32 cdvdGetTrayStatus()
{ {
s32 ret = CDVD->getTrayStatus(); /*s32 ret = CDVD->getTrayStatus();
if (ret == -1) if (ret == -1)
return(CDVD_TRAY_CLOSE); return(CDVD_TRAY_CLOSE);
else else
return(ret); return(ret);*/
return -1;
} }
// Note: Is tray status being kept as a var here somewhere? // Note: Is tray status being kept as a var here somewhere?
// Yep, and sceCdTrayReq needs it to detect tray state changes (rama)
// cdvdNewDiskCB() can update it's status as well... // cdvdNewDiskCB() can update it's status as well...
// Modified by (efp) - 16/01/2006 // Modified by (efp) - 16/01/2006
@ -932,10 +929,7 @@ void cdvdVsync() {
{ {
if ( cdvd.RTC.second != DiscSwapTimerSeconds) if ( cdvd.RTC.second != DiscSwapTimerSeconds)
{ {
Console.Warning("Close virtual disk tray"); cdvdCtrlTrayClose();
trayState = 0;
cdvd.Status = CDVD_STATUS_PAUSE;
cdvd.Ready = CDVD_READY1;
} }
} }
@ -1015,8 +1009,7 @@ u8 cdvdRead(u8 key)
case 0x0B: // TRAY-STATE (if tray has been opened) case 0x0B: // TRAY-STATE (if tray has been opened)
{ {
u8 tray = cdvdGetTrayStatus(); CDVD_LOG("cdvdRead0B(Tray) %x", trayState);
CDVD_LOG("cdvdRead0B(Tray) %x HLE flag = %x ", tray, trayState);
return /*tray*/ trayState; return /*tray*/ trayState;
break; break;
} }
@ -1407,6 +1400,7 @@ static void cdvdWrite16(u8 rt) // SCOMMAND
// cdvdTN diskInfo; // cdvdTN diskInfo;
// cdvdTD trackInfo; // cdvdTD trackInfo;
// int i, lbn, type, min, sec, frm, address; // int i, lbn, type, min, sec, frm, address;
static bool oldTrayState = 0;
int address; int address;
u8 tmp; u8 tmp;
@ -1461,9 +1455,15 @@ static void cdvdWrite16(u8 rt) // SCOMMAND
break; break;
case 0x05: // CdTrayReqState (0:1) - resets the tray open detection case 0x05: // CdTrayReqState (0:1) - resets the tray open detection
trayState = 0;
//Console.Warning("CdTrayReqState. trayState = %d oldTrayState = %d",trayState, oldTrayState);
SetResultSize(1); SetResultSize(1);
cdvd.Result[0] = 0; if (trayState != oldTrayState)
cdvd.Result[0] = 1;
else
cdvd.Result[0] = 0; // old behaviour was always this
oldTrayState = trayState;
break; break;
case 0x06: // CdTrayCtrl (1:1) case 0x06: // CdTrayCtrl (1:1)

View File

@ -144,6 +144,7 @@ extern u8 cdvdRead(u8 key);
extern void cdvdWrite(u8 key, u8 rt); extern void cdvdWrite(u8 key, u8 rt);
extern void cdvdReloadElfInfo(wxString elfoverride = wxEmptyString); extern void cdvdReloadElfInfo(wxString elfoverride = wxEmptyString);
extern void openVirtualTray(); extern s32 cdvdCtrlTrayOpen();
extern s32 cdvdCtrlTrayClose();
extern wxString DiscSerial; extern wxString DiscSerial;

View File

@ -294,7 +294,11 @@ CDVD_SourceType CDVDsys_GetSourceType()
void CDVDsys_ChangeSource( CDVD_SourceType type ) void CDVDsys_ChangeSource( CDVD_SourceType type )
{ {
GetCorePlugins().Close( PluginId_CDVD ); GetCorePlugins().Close( PluginId_CDVD );
static bool firstRun = true;
if (!firstRun) cdvdCtrlTrayOpen();
firstRun = false;
switch( m_CurrentSourceType = type ) switch( m_CurrentSourceType = type )
{ {
case CDVDsrc_Iso: case CDVDsrc_Iso:
@ -400,9 +404,6 @@ void DoCDVDclose()
CDVD->close(); CDVD->close();
DoCDVDresetDiskTypeCache(); DoCDVDresetDiskTypeCache();
Console.Warning("Closing CDVD plugin > open virtual disk tray");
openVirtualTray();
} }
s32 DoCDVDreadSector(u8* buffer, u32 lsn, int mode) s32 DoCDVDreadSector(u8* buffer, u32 lsn, int mode)