1 /* $Id: mve_main.c,v 1.2 2003-02-19 00:42:40 btb Exp $ */
17 #define SWAPINT(x) (((x)<<24) | (((unsigned int)(x)) >> 24) | (((x) &0x0000ff00) << 8) | (((x) & 0x00ff0000) >> 8))
21 extern int g_spdFactorNum;
22 extern int g_sdlVidFlags;
25 void initializeMovie(MVESTREAM *mve);
26 void playMovie(MVESTREAM *mve);
27 void shutdownMovie(MVESTREAM *mve);
29 static void usage(void)
31 fprintf(stderr, "usage: mveplay [-f] [-l] [-s <n>] [<mvlfile>] <filename>\n"
32 "-f\tFullscreen mode\n"
33 "-s\tSpeed Factor <n>\n"
38 static int doPlay(int filehandle)
40 MVESTREAM *mve = mve_open_filehandle(filehandle);
42 fprintf(stderr, "can't open MVE file\n");
50 mve_close_filehandle(mve);
55 int main(int argc, char *argv[])
58 char *mvlfile = NULL, *mvefile = NULL;
60 for (i = 1; i < argc; i++) {
61 if (!strcmp(argv[i], "-h"))
64 if (!strcmp(argv[i], "-f"))
65 g_sdlVidFlags |= SDL_FULLSCREEN;
67 if (!strcmp(argv[i], "-l"))
70 if (!strcmp(argv[i], "-s")) {
73 g_spdFactorNum = atoi(argv[i + 1]);
77 if (strchr(argv[i], '.') && !strcasecmp(strchr(argv[i], '.'), ".mvl"))
80 if (strchr(argv[i], '.') && !strcasecmp(strchr(argv[i], '.'), ".mve"))
86 char filename[MAX_FILES][13];
87 int filesize[MAX_FILES];
91 filehandle = open(mvlfile, O_RDONLY | O_BINARY);
93 filehandle = open(mvlfile, O_RDONLY);
95 if (filehandle == -1) {
96 fprintf(stderr, "Error opening %s\n", mvlfile);
99 if ((read(filehandle, sig, 4) < 4) ||
100 (strncmp(sig, "DMVL", 4)) ||
101 (read(filehandle, &nfiles, 4) < 4)) {
102 fprintf(stderr, "Error reading %s\n", mvlfile);
105 #ifdef WORDS_BIGENDIAN
106 nfiles = SWAPINT(nfiles);
108 if (nfiles > MAX_FILES) {
109 fprintf(stderr, "Error reading %s: nfiles = %d, MAX_FILES = %d\n",
110 mvlfile, nfiles, MAX_FILES);
112 for (i = 0; i < nfiles; i++) {
113 if ((read(filehandle, filename[i], 13) < 13) ||
114 (read(filehandle, &filesize[i], 4) < 4) ||
115 (strlen(filename[i]) > 12)) {
116 fprintf(stderr, "Error reading %s\n", mvlfile);
119 #ifdef WORDS_BIGENDIAN
120 filesize[i] = SWAPINT(filesize[i]);
124 for (i = 0; i < nfiles; i++) {
126 if (!strcasecmp(filename[i], mvefile))
129 lseek(filehandle, filesize[i], SEEK_CUR);
131 printf("%13s\t%d\n", filename[i], filesize[i]);
136 } else if (mvefile) {
138 filehandle = open(mvefile, O_RDONLY | O_BINARY);
140 filehandle = open(mvefile, O_RDONLY);
145 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0)
147 fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());