home *** CD-ROM | disk | FTP | other *** search
/ Computer Installation Guide - Dragon Clan Series / CD1.iso / MPEG / WFSMP11 / SDK / DOS / VIDEOCD.C < prev   
Encoding:
C/C++ Source or Header  |  1995-04-06  |  3.9 KB  |  183 lines

  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include "mpgmovie.h"
  4.  
  5. int DelayMiliSecond(long miliseconds)
  6. {
  7.     int   lobyte;
  8.     int   hibyte;
  9.  
  10.     miliseconds *= 1000L;
  11.     lobyte = (int)miliseconds;
  12.     hibyte = (int)(miliseconds>>16);
  13.  
  14.     _asm    mov    dx,lobyte
  15.     _asm    mov    cx,hibyte
  16.     _asm    mov    ah,86h
  17.     _asm    int    15h
  18.     _asm    jc     error
  19.     return 1;
  20. error:
  21.     return 0;
  22. }
  23.  
  24. int main(int argc,char *argv[])
  25. {
  26.     int                 CDI;
  27.     unsigned char       starttrack;
  28.     unsigned char       endtrack;
  29.     unsigned char       track;
  30.     unsigned int        song;
  31.     int                 status;
  32.     int                 toggle;
  33.     char                title[80];
  34.  
  35.     if (argc == 1)
  36.     {
  37.         song = 0;
  38.     }
  39.     else if (argc == 2)
  40.     {
  41.         song = 0;
  42.         sscanf(argv[1],"%d",&song);
  43.     }
  44.     else
  45.     {
  46.         printf("Usage: VIDEOCD <track number>\n");
  47.         return 1;
  48.     }
  49.  
  50.     if (!MOVIE_CDROM_Installed())
  51.     {
  52.         printf("No CD-ROM drive installed.\n");
  53.         return 2;
  54.     }
  55.     status = MOVIE_Initialize(-1,-1);
  56.     if (status == 0)
  57.     {
  58.         printf("Fail to detect hardware.\n");
  59.         return 3;
  60.     }
  61.     else if (status == -1)
  62.     {
  63.         printf("Memory insufficient.\n");
  64.         return 3;
  65.     }
  66.  
  67.     if (!MOVIE_CDROM_HasDisc())
  68.     {
  69.         printf("No Disc in the CD-ROM drive.\n");
  70.         MOVIE_Exit(0);
  71.         return 4;
  72.     }
  73.  
  74.     if (MOVIE_CDROM_IsDiscChanged())
  75.     {
  76.         printf("Disc is changed.\n");
  77.     }
  78.  
  79.     CDI = MOVIE_CDROM_GetCDITitle(title);
  80.  
  81.     if (CDI)
  82.     {
  83.         if (MOVIE_CDROM_SeekCDI() != 0)
  84.         {
  85.             MOVIE_Exit(0);
  86.             printf("Fail to seek Video CD (CD-I:%s).\n",title);
  87.             return 5;
  88.         }
  89.     }
  90.     else
  91.     {
  92.         if (!MOVIE_CDROM_GetTrackNo(&starttrack,&endtrack))
  93.         {
  94.             MOVIE_Exit(0);
  95.             printf("Fail to get the track infomation of Video CD.\n");
  96.             return 6;
  97.         }
  98.  
  99.         if ( starttrack == endtrack )
  100.         {
  101.             MOVIE_Exit(0);
  102.             printf("The CD-ROM is not Video CD.\n");
  103.             return 7;
  104.         }
  105.  
  106.         if (song != 0)
  107.         {
  108.             track = (unsigned char)(song + 1);
  109.             if (track > endtrack)
  110.             {
  111.                 MOVIE_Exit(0);
  112.                 printf("The track number is out of range [1..%d].\n",endtrack-1);
  113.                 return 8;
  114.             }
  115.         }
  116.         else
  117.         {
  118.             track = 2;
  119.         }
  120.  
  121.         if (!MOVIE_CDROM_SeekTrack(track))
  122.         {
  123.             MOVIE_Exit(0);
  124.             printf("Fail to seek track %d of Video CD.\n",track);
  125.             return 9;
  126.         }
  127.     }
  128.  
  129.     toggle = 0;
  130.     MOVIE_VGA_Output(toggle);
  131.  
  132.     DelayMiliSecond(1000L);
  133.  
  134.     MOVIE_Play();
  135.     status = 0;
  136.     while (1)
  137.     {
  138.         while (1)
  139.         {
  140.             if (kbhit())
  141.             {
  142.                 int ch;
  143.  
  144.                 ch = getch();
  145.                 if (ch == 0x1B)
  146.                 {
  147.                     status = 1;
  148.                     break;
  149.                 }
  150.                 else if (ch == ' ')
  151.                 {
  152.                     toggle ^= 1;
  153.                     MOVIE_VGA_Output(toggle);
  154.                 }
  155.             }
  156.             if (!MOVIE_SendData()) break;
  157.             if (MOVIE_Error)
  158.             {
  159.                 status = 1;
  160.                 printf("Decoding error\n");
  161.                 break;
  162.             }
  163.         }
  164.         if (status) break;
  165.         if ( (!CDI) && (song==0) )
  166.         {
  167.             if (track >= endtrack) break;
  168.             track ++;
  169.             if (!MOVIE_CDROM_SeekTrack(track))
  170.             {
  171.                 MOVIE_Exit(0);
  172.                 printf("Fail to seek track %d of Video CD.\n",track);
  173.                 return 9;
  174.             }
  175.             MOVIE_Play();
  176.         }
  177.         else break;
  178.     }
  179.     MOVIE_Pause();
  180.     MOVIE_Exit(0);
  181.     return status;
  182. }
  183.