Found some materials, all are in assembly, but I don't understand assembly. How to write it in C language? Thanks
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
#include<dos.h>
int ppp=0;
unsigned int cdnum;
char getbuff,setbuff;
char stop={0x0d,0,0x85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
char setcd={0x1a,0,0x0c,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
char getcd={0x1a,0,0x03,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
main()
{int i; char ch;
_BX=0;
_AX=0x1500;
geninterrupt(0x2f);
if(ppp==0){cdnum=_CX;ppp=1;}
_AX=FP_OFF(getbuff);
_BX=FP_SEG(getbuff);
getcd=_AL;
getcd=_AH;
getcd=_BL;
getcd=_BH;
_AX=FP_OFF(setbuff);
_BX=FP_SEG(setbuff);
setcd=_AL;
setcd=_AH;
setcd=_BL;
setcd=_BH;
for(i=0;i<2;i++)
{
getcd=5;
getbuff=0x06;
_ES=FP_SEG(getcd);
_BX=FP_OFF(getcd);
_CX=cdnum;
_AX=0x1510;
geninterrupt(0x2f);
}
ch=getbuff&0x01;
if(ch==0)i=0;
else i=1;
if(i==0)
{_ES=FP_SEG(stop); /*Stop CD*/
_BX=FP_OFF(stop);
_CX=cdnum;
_AX=0x1510;
geninterrupt(0x2f);
setcd=1; /*Open CD*/
setbuff=0;
_ES=FP_SEG(setcd);
_BX=FP_OFF(setcd);
_CX=cdnum;
_AX=0x1510;
geninterrupt(0x2f);
}
else
{ /*Close CD*/
setcd=1;
setbuff=5;
_ES=FP_SEG(setcd);
_BX=FP_OFF(setcd);
_CX=cdnum;
_AX=0x1510;
geninterrupt(0x2f);
}
}The following is the statement from zhaojinpo on 2004-8-19 22:22:40: You can see the introduction from http://www.he.net/~marcj/cdrom.html! The source code is at ftp://ftp.he.net/pub/marcj/cdrom.c
Originally posted by qingfen at 2006-4-25 03:07:
for(i=0;i < 2;i++) and ch=getbuff & 0x01;
What is the function of i <, and it seems that lt and amp are not defined?