Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I open or close the cdrom drive in basic?

6 views
Skip to first unread message

Drunken Imbecile

unread,
Sep 25, 1996, 3:00:00 AM9/25/96
to

Anyone know how to open or close the cdrom drive in Qbasic or
VisualBasic3? And how to see if the drive is opned or closed? Any info
would be greatly appreciated. Thanks


Daniel Bellen

unread,
Sep 27, 1996, 3:00:00 AM9/27/96
to

> Anyone know how to open or close the cdrom drive in Qbasic or
> VisualBasic3? And how to see if the drive is opned or closed? Any info
> would be greatly appreciated. Thanks


OPEN"MSCDEX01" FOR RANDOM AS #1
IOCTL #1,CHR$(3) 'open
IOCTL #1,CHR$(10) 'close
CLOSE
Greetings from Germany...
Daniel

+------------------------------------------------------------------------+
| HUCK @ Nobody.gun.de ObOd¥ in M'Gladbach 02166 / 185293 |
+------------------------------------------------------------------------+

Jesse Dorland

unread,
Sep 28, 1996, 3:00:00 AM9/28/96
to Daniel Bellen

Daniel Bellen wrote:
>
> > Anyone know how to open or close the cdrom drive in Qbasic or
> > VisualBasic3? And how to see if the drive is opned or closed? Any info
> > would be greatly appreciated. Thanks
>
> OPEN"MSCDEX01" FOR RANDOM AS #1
> IOCTL #1,CHR$(3) 'open
> IOCTL #1,CHR$(10) 'close
> CLOSE
> Greetings from Germany...
> Daniel
>

You wouldn't happen to have similar code for playing the CDs, would you?

-Jesse

> +------------------------------------------------------------------------+
> | HUCK @ Nobody.gun.de ObOd¥ in M'Gladbach 02166 / 185293 |
> +------------------------------------------------------------------------+

--
====================================
Very funny Scotty!
Now beam down my clothes!
====================================

Tom Lake

unread,
Sep 28, 1996, 3:00:00 AM9/28/96
to

Jesse Dorland <jessed...@hotmail.com> wrote in article <12D495...@hotmail.com>...


> Daniel Bellen wrote:
> >
> > > Anyone know how to open or close the cdrom drive in Qbasic or
> > > VisualBasic3? And how to see if the drive is opned or closed? Any info
> > > would be greatly appreciated. Thanks
> >
> > OPEN"MSCDEX01" FOR RANDOM AS #1
> > IOCTL  #1,CHR$(3) 'open
> > IOCTL  #1,CHR$(10) 'close
> > CLOSE
> > Greetings from Germany...
> >      Daniel

All I get is an Illegal Function call when I try this code.  It also creates a file called MSCDEX01 with 0 byte length (Since there were no writes to it this is what I would expect.)

Tom Lake

Tyler Barnes

unread,
Sep 28, 1996, 3:00:00 AM9/28/96
to

TO>> > OPEN"MSCDEX01" FOR RANDOM AS #1
TO>> > IOCTL #1,CHR$(3) 'open
TO>> > IOCTL #1,CHR$(10) 'close
TO>> > CLOSE
TO>All I get is an Illegal Function call when I try this code. It also
TO>creates a file called MSCDEX01 with 0 byte length (Since there were no
TO>writes to it this is what I would expect.)

THat's because it isn't MSCDEX01 on all computers. It changes depending
on what software, and what type of CD-ROM you have. On my computer I
have to replace MSCDEX01 with DMSCD01 ... I think there is a way to
obtain the device name to use through interrupt 02Fh but I've never
looked. (If there is, that would allow you to write some CD routines
compatible with various different set ups)
I've actually found a CD player written in BASIC so I know there's a
way. (Compiled code)

Peter Cooper

unread,
Sep 28, 1996, 3:00:00 AM9/28/96
to

In article <324dbe1f...@news.xs4all.nl>, Marc van den Dikkenberg
<p...@excelsior.demon.nl> writes
>In the Basic Fanzine that has been/will be ( ;) ) QBasic code to
>perform all these operations, including playing the CD. I've converted
>this all to PB, but since the PB REG(x) is apparently slightly
>incompatible with Windows 95 I'm still busy to make it 95-compatible.
>I will probably succeed, it just takes some time. ;-)

Has been and will be more this next issue. =) Believe it or not, I am
sitting here with an open cdrom drive after it came up with lotsa errors
after running that program in QBasic, win95 didnt like it heh =)

Cheers,
--
Peter Cooper

Marc van den Dikkenberg

unread,
Sep 29, 1996, 3:00:00 AM9/29/96
to

On 28 Sep 1996 03:01:04 -0700, Jesse Dorland
<jessed...@hotmail.com> wrote:

>Daniel Bellen wrote:
>>
>> > Anyone know how to open or close the cdrom drive in Qbasic or
>> > VisualBasic3? And how to see if the drive is opned or closed? Any info
>> > would be greatly appreciated. Thanks
>>

>> OPEN"MSCDEX01" FOR RANDOM AS #1

>> IOCTL #1,CHR$(3) 'open
>> IOCTL #1,CHR$(10) 'close

Um... I may be mistaken, but isn't this supposed to be 0 and 5?

>> CLOSE
>> Greetings from Germany...
>> Daniel

>You wouldn't happen to have similar code for playing the CDs, would you?
>
>-Jesse

