Heya all ppl!!
Anyone here know how to check the status of the CD-ROM? I mean, like if there is a cd inside or if it's ejected...???
Ok, thanks a lot
Printable View
Heya all ppl!!
Anyone here know how to check the status of the CD-ROM? I mean, like if there is a cd inside or if it's ejected...???
Ok, thanks a lot
theres a biosdisk() in bios.h. i haven't used it just read about it so can't really help you right now.
that's if you want to use it while like in programming.
otherwise whats wrong with using the d: or your driveletter command??
Isn't it in the documentation of your driver? I think you need to send a command to the driver and interpret the result it sends back. Sending a command to the driver is in this case calling a driver function which retrieves the status of the CD-ROM device.
You can access the CD-ROM via the multiplex interrupt 2Fh.
For more information consult Ralf Brown's Interrupt Listing. You will also have to use DOS IOCTL via int 21h to issue IO commands to the drive for things such as opening the door and closing the door.
Thanks. I found out it's a LOT more complicated than i thought.
I found some interesting documentation at he.net. BUt it's still very hard to check the drive status.
The ideal would be to know if it's ejected, closed or if there's a CD inside and all that.
Thanks a lot everybody!!!!
Stefano
First you have to check if MSCDEX is installed.
This is all in assembly, but it is not to hard to port to C or to do
it inline. Make sure to preserve DS, just in case I forgot to, in functions that alter it or C will crash.
I would personally write this in a separate assembly source file and then call out to it from C. If you need help on setting that up, let me know.
Code:mov AX,0DADAh
push AX
mov AX,01100h
int 2Fh
pop BX
cmp BX,0ADADh
jne NOTFOUND
;if we get here MSCDEX is installed
To get the version of MSCDEX
Code:mov AX,0150Ch
int 2Fh
;BH holds major version
;BL holds minor version
To do anything you have to know how many CD-ROMS are present
Now you need to get the name of the CD-ROM device driverCode:mov AX,01500h
xor BX,BX ;same as mov bx,0
int 2Fh
;BX holds number of CD-ROMS
;CL holds first drive's letter (0=A,1=B, etc.)
;Cannot be used with DOS 4.0 GRAPHICS.COM
You will need a buffer that is 5 times the number of drives present (in bytes).
Now to get a file handle to the deviceCode:mov AX,01501h
les BX,Array
int 2Fh
FileHandle can be retrieved via DOS function 3Dh
Now you can check the CD-ROM statusCode:mov dx, SEG Array ;our file name is the device driver
push ds ;even for inline asm - DS must be pushed
mov ds,dx
mov dx,OFFSET Array
mov al,002h ;open file for read/write
mov ah,3Dh ;open file with handle
int 21h
jc error_encountered
mov FileHandle,ax
pop DS ;restore DS so C or asm can continue normally
;handle will be in AX
You will need a 5 byte block of memory.
bit 10 is set if audio is playingCode:mov bx,FileHandle
mov cx,MaxBytes
mov dx,SEG Buffer
push ds ;Save DS
mov ds,dx
mov dx,OFFSET buffer
mov ax,04402h
int 21h
jc error_encountered
mov BytesReceived,ax
pop DS ;Restore DS
bit 9 is set if Red Book and HSG addressing are supported
bit 8 is set if audio channel control is supported
bit 7 is set if prefetch requests are supported
bit 5 is set if interleaving is supported
bit 4 is set if audio/video playback supported
bit 3 is set if the CD-ROM is writable
bit 2 is set if raw and cooked read is supported
bit 1 is set if door is unlocked
bit 0 is set if door is open
Hope this helps.
Thanks a lot. It sure does help.
Stef