home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 3 / FREEWARE.BIN / ms_dos / stopcd30 / stopcd.c next >
Text File  |  1980-01-02  |  2KB  |  82 lines

  1. /*******************************************************/
  2. /*  STOPCD : COPYRIGHT (C) AIH.                        */
  3. /*                                    NIFTY/MHA02125   */
  4. /*                                        PCVAN/FMCLUB */
  5. /*  stop the CD-drive (real mode)                      */
  6. /*         Ver1.0 90.03    proto type                  */
  7. /*         Ver2.0 90.04.30 set time -> stop music      */
  8. /*         Ver3.0 91.01.19 MSC V5.0対応                */
  9. /*******************************************************/
  10.  
  11. #include    <stdio.h>
  12. #include    <dos.h>
  13.  
  14. union   REGS    inregs, outregs;
  15. struct  SREGS   sregs;
  16.  
  17. main(argc, argv)
  18. int argc;
  19. char *argv[];
  20. {
  21.     int ret;
  22.  
  23.     if (argc==1)
  24.         ret=stopcd(3);
  25.     else
  26.         ret=stopcd(atoi(argv));
  27.  
  28.     if (ret!=0)
  29.         exit(1);
  30.     else
  31.         exit(0);
  32. }
  33.  
  34. stopcd()
  35. {
  36.     char    *p;
  37.     int    i=0;
  38.  
  39.     while(i<5){
  40.         inregs.h.ah = 0x52;
  41.         inregs.h.al = 0xc0;
  42.         inregs.x.cx = 0x0000;
  43.         inregs.x.di = FP_OFF(p);
  44.         sregs.ds = FP_SEG(p);
  45.  
  46.         int86x( 0x93, &inregs, &outregs, &sregs );
  47.         i++;
  48.  
  49.         /* printf("ax=%x cx=%x\n", inregs.x.ax, inregs.x.cx); */
  50.                     /* 停止正常終了 */
  51.         if (outregs.h.cl==0x00)
  52.             break;
  53.                     /* DRIVE NOT READY */
  54.         if (outregs.h.cl==0x01) {
  55.             printf( "CD-ROMドライブが準備できていません.\n");
  56.             break;
  57.         }
  58.     }
  59.     if (outregs.h.ah==0x02 || outregs.h.al==0x80) {
  60.         printf( "CD-ROMの停止に失敗しました. ごめんなさい(^_^;)\n");
  61.         printf("レジスタ情報(ax=%x cx=%x)\n", inregs.x.ax, inregs.x.cx);
  62.     }
  63.     printf( "CD-ROMを停止しました. (^_^)\n");
  64.     return(outregs.x.cx);
  65. }
  66.  
  67. wait( mit )
  68. int    mit;
  69. {
  70.     int    i;
  71.     long    fst,lst;
  72.  
  73.     if (mit!=0){
  74.         time( &fst );
  75.         for( ; ; ){
  76.             time( &lst );
  77.             if( (fst+(long)mit) < lst ){ break; }
  78.         }
  79.     }
  80.     return 0;
  81. }
  82.