From: notaz Date: Sat, 28 Oct 2023 22:19:32 +0000 (+0300) Subject: cdrom: allow resetting with lid open X-Git-Tag: r24l~89 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7f50ee7e6412032ed5bb4559fbc8b18e6ba0c72;p=pcsx_rearmed.git cdrom: allow resetting with lid open libretro/pcsx_rearmed#679 --- diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index cb510606..a12ec31d 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -118,7 +118,6 @@ long CALLBACK CDR__configure(void); long CALLBACK CDR__test(void); void CALLBACK CDR__about(void); long CALLBACK CDR__setfilename(char *filename); -long CALLBACK CDR__getStatus(struct CdrStat *stat); static void DecodeRawSubData(void); diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index 99e8dcd6..6f4e3eb4 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -1694,7 +1694,13 @@ void cdrReset() { cdr.Reg2 = 0x1f; cdr.Stat = NoIntr; cdr.FifoOffset = DATA_SIZE; // fifo empty - if (CdromId[0] == '\0') { + + CDR_getStatus(&stat); + if (stat.Status & STATUS_SHELLOPEN) { + cdr.DriveState = DRIVESTATE_LID_OPEN; + cdr.StatP = STATUS_SHELLOPEN; + } + else if (CdromId[0] == '\0') { cdr.DriveState = DRIVESTATE_STOPPED; cdr.StatP = 0; } diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 526ebd43..f175e2a3 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -163,12 +163,19 @@ static void SetBootRegs(u32 pc, u32 gp, u32 sp) psxCpu->Notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL); } -void BiosBootBypass() { +int BiosBootBypass() { + struct CdrStat stat = { 0, 0, }; assert(psxRegs.pc == 0x80030000); + // no bypass if the lid is open + CDR__getStatus(&stat); + if (stat.Status & 0x10) + return 0; + // skip BIOS logos and region check psxCpu->Notify(R3000ACPU_NOTIFY_BEFORE_SAVE, NULL); psxRegs.pc = psxRegs.GPR.n.ra; + return 1; } static void getFromCnf(char *buf, const char *key, u32 *val) diff --git a/libpcsxcore/misc.h b/libpcsxcore/misc.h index a1c36bb9..539acc7b 100644 --- a/libpcsxcore/misc.h +++ b/libpcsxcore/misc.h @@ -57,7 +57,7 @@ extern char CdromId[10]; extern char CdromLabel[33]; extern int CdromFrontendId; // for frontend use -void BiosBootBypass(); +int BiosBootBypass(); int LoadCdrom(); int LoadCdromFile(const char *filename, EXE_HEADER *head); diff --git a/libpcsxcore/plugins.h b/libpcsxcore/plugins.h index d2086656..b106028c 100644 --- a/libpcsxcore/plugins.h +++ b/libpcsxcore/plugins.h @@ -161,6 +161,8 @@ extern CDRsetfilename CDR_setfilename; extern CDRreadCDDA CDR_readCDDA; extern CDRgetTE CDR_getTE; +long CALLBACK CDR__getStatus(struct CdrStat *stat); + // SPU Functions typedef long (CALLBACK* SPUinit)(void); typedef long (CALLBACK* SPUshutdown)(void); diff --git a/libpcsxcore/r3000a.c b/libpcsxcore/r3000a.c index fb043ae0..0c29dba7 100644 --- a/libpcsxcore/r3000a.c +++ b/libpcsxcore/r3000a.c @@ -76,8 +76,7 @@ void psxReset() { if (!Config.HLE) { psxExecuteBios(); if (psxRegs.pc == 0x80030000 && !Config.SlowBoot) { - BiosBootBypass(); - introBypassed = TRUE; + introBypassed = BiosBootBypass(); } } if (Config.HLE || introBypassed)