home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / CDROM / GetCDDB / src / GETCDD~2.BB2 < prev    next >
Text File  |  2000-01-07  |  2KB  |  88 lines

  1. ;GetCDDB_CDFuncs.bb2
  2.  
  3. ;-----------------------------------------------------------
  4. ; GetCDDB_CDFuncs V0.06b by Roger Light (c)1999,2000
  5. ; Calculates the CDDB discid of the current CD.
  6. ;-----------------------------------------------------------
  7.  
  8. XINCLUDE MyCDCode.bb2
  9. XINCLUDE "GetCDDB_Consts.bb2"
  10. XINCLUDE "GetCDDB_MiscFuncs.bb2"
  11.  
  12. Function.s ComputeCDDBDiscId{}
  13.  
  14.   SHARED TOClength
  15.   SHARED TOCaddr()
  16.   SHARED cdtoc()
  17.   SHARED t.l
  18.  
  19.   Dim trackpos.l(100) ; position of tracks, in frame format
  20. ;  Dim cdtoc.toc(100)  ; position of tracks, in MSF format
  21.  
  22.   ;calculate position of tracks
  23.   For i.l=0 To TOClength
  24.     trackpos(i)=TOCaddr(i)+150
  25.     cdtoc(i)\m=trackpos(i)/4500
  26.     trackpos(i)-cdtoc(i)\m*4500
  27.  
  28.     cdtoc(i)\s=trackpos(i)/75
  29.     trackpos(i)-cdtoc(i)\s*75
  30.  
  31.     cdtoc(i)\f=trackpos(i)
  32.   Next
  33.  
  34.  
  35.   ; below is the code taken from the CDDB site and converted to Blitz
  36.   i.l = 0
  37.   n.l = 0
  38.   While i < TOClength
  39.  
  40.     ;// cddb_sum
  41.     cddb_sum.l=0;
  42.     j.l=(cdtoc(i)\m * 60) + cdtoc(i)\s;
  43.     While j.l > 0
  44.       cddb_sum = cddb_sum + (j MOD 10);
  45.       j = j / 10;
  46.     Wend
  47.  
  48.     n = n + cddb_sum;
  49.     i+1
  50.   Wend
  51.  
  52. ;  // compute total CD Length in seconds
  53.   t.l = ((cdtoc(TOClength)\m * 60) + cdtoc(TOClength)\s) - ((cdtoc(0)\m * 60) + cdtoc(0)\s);
  54.  
  55. ;  // compute disc-id
  56.   dwDiscId.l = ((n MOD 255) * 16777216 OR t*256 OR TOClength);
  57.  
  58.   Function Return Hex$(dwDiscId.l)
  59. End Function
  60.  
  61. ;------------------------------------------------------------
  62. Function.s GetCurrentId{}
  63.   SHARED scsidev$
  64.   SHARED scsiid
  65.   SHARED TOCCDID$
  66.  
  67.   scsiid=GTGetInteger(0,#_UNIT_INTEGER)
  68.   scsidev$=GTGetString(0,#_DEVICE_STRING)
  69.   If NOT Len(scsidev$)
  70.     Function Return "0"
  71.   EndIf
  72.  
  73.   If InitCDDA{}
  74.     If CDDAReadContents{}
  75. ;      ErrorReq{"Unable to read CD contents"}
  76.     Else
  77.       ;TOCCDID$ now holds the current CDID
  78.       currentid$=TOCCDID$
  79.     EndIf
  80.     EndingCDDA{}
  81.   Else
  82. ;   ErrorReq{"Unable to open CD"}
  83.   EndIf
  84.  
  85.   Function Return currentid$
  86. End Function
  87.  
  88.