'===========================================================================
' Subject: CD-ROM RECOGNITION                 Date: 02-10-93 (17:19)       
'  Author: Francois Roy                       Code: QB, PDS                
'  Origin: FidoNet QUIK_BAS Echo            Packet: DISK.ABC
'===========================================================================
'You can use CALL INTERRUPT to read the ISO-9660 sectors via MSCDEX.  The VTOC
'(Volume Table of Contents) is accessible as shown below; I don't have its
'structure so can't tell you what the fields mean, but I can betcha no two are
'alike... the VTOC is a 2048-byte string; I defined my buffer in CDVTOC with a
'length of 4096 because for some reason 2048 gives me String Space Corrupt
'errors... the demo routine below prints the first 800 bytes of the VTOC but
'you may want to store the whole 2048 bytes as the CD's "fingerprint".
 
'The code snippet below is for QB; QBX far strings need a small alteration.
 
DECLARE SUB CDVTOC (D$, V$)
DECLARE SUB CDDRIVE (DR$)
   TYPE REGTYPE  ' For CALL INTERRUPT
     AX AS INTEGER
     BX AS INTEGER
     CX AS INTEGER
     DX AS INTEGER
     BP AS INTEGER
     SI AS INTEGER
     DI AS INTEGER
     FL AS INTEGER
     DS AS INTEGER
     ES AS INTEGER
   END TYPE
   DIM SHARED INR AS REGTYPE, OUR AS REGTYPE
   CALL CDDRIVE(D$)
   PRINT "Drive:"; D$
   CALL CDVTOC(D$, V$)
   PRINT LEFT$(V$, 800)
   END
 
SUB CDDRIVE (DR$) STATIC
    DR$ = STRING$(32, 0)
    INR.AX = &H150D
    INR.BX = SADD(DR$)
    INR.ES = SSEG(DR$)
    CALL InterruptX(&H2F, INR, OUR)
    IF ASC(DR$) = 0 THEN DR$ = "" ELSE DR$ = CHR$(ASC(DR$) + 65) + ":"
END SUB
 
SUB CDVTOC (D$, V$) STATIC
REM Reads VTOC
    DR$ = STRING$(4096, 0)
    INR.AX = &H1505
    INR.BX = SADD(DR$)
    INR.CX = INSTR("ABCDEFGHIJKLMNOP", LEFT$(D$, 1)) - 1
    INR.DX = 0  ' 1st volume descriptor
    INR.ES = SSEG(DR$)
    CALL InterruptX(&H2F, INR, OUR)
REM AX=1 is normal and indicates a standard vol. descr.
REM AX=15 is 'Invalid Drive' and 21 is 'Not Ready'. 255 means no vol. desc.
    IF OUR.AX > 1 THEN V$ = "Error" + STR$(OUR.AX) ELSE V$ = DR$
END SUB
