@@ -69,6 +69,8 @@ class CDRomImpl : public PCSX::CDRom {
69
69
CdlReadToc = 30 ,
70
70
};
71
71
72
+ static const size_t cdCmdEnumCount = magic_enum::enum_count<Commands>();
73
+
72
74
static const inline uint8_t Test04[] = {0 };
73
75
static const inline uint8_t Test05[] = {0 };
74
76
static const inline uint8_t Test20[] = {0x98 , 0x06 , 0x10 , 0xC3 };
@@ -1232,9 +1234,11 @@ class CDRomImpl : public PCSX::CDRom {
1232
1234
m_ctrl &= ~0x20 ;
1233
1235
}
1234
1236
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
+ }
1238
1242
1239
1243
m_ctrl |= 0x18 ;
1240
1244
@@ -1276,7 +1280,12 @@ class CDRomImpl : public PCSX::CDRom {
1276
1280
m_cmd = rt;
1277
1281
m_OCUP = 0 ;
1278
1282
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
+
1280
1289
if (m_paramC) {
1281
1290
CDROM_IO_LOG (" Param[%d] = {" , m_paramC);
1282
1291
for (i = 0 ; i < m_paramC; i++) CDROM_IO_LOG (" %x," , m_param[i]);
@@ -1342,6 +1351,7 @@ class CDRomImpl : public PCSX::CDRom {
1342
1351
unsigned char ret;
1343
1352
1344
1353
if (m_read == 0 ) {
1354
+ m_OCUP = 0 ;
1345
1355
ret = 0 ;
1346
1356
} else {
1347
1357
ret = m_transfer[m_transferIndex];
@@ -1658,8 +1668,12 @@ class CDRomImpl : public PCSX::CDRom {
1658
1668
m_param[0 ]);
1659
1669
break ;
1660
1670
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
+ }
1663
1677
break ;
1664
1678
}
1665
1679
}
0 commit comments