home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / CDaemon / HACK16 / Sources / CDControl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-06-23  |  1.4 KB  |  70 lines

  1. #include <ata.h>
  2. #include <string.h>
  3. #include "CDControl.h"
  4.  
  5. static bool                gActiveQ = false;
  6. static bool                gDoneQ = false;
  7. static ataPB            gPB;
  8. static ATAPICmdPacket    gPacket;
  9.  
  10. OSErr    SetupATAPI(UInt32 nDeviceID)
  11. {
  12.     OSErr theResult = noErr;
  13.  
  14.     if(not gActiveQ){
  15.         gActiveQ = true;
  16.  
  17.         memset(&gPB,0,sizeof(gPB));
  18.         memset(&gPacket,0,sizeof(gPacket));
  19.  
  20.         gPB.ataIOParamBlock.ataPBVers = 3;
  21.         gPB.ataIOParamBlock.ataPBFunctionCode = 1;
  22.         gPB.ataIOParamBlock.ataPBIOSpeed = 4;
  23.         gPB.ataIOParamBlock.ataPBFlags = 0x0020;
  24.         gPB.ataIOParamBlock.ataPBDeviceID = nDeviceID;
  25.         gPB.ataIOParamBlock.ataPBTimeOut = 0x2710;
  26.  
  27.         gPB.ataIOParamBlock.ataPBStatusRegister = 0x50;
  28.         gPB.ataIOParamBlock.ataPBLogicalBlockSize = 0x200;
  29.  
  30.         gPB.ataIOParamBlock.ataPBActualTxCount = 0x12;
  31.  
  32.         gPB.ataIOParamBlock.ataPBTaskFile.ataTFSDH = 0xA0;
  33.         gPB.ataIOParamBlock.ataPBTaskFile.ataTFCommand = 0xA0;
  34.         gPB.ataIOParamBlock.ataPBPacketPtr = &gPacket;
  35.  
  36.         gPacket.atapiPacketSize = 12;
  37.         gPacket.atapiCommandByte[0] = 0x1b00;
  38.         gPacket.atapiCommandByte[2] = 0x0200;
  39.  
  40.     }
  41.     return theResult;
  42. }
  43.  
  44. void    StopIt()
  45. {
  46.     gActiveQ = false;
  47. }
  48.  
  49. OSErr    xJect(bool bOpen)
  50. {
  51.  
  52.     OSErr theResult;
  53.  
  54.     if(gActiveQ)
  55.     {
  56.         if(!bOpen)
  57.         {
  58.             gPacket.atapiCommandByte[2] = 0x0300;    // 0x0300 INject Command
  59.         }
  60.         else
  61.         {
  62.             gPacket.atapiCommandByte[2] = 0x0200;    // 0x0200 Eject Command
  63.         }
  64.         gDoneQ = false;
  65.         theResult = ataManager(&gPB);
  66.     }
  67.     return theResult;
  68. }
  69.  
  70.