Sfoglia il codice sorgente

Update simple full TOC reporting to adjustments made to regular version.

Removed BCD conversion, report 'real' leadout, and fix length that should have been in 2b4dda189a850aba59b5b11787b1bb2b38f26fec
saybur 2 anni fa
parent
commit
f6692d0eae
1 ha cambiato i file con 11 aggiunte e 25 eliminazioni
  1. 11 25
      src/BlueSCSI_cdrom.cpp

+ 11 - 25
src/BlueSCSI_cdrom.cpp

@@ -96,7 +96,7 @@ static const uint8_t SessionTOC[] =
 static const uint8_t FullTOC[] =
 {
     0x00, //  0: toc length, MSB
-    0x44, //  1: toc length, LSB
+    0x2E, //  1: toc length, LSB
     0x01, //  2: First session number
     0x01, //  3: Last session number,
     // A0 Descriptor
@@ -132,9 +132,9 @@ static const uint8_t FullTOC[] =
     0x00, // 31: Sec
     0x00, // 32: Frame
     0x00, // 33: Zero
-    0x79, // 34: LEADOUT position BCD
-    0x59, // 35: leadout PSEC BCD
-    0x74, // 36: leadout PFRAME BCD
+    0x00, // 34: LEADOUT position
+    0x00, // 35: leadout PSEC
+    0x00, // 36: leadout PFRAME
     // TRACK 1 Descriptor
     0x01, // 37: session number
     0x14, // 38: ADR/Control
@@ -337,12 +337,6 @@ static void doReadSessionInfoSimple(bool msf, uint16_t allocationLength)
     scsiDev.phase = DATA_IN;
 }
 
-static inline uint8_t
-fromBCD(uint8_t val)
-{
-    return ((val >> 4) * 10) + (val & 0xF);
-}
-
 static void doReadFullTOCSimple(uint8_t session, uint16_t allocationLength)
 {
     // We only support session 1.
@@ -358,21 +352,13 @@ static void doReadFullTOCSimple(uint8_t session, uint16_t allocationLength)
         uint32_t len = sizeof(FullTOC);
         memcpy(scsiDev.data, FullTOC, len);
 
-        if (false)
-        {
-            int descriptor = 4;
-            while (descriptor < len)
-            {
-                int i;
-                for (i = 0; i < 7; ++i)
-                {
-                    scsiDev.data[descriptor + i] =
-                        fromBCD(scsiDev.data[descriptor + 4 + i]);
-                }
-                descriptor += 11;
-            }
-
-        }
+        // update leadout position
+        // consistent 2048-byte blocks makes this easier than bin/cue version
+        uint32_t capacity = getScsiCapacity(
+            scsiDev.target->cfg->sdSectorStart,
+            scsiDev.target->liveCfg.bytesPerSector,
+            scsiDev.target->cfg->scsiSectors);
+        LBA2MSF(capacity, &scsiDev.data[34], false);
 
         if (len > allocationLength)
         {