home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <conio.h>
- #include "mpgmovie.h"
-
- int DelayMiliSecond(long miliseconds)
- {
- int lobyte;
- int hibyte;
-
- miliseconds *= 1000L;
- lobyte = (int)miliseconds;
- hibyte = (int)(miliseconds>>16);
-
- _asm mov dx,lobyte
- _asm mov cx,hibyte
- _asm mov ah,86h
- _asm int 15h
- _asm jc error
- return 1;
- error:
- return 0;
- }
-
- int main(int argc,char *argv[])
- {
- int CDI;
- unsigned char starttrack;
- unsigned char endtrack;
- unsigned char track;
- unsigned int song;
- int status;
- int toggle;
- char title[80];
-
- if (argc == 1)
- {
- song = 0;
- }
- else if (argc == 2)
- {
- song = 0;
- sscanf(argv[1],"%d",&song);
- }
- else
- {
- printf("Usage: VIDEOCD <track number>\n");
- return 1;
- }
-
- if (!MOVIE_CDROM_Installed())
- {
- printf("No CD-ROM drive installed.\n");
- return 2;
- }
- status = MOVIE_Initialize(-1,-1);
- if (status == 0)
- {
- printf("Fail to detect hardware.\n");
- return 3;
- }
- else if (status == -1)
- {
- printf("Memory insufficient.\n");
- return 3;
- }
-
- if (!MOVIE_CDROM_HasDisc())
- {
- printf("No Disc in the CD-ROM drive.\n");
- MOVIE_Exit(0);
- return 4;
- }
-
- if (MOVIE_CDROM_IsDiscChanged())
- {
- printf("Disc is changed.\n");
- }
-
- CDI = MOVIE_CDROM_GetCDITitle(title);
-
- if (CDI)
- {
- if (MOVIE_CDROM_SeekCDI() != 0)
- {
- MOVIE_Exit(0);
- printf("Fail to seek Video CD (CD-I:%s).\n",title);
- return 5;
- }
- }
- else
- {
- if (!MOVIE_CDROM_GetTrackNo(&starttrack,&endtrack))
- {
- MOVIE_Exit(0);
- printf("Fail to get the track infomation of Video CD.\n");
- return 6;
- }
-
- if ( starttrack == endtrack )
- {
- MOVIE_Exit(0);
- printf("The CD-ROM is not Video CD.\n");
- return 7;
- }
-
- if (song != 0)
- {
- track = (unsigned char)(song + 1);
- if (track > endtrack)
- {
- MOVIE_Exit(0);
- printf("The track number is out of range [1..%d].\n",endtrack-1);
- return 8;
- }
- }
- else
- {
- track = 2;
- }
-
- if (!MOVIE_CDROM_SeekTrack(track))
- {
- MOVIE_Exit(0);
- printf("Fail to seek track %d of Video CD.\n",track);
- return 9;
- }
- }
-
- toggle = 0;
- MOVIE_VGA_Output(toggle);
-
- DelayMiliSecond(1000L);
-
- MOVIE_Play();
- status = 0;
- while (1)
- {
- while (1)
- {
- if (kbhit())
- {
- int ch;
-
- ch = getch();
- if (ch == 0x1B)
- {
- status = 1;
- break;
- }
- else if (ch == ' ')
- {
- toggle ^= 1;
- MOVIE_VGA_Output(toggle);
- }
- }
- if (!MOVIE_SendData()) break;
- if (MOVIE_Error)
- {
- status = 1;
- printf("Decoding error\n");
- break;
- }
- }
- if (status) break;
- if ( (!CDI) && (song==0) )
- {
- if (track >= endtrack) break;
- track ++;
- if (!MOVIE_CDROM_SeekTrack(track))
- {
- MOVIE_Exit(0);
- printf("Fail to seek track %d of Video CD.\n",track);
- return 9;
- }
- MOVIE_Play();
- }
- else break;
- }
- MOVIE_Pause();
- MOVIE_Exit(0);
- return status;
- }