home *** CD-ROM | disk | FTP | other *** search
- #include "CDTrayControl.h"
- #include "PO_Globals.h"
- #include <ata.h>
- #include "PO_Assert.h"
- #include <string.h>
-
- static bool gActiveQ = false;
- static bool gDoneQ = false;
- static ataPB gPB;
- static ATAPICmdPacket gPacket;
-
- static pascal void _CompleteProc(ataPB* pb)
- {
- PO_EnterCallback();
-
- gDoneQ = true;
-
- PO_ExitCallback();
- }
-
- void StartTrayCycle()
- {
- if(not gActiveQ){
- gActiveQ = true;
-
- memset(&gPB,0,sizeof(gPB));
- memset(&gPacket,0,sizeof(gPacket));
-
- gPB.ataIOParamBlock.ataPBVers = 3;
- gPB.ataIOParamBlock.ataPBFunctionCode = 1;
- gPB.ataIOParamBlock.ataPBIOSpeed = 4;
- gPB.ataIOParamBlock.ataPBFlags = 0x8021;
- gPB.ataIOParamBlock.ataPBDeviceID = 1;
- gPB.ataIOParamBlock.ataPBTimeOut = 0x2710;
- gPB.ataIOParamBlock.ataPBCallbackPtr = (ProcPtr)_CompleteProc;
- gPB.ataIOParamBlock.ataPBClientPtr1 = LMGetCurrentA5();
-
- gPB.ataIOParamBlock.ataPBStatusRegister = 0x50;
- gPB.ataIOParamBlock.ataPBLogicalBlockSize = 0x200;
-
- gPB.ataIOParamBlock.ataPBActualTxCount = 0x12;
-
- gPB.ataIOParamBlock.ataPBTaskFile.ataTFSDH = 0xA0;
- gPB.ataIOParamBlock.ataPBTaskFile.ataTFCommand = 0xA0;
- gPB.ataIOParamBlock.ataPBPacketPtr = &gPacket;
-
- gPacket.atapiPacketSize = 12;
- gPacket.atapiCommandByte[0] = 0x1b00;
- gPacket.atapiCommandByte[2] = 0x0200;
-
- PO_PrepareCallback();
-
- gDoneQ = false;
- ataManager(&gPB);
- }
- }
-
- void IdleTray()
- {
- if(gActiveQ){
- if(gDoneQ){
- if(gPacket.atapiCommandByte[2] == 0x0200){
- gPacket.atapiCommandByte[2] = 0x0300;
- }else{
- gPacket.atapiCommandByte[2] = 0x0200;
- }
- gDoneQ = false;
- ataManager(&gPB);
- }
- }
- }
-
- void StopTrayCycle()
- {
- gActiveQ = false;
- }
-
-