Playing Cd's is way more complicated, since you've got to construct a
controlblock with a lot of info. Also, above example will not work if
you're running windows (95) since that overrides mscdex. Also, what if

someone is using a non-standard devicedriver name? default is
MSCD001,but a lot of people I know (including myself) use different
names for this one.

In the Basic Fanzine that has been/will be ( ;) ) QBasic code to
perform all these operations, including playing the CD. I've converted
this all to PB, but since the PB REG(x) is apparently slightly
incompatible with Windows 95 I'm still busy to make it 95-compatible.
I will probably succeed, it just takes some time. ;-)


Marc van den Dikkenberg
-----------------------------o---------------------
http://145.89.78.151/~excel | Programming Archives
http://www.xs4all.nl/~excel | antU, Humour, Sci-Fi

Tyler Barnes

unread,
Sep 29, 1996, 3:00:00 AM9/29/96
to

EX>Um... I may be mistaken, but isn't this supposed to be 0 and 5?

You're right.

Marco Koegler

unread,
Sep 29, 1996, 3:00:00 AM9/29/96
to

Marc van den Dikkenberg wrote:
>
> On 28 Sep 1996 03:01:04 -0700, Jesse Dorland
> <jessed...@hotmail.com> wrote:
>
> >Daniel Bellen wrote:
> >>
> >> > Anyone know how to open or close the cdrom drive in Qbasic or
> >> > VisualBasic3? And how to see if the drive is opned or closed? Any info
> >> > would be greatly appreciated. Thanks
> >>
> >> OPEN"MSCDEX01" FOR RANDOM AS #1
> >> IOCTL #1,CHR$(3) 'open
> >> IOCTL #1,CHR$(10) 'close

First of all! I once tried opening the device driver and using IOCTL to
do this, but let's just say that after looking about an hour for a backup
of the driver everything was alright! I personally dislike this method of
programming the cd-rom. Since the driver has already been loaded in
memory, you can access all the cd-rom functions via interrupts. This
means you test if the driver has been installed, construct your
request/control headers in memory and use interrupts to activate the
instructions you have given in the headers. To see one way of how you can
do this keep reading the fanzine. If you are a QBASIC user then check out
my web page for a downloadable conversion of the prog from the fanzine.

> Um... I may be mistaken, but isn't this supposed to be 0 and 5?

According to my docs you are right, Code 0 is EJECT DISK for a IOCTL
Write and 5 is CLOSE TRAY.



> >> CLOSE
> >> Greetings from Germany...
> >> Daniel
>
> >You wouldn't happen to have similar code for playing the CDs, would you?
> >
> >-Jesse
>
> Playing Cd's is way more complicated, since you've got to construct a
> controlblock with a lot of info. Also, above example will not work if
> you're running windows (95) since that overrides mscdex. Also, what if

Yep, that's right! You will not only need a request header, but also a
control block to play CDs. But, it's not that much more complicated. You
request header should have the following format:

Field Size Entry
byte Length in bytes of request header
byte 0
byte 132 (Command Code for PLAY AUDIO)
word 0 (contains status after call)
8 bytes all 0 (Reserved)
byte addressing mode (0=HSG, 1=RBA)
dword starting sector number (depends on addressing
mode)
dword number of sectors to read



> someone is using a non-standard devicedriver name? default is
> MSCD001,but a lot of people I know (including myself) use different
> names for this one.

Again, opening the actual device driver on the disk can be dangerous.



> In the Basic Fanzine that has been/will be ( ;) ) QBasic code to
> perform all these operations, including playing the CD. I've converted
> this all to PB, but since the PB REG(x) is apparently slightly
> incompatible with Windows 95 I'm still busy to make it 95-compatible.
> I will probably succeed, it just takes some time. ;-)

Aha! That's interesting. Another reason not to switch to Windows 95. Have
you tried inline assembler? Oh yeah, it would really interest me how my
program/tutorial is working out for all of you (bugs, problems,
quirks,...)! Thanks!

Hope this cleared some things up!

Marco Koegler
mk...@fidnet.com
http://www.umr.edu/~marco

PS: The QBASIC version (PCD3.ZIP) on my homepage also contains a
translation of the interrupt routines into CALL ABSOLUTE's with ASM
equivalents in REMarks on the side.

Marc van den Dikkenberg

unread,
Sep 30, 1996, 3:00:00 AM9/30/96
to

On Sun, 29 Sep 1996 13:33:18 -0700, Marco Koegler <mk...@fidnet.com>
wrote:

>> perform all these operations, including playing the CD. I've converted
>> this all to PB, but since the PB REG(x) is apparently slightly
>> incompatible with Windows 95 I'm still busy to make it 95-compatible.
>> I will probably succeed, it just takes some time. ;-)
>
>Aha! That's interesting. Another reason not to switch to Windows 95. Have
>you tried inline assembler? Oh yeah, it would really interest me how my
>program/tutorial is working out for all of you (bugs, problems,
>quirks,...)! Thanks!

Yes, and inline ASM is working fine. I just need to know how to use
VARSEG and VARPTR in this context, though.

It's very weird:

REG %ax,<something>
REG %bx,<something>
CALL INTERURPT &H<x>

May give a different result than

! mov AX,<something>
! mov BX,<something>
! int &H<x>

But ofcourse you can always translate the above stuff into inline ASM
to make it work. That's what I'm doing right now...

0 new messages