]> icculus.org git repositories - btb/d2x.git/blob - main/mve_main.c
lotsa movie cleanups, added truecolor mve support, standalone mveplayer
[btb/d2x.git] / main / mve_main.c
1 #include <SDL/SDL.h>
2
3 #include "mvelib.h"
4
5 extern int g_spdFactorNum;
6
7 void initializeMovie(MVESTREAM *mve);
8 void playMovie(MVESTREAM *mve);
9 void shutdownMovie(MVESTREAM *mve);
10
11 static void usage(void)
12 {
13     fprintf(stderr, "usage: mveplay filename\n");
14     exit(1);
15 }
16
17 static int doPlay(const char *filename)
18 {
19     MVESTREAM *mve = mve_open(filename);
20     if (mve == NULL)
21     {
22         fprintf(stderr, "can't open MVE file '%s'\n", filename);
23         return 1;
24     }
25
26     initializeMovie(mve);
27     playMovie(mve);
28     shutdownMovie(mve);
29
30     mve_close(mve);
31
32     return 0;
33 }
34
35 int main(int c, char **v)
36 {
37     if (c != 2  &&  c != 3)
38         usage();
39
40     if (c == 3)
41         g_spdFactorNum = atoi(v[2]);
42
43     if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0)
44     {
45         fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
46         exit(1);
47     }
48     atexit(SDL_Quit);
49
50     return doPlay(v[1]);
51 }