@@ -69,6 +69,8 @@ class CDRomImpl : public PCSX::CDRom {
6969 CdlReadToc = 30 ,
7070 };
7171
72+ static const size_t cdCmdEnumCount = magic_enum::enum_count<Commands>();
73+
7274 static const inline uint8_t Test04[] = {0 };
7375 static const inline uint8_t Test05[] = {0 };
7476 static const inline uint8_t Test20[] = {0x98 , 0x06 , 0x10 , 0xC3 };
@@ -1232,9 +1234,11 @@ class CDRomImpl : public PCSX::CDRom {
12321234 m_ctrl &= ~0x20 ;
12331235 }
12341236
1235- if (m_OCUP) m_ctrl |= 0x40 ;
1236- // else
1237- // m_ctrl &= ~0x40;
1237+ if (m_OCUP) {
1238+ m_ctrl |= 0x40 ;
1239+ } else {
1240+ m_ctrl &= ~0x40 ;
1241+ }
12381242
12391243 m_ctrl |= 0x18 ;
12401244
@@ -1276,7 +1280,12 @@ class CDRomImpl : public PCSX::CDRom {
12761280 m_cmd = rt;
12771281 m_OCUP = 0 ;
12781282
1279- CDROM_IO_LOG (" CD1 write: %x (%s)" , rt, magic_enum::enum_names<Commands>()[rt]);
1283+ if (rt > cdCmdEnumCount) {
1284+ CDROM_IO_LOG (" CD1 write: %x (CdlUnknown)" , rt);
1285+ } else {
1286+ CDROM_IO_LOG (" CD1 write: %x (%s)" , rt, magic_enum::enum_names<Commands>()[rt]);
1287+ }
1288+
12801289 if (m_paramC) {
12811290 CDROM_IO_LOG (" Param[%d] = {" , m_paramC);
12821291 for (i = 0 ; i < m_paramC; i++) CDROM_IO_LOG (" %x," , m_param[i]);
@@ -1342,6 +1351,7 @@ class CDRomImpl : public PCSX::CDRom {
13421351 unsigned char ret;
13431352
13441353 if (m_read == 0 ) {
1354+ m_OCUP = 0 ;
13451355 ret = 0 ;
13461356 } else {
13471357 ret = m_transfer[m_transferIndex];
@@ -1658,8 +1668,12 @@ class CDRomImpl : public PCSX::CDRom {
16581668 m_param[0 ]);
16591669 break ;
16601670 default :
1661- PCSX ::g_system->log (PCSX ::LogClass::CDROM , " [CDROM]%s Command: %s\n " , delayedString,
1662- magic_enum::enum_names<Commands>()[command & 0xff ]);
1671+ if (command > cdCmdEnumCount) {
1672+ PCSX ::g_system->log (PCSX ::LogClass::CDROM , " [CDROM]%s Command: CdlUnknown\n " , delayedString);
1673+ } else {
1674+ PCSX ::g_system->log (PCSX ::LogClass::CDROM , " [CDROM]%s Command: %s\n " , delayedString,
1675+ magic_enum::enum_names<Commands>()[command & 0xff ]);
1676+ }
16631677 break ;
16641678 }
16651679 }
0 commit comments