Talking to more than one CD-ROM drive in TP6.0

Hi there,

  I'm trying to write an audio CD player with a turbovision interface.  Right
now I'm just trying to get the CD procedures to work, and I'm having a really
weird problem.  The source code below <should> just send a reset command to
the drive.  When I run it on my old PS/2(which is my target platform), it
will eject the disk(not the intended result) every other time I run it.  When
it doesn't eject the disk, the driver returns 'busy' in the status word of
the request header.  When I run it on my Pentium (in DOS mode) it never
works.  The Check() procedure works just fine in both cases, but nothing else
will work with any consistency.  I have the Microsoft document on interfacing
MSCDEX to the device driver, but it doesn't say much about talking to MSCDEX
from within my program.  I have some code I pulled off the net that works
fine with one drive, but it uses Dos function 44, which won't let me specify
which drive I want.

  The target system has 2 Reveal CD-rom drives, model GCD-542B - ROM ver
1.20, and the driver is GCD540.SYS dated 3-20-95.

  Is there something that I need to do between ioctl calls?  I've tried
sending device_open and device_close, and both these calls seem to work ok,
but drive_reset, volume_info, eject and close_tray commands all act weird.

Any help will be greatly appreciated.

Warren Puziewicz
zoun...@usinternet.com

-------------------------------------------
program CD;
Uses Crt;

Type
  ReqHdr = Record
    Len    : Byte;
    SubU   : Byte;
    ComC   : Byte;
    Status : Word;
    Junk   : Array[1..8] of Byte;
  End;

  IoCtlH = Record
    Hdr     : ReqHdr;
    MDB     : Byte;
    TA_Seg  : Word;
    TA_Ofs  : Word;
    T_Bytes : Word;
    Sect    : Word;
    Vol_Seg : Word;
    Vol_Ofs : Word;
  End;

var
  Ctrl : IoCtlH;
  Info : Array[1..100] of Byte;

{ Send Device Driver Request, seems to work every other time the prog is run

Quote
}

Procedure IOCtl(Dr_No : Byte);
  var Temp : Word;
  Begin
    Temp := Ofs(Ctrl);
    Dr_No := Dr_No + 3;
    ASM
      mov   ax, $1510
      push  es
      push  ds
      pop   es
      xor   cx, cx
      mov   cl, Dr_No
      mov   bx, Temp
      int   $2F
      pop   es
    End;
  End;

{ Check that Sub_Unit is a CD-ROM drive, always works }
Procedure Check(Sub_Unit : Byte);
var Temp1, Temp2 : Word;
begin
  Temp1 := Sub_Unit;
  asm
    mov bx, 0
    mov cx, Temp1
    mov ax, $150b
    int $2f
    mov Temp1, bx
    mov Temp2, ax
  end;
  if (Temp1 = $adad) then begin
    write('Drive ');
    write (Sub_Unit);
    writeln(' Checks OK');
  end;
end;

var Dr : Byte;

Begin
  If (ParamStr(1) = 'E') Then Dr := 1
  Else Dr := 0;
  Check(Dr);
  Ctrl.Hdr.Len    := 13;
  Ctrl.Hdr.Subu   := Dr;
  Ctrl.Hdr.ComC   := 12;
  Ctrl.Hdr.Status := 0;
  fillchar (Ctrl.hdr.junk, 8, 0);
  Ctrl.T_Bytes    := 1;
  Ctrl.Sect       := 0;
  Ctrl.Vol_Seg    := 0;
  Ctrl.Vol_Ofs    := 0;
  Ctrl.Ta_Seg     := Seg(Info);
  Ctrl.Ta_Ofs     := Ofs(Info);
  Ctrl.Mdb        := 0;
  Fillchar (info, sizeof(info), 0 );
  Info[1]         := 2; { Command to reset drive }
  IoCtl(Dr);
  Write('Status = ');
  writeln(Ctrl.Hdr.Status);
  Writeln;
  Writeln;
End.