]> icculus.org git repositories - btb/d2x.git/blob - main/movie.c
implement removeext, use it in dsload instead of splitpath
[btb/d2x.git] / main / movie.c
1 /* $Id: movie.c,v 1.37 2004-12-01 12:48:13 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Movie Playing Stuff
18  *
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #include <conf.h>
23 #endif
24
25 #ifdef RCS
26 static char rcsid[] = "$Id: movie.c,v 1.37 2004-12-01 12:48:13 btb Exp $";
27 #endif
28
29 #define DEBUG_LEVEL CON_NORMAL
30
31 #include <string.h>
32 #ifndef macintosh
33 # ifndef _WIN32_WCE
34 #  include <sys/types.h>
35 #  include <sys/stat.h>
36 #  include <fcntl.h>
37 # endif
38 # ifndef _MSC_VER
39 #  include <unistd.h>
40 # endif
41 #endif // ! macintosh
42 #include <ctype.h>
43
44 #include "movie.h"
45 #include "console.h"
46 #include "args.h"
47 #include "key.h"
48 #include "digi.h"
49 #include "songs.h"
50 #include "inferno.h"
51 #include "palette.h"
52 #include "strutil.h"
53 #include "error.h"
54 #include "u_mem.h"
55 #include "byteswap.h"
56 #include "gr.h"
57 #include "gamefont.h"
58 #include "cfile.h"
59 #include "menu.h"
60 #include "libmve.h"
61 #include "text.h"
62 #include "screens.h"
63 #include "physfsrwops.h"
64
65 extern int MenuHiresAvailable;
66 extern char CDROM_dir[];
67
68 #define VID_PLAY 0
69 #define VID_PAUSE 1
70
71 int Vid_State;
72
73
74 // Subtitle data
75 typedef struct {
76         short first_frame,last_frame;
77         char *msg;
78 } subtitle;
79
80 #define MAX_SUBTITLES 500
81 #define MAX_ACTIVE_SUBTITLES 3
82 subtitle Subtitles[MAX_SUBTITLES];
83 int Num_subtitles;
84
85 // Movielib data
86
87 #ifdef D2_OEM
88 char movielib_files[5][FILENAME_LEN] = {"intro","other","robots","oem"};
89 #else
90 char movielib_files[4][FILENAME_LEN] = {"intro","other","robots"};
91 #endif
92
93 #define N_MOVIE_LIBS (sizeof(movielib_files) / sizeof(*movielib_files))
94 #define N_BUILTIN_MOVIE_LIBS (N_MOVIE_LIBS - 1)
95 #define EXTRA_ROBOT_LIB N_BUILTIN_MOVIE_LIBS
96
97 int MovieHires = 1;   //default is highres
98
99 SDL_RWops *RoboFile;
100
101 // Function Prototypes
102 int RunMovie(char *filename, int highres_flag, int allow_abort,int dx,int dy);
103
104 void change_filename_ext( char *dest, char *src, char *ext );
105 void decode_text_line(char *p);
106 void draw_subtitles(int frame_num);
107
108
109 // ----------------------------------------------------------------------
110 void* MPlayAlloc(unsigned size)
111 {
112     return d_malloc(size);
113 }
114
115 void MPlayFree(void *p)
116 {
117     d_free(p);
118 }
119
120
121 //-----------------------------------------------------------------------
122
123 unsigned int FileRead(void *handle, void *buf, unsigned int count)
124 {
125     unsigned numread;
126     numread = SDL_RWread((SDL_RWops *)handle, buf, 1, count);
127     return (numread == count);
128 }
129
130
131 //-----------------------------------------------------------------------
132
133
134 //filename will actually get modified to be either low-res or high-res
135 //returns status.  see values in movie.h
136 int PlayMovie(const char *filename, int must_have)
137 {
138         char name[FILENAME_LEN],*p;
139         int c, ret;
140
141         if (FindArg("-nomovies"))
142                 return MOVIE_NOT_PLAYED;
143
144         strcpy(name,filename);
145
146         if ((p=strchr(name,'.')) == NULL)               //add extension, if missing
147                 strcat(name,".mve");
148
149         //check for escape already pressed & abort if so
150         while ((c=key_inkey()) != 0)
151                 if (c == KEY_ESC)
152                         return MOVIE_ABORTED;
153
154         // Stop all digital sounds currently playing.
155         digi_stop_all();
156
157         // Stop all songs
158         songs_stop_all();
159
160         digi_close();
161
162         // Start sound
163         if (!FindArg("-nosound"))
164                 MVE_sndInit(1);
165         else
166                 MVE_sndInit(-1);
167
168         ret = RunMovie(name,MovieHires,must_have,-1,-1);
169
170         if (!FindArg("-nosound"))
171                 digi_init();
172
173         Screen_mode = -1;               //force screen reset
174
175         return ret;
176 }
177
178
179 void MovieShowFrame(ubyte *buf, uint bufw, uint bufh, uint sx, uint sy,
180                                         uint w, uint h, uint dstx, uint dsty)
181 {
182         grs_bitmap source_bm;
183
184         //mprintf((0,"MovieShowFrame %d,%d  %d,%d  %d,%d  %d,%d\n",bufw,bufh,sx,sy,w,h,dstx,dsty));
185
186         Assert(bufw == w && bufh == h);
187
188         source_bm.bm_x = source_bm.bm_y = 0;
189         source_bm.bm_w = source_bm.bm_rowsize = bufw;
190         source_bm.bm_h = bufh;
191         source_bm.bm_type = BM_LINEAR;
192         source_bm.bm_flags = 0;
193         source_bm.bm_data = buf;
194
195         gr_bm_ubitblt(bufw,bufh,dstx,dsty,sx,sy,&source_bm,&grd_curcanv->cv_bitmap);
196 }
197
198 //our routine to set the pallete, called from the movie code
199 void MovieSetPalette(unsigned char *p, unsigned start, unsigned count)
200 {
201         if (count == 0)
202                 return;
203
204         //mprintf((0,"SetPalette p=%x, start=%d, count=%d\n",p,start,count));
205
206         //Color 0 should be black, and we get color 255
207         Assert(start>=1 && start+count-1<=254);
208
209         //Set color 0 to be black
210         gr_palette[0] = gr_palette[1] = gr_palette[2] = 0;
211
212         //Set color 255 to be our subtitle color
213         gr_palette[765] = gr_palette[766] = gr_palette[767] = 50;
214
215         //movie libs palette into our array
216         memcpy(gr_palette+start*3,p+start*3,count*3);
217
218         //finally set the palette in the hardware
219         //gr_palette_load(gr_palette);
220
221         //MVE_SetPalette(p, start, count);
222 }
223
224
225 #if 0
226 typedef struct bkg {
227         short x, y, w, h;           // The location of the menu.
228         grs_bitmap * bmp;               // The background under the menu.
229 } bkg;
230
231 bkg movie_bg = {0,0,0,0,NULL};
232 #endif
233
234 #define BOX_BORDER (MenuHires?40:20)
235
236
237 void show_pause_message(char *msg)
238 {
239         int w,h,aw;
240         int x,y;
241
242         gr_set_current_canvas(NULL);
243         gr_set_curfont( SMALL_FONT );
244
245         gr_get_string_size(msg,&w,&h,&aw);
246
247         x = (grd_curscreen->sc_w-w)/2;
248         y = (grd_curscreen->sc_h-h)/2;
249
250 #if 0
251         if (movie_bg.bmp) {
252                 gr_free_bitmap(movie_bg.bmp);
253                 movie_bg.bmp = NULL;
254         }
255
256         // Save the background of the display
257         movie_bg.x=x; movie_bg.y=y; movie_bg.w=w; movie_bg.h=h;
258
259         movie_bg.bmp = gr_create_bitmap( w+BOX_BORDER, h+BOX_BORDER );
260
261         gr_bm_ubitblt(w+BOX_BORDER, h+BOX_BORDER, 0, 0, x-BOX_BORDER/2, y-BOX_BORDER/2, &(grd_curcanv->cv_bitmap), movie_bg.bmp );
262 #endif
263
264         gr_setcolor(0);
265         gr_rect(x-BOX_BORDER/2,y-BOX_BORDER/2,x+w+BOX_BORDER/2-1,y+h+BOX_BORDER/2-1);
266
267         gr_set_fontcolor( 255, -1 );
268
269         gr_ustring( 0x8000, y, msg );
270
271         gr_update();
272 }
273
274 void clear_pause_message()
275 {
276 #if 0
277         if (movie_bg.bmp) {
278
279                 gr_bitmap(movie_bg.x-BOX_BORDER/2, movie_bg.y-BOX_BORDER/2, movie_bg.bmp);
280
281                 gr_free_bitmap(movie_bg.bmp);
282                 movie_bg.bmp = NULL;
283         }
284 #endif
285 }
286
287
288 //returns status.  see movie.h
289 int RunMovie(char *filename, int hires_flag, int must_have,int dx,int dy)
290 {
291         SDL_RWops *filehndl;
292         int result=1,aborted=0;
293         int track = 0;
294         int frame_num;
295         int key;
296 #ifdef OGL
297         ubyte pal_save[768];
298 #endif
299
300         result=1;
301
302         // Open Movie file.  If it doesn't exist, no movie, just return.
303
304         filehndl = PHYSFSRWOPS_openRead(filename);
305
306         if (!filehndl)
307         {
308                 if (must_have)
309                         Warning("movie: RunMovie: Cannot open movie <%s>: %s\n", filename, PHYSFS_getLastError());
310                 return MOVIE_NOT_PLAYED;
311         }
312
313         MVE_memCallbacks(MPlayAlloc, MPlayFree);
314         MVE_ioCallbacks(FileRead);
315
316         if (hires_flag) {
317                 gr_set_mode(SM(640,480));
318         } else {
319                 gr_set_mode(SM(320,200));
320         }
321 #ifdef OGL
322         set_screen_mode(SCREEN_MENU);
323         gr_copy_palette(pal_save, gr_palette, 768);
324         memset(gr_palette, 0, 768);
325         gr_palette_load(gr_palette);
326 #endif
327
328 #if !defined(POLY_ACC)
329         MVE_sfCallbacks(MovieShowFrame);
330         MVE_palCallbacks(MovieSetPalette);
331 #endif
332
333         if (MVE_rmPrepMovie((void *)filehndl, dx, dy, track)) {
334                 Int3();
335                 return MOVIE_NOT_PLAYED;
336         }
337
338 #if !defined(POLY_ACC)
339         MVE_sfCallbacks(MovieShowFrame);
340         MVE_palCallbacks(MovieSetPalette);
341 #endif
342
343         frame_num = 0;
344
345         FontHires = FontHiresAvailable && hires_flag;
346
347         while((result = MVE_rmStepMovie()) == 0) {
348
349                 draw_subtitles(frame_num);
350
351                 gr_palette_load(gr_palette); // moved this here because of flashing
352
353                 gr_update();
354
355                 key = key_inkey();
356
357                 // If ESCAPE pressed, then quit movie.
358                 if (key == KEY_ESC) {
359                         result = aborted = 1;
360                         break;
361                 }
362
363                 // If PAUSE pressed, then pause movie
364                 if (key == KEY_PAUSE) {
365                         MVE_rmHoldMovie();
366                         show_pause_message(TXT_PAUSE);
367                         while (!key_inkey()) ;
368                         clear_pause_message();
369                 }
370
371 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
372                 if ((key == KEY_ALTED+KEY_ENTER) ||
373                     (key == KEY_ALTED+KEY_PADENTER))
374                         gr_toggle_fullscreen();
375 #endif
376
377                 frame_num++;
378         }
379
380         Assert(aborted || result == MVE_ERR_EOF);        ///movie should be over
381
382     MVE_rmEndMovie();
383
384         SDL_FreeRW(filehndl);                           // Close Movie File
385
386         // Restore old graphic state
387
388         Screen_mode=-1;  //force reset of screen mode
389 #ifdef OGL
390         gr_copy_palette(gr_palette, pal_save, 768);
391         gr_palette_load(pal_save);
392 #endif
393
394         return (aborted?MOVIE_ABORTED:MOVIE_PLAYED_FULL);
395 }
396
397
398 int InitMovieBriefing()
399 {
400 #if 0
401         if (MenuHires)
402                 gr_set_mode(SM(640,480));
403         else
404                 gr_set_mode(SM(320,200));
405
406         gr_init_sub_canvas( &VR_screen_pages[0], &grd_curscreen->sc_canvas, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h );
407         gr_init_sub_canvas( &VR_screen_pages[1], &grd_curscreen->sc_canvas, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h );
408 #endif
409
410         return 1;
411 }
412
413
414 //returns 1 if frame updated ok
415 int RotateRobot()
416 {
417         int err;
418
419         err = MVE_rmStepMovie();
420
421         gr_palette_load(gr_palette);
422
423         if (err == MVE_ERR_EOF)     //end of movie, so reset
424         {
425                 SDL_RWseek(RoboFile, 0, SEEK_SET);
426                 if (MVE_rmPrepMovie(RoboFile, MenuHires?280:140, MenuHires?200:80, 0))
427                 {
428                         Int3();
429                         return 0;
430                 }
431         }
432         else if (err) {
433                 Int3();
434                 return 0;
435         }
436
437         return 1;
438 }
439
440
441 void DeInitRobotMovie(void)
442 {
443         MVE_rmEndMovie();
444         SDL_FreeRW(RoboFile);                           // Close Movie File
445 }
446
447
448 int InitRobotMovie(char *filename)
449 {
450         if (FindArg("-nomovies"))
451                 return 0;
452
453         con_printf(DEBUG_LEVEL, "RoboFile=%s\n", filename);
454
455         MVE_sndInit(-1);        //tell movies to play no sound for robots
456
457         RoboFile = PHYSFSRWOPS_openRead(filename);
458
459         if (!RoboFile)
460         {
461                 Warning("movie: InitRobotMovie: Cannot open movie file <%s>: %s\n", filename, PHYSFS_getLastError());
462                 return MOVIE_NOT_PLAYED;
463         }
464
465         Vid_State = VID_PLAY;
466
467         if (MVE_rmPrepMovie((void *)RoboFile, MenuHires?280:140, MenuHires?200:80, 0)) {
468                 Int3();
469                 return 0;
470         }
471
472         return 1;
473 }
474
475
476 /*
477  *              Subtitle system code
478  */
479
480 char *subtitle_raw_data;
481
482
483 //search for next field following whitespace 
484 char *next_field (char *p)
485 {
486         while (*p && !isspace(*p))
487                 p++;
488
489         if (!*p)
490                 return NULL;
491
492         while (*p && isspace(*p))
493                 p++;
494
495         if (!*p)
496                 return NULL;
497
498         return p;
499 }
500
501
502 int init_subtitles(char *filename)
503 {
504         CFILE *ifile;
505         int size,read_count;
506         char *p;
507         int have_binary = 0;
508
509         Num_subtitles = 0;
510
511         if (! FindArg("-subtitles"))
512                 return 0;
513
514         ifile = cfopen(filename,"rb");          //try text version
515
516         if (!ifile) {                                                           //no text version, try binary version
517                 char filename2[FILENAME_LEN];
518                 change_filename_ext(filename2,filename,".TXB");
519                 ifile = cfopen(filename2,"rb");
520                 if (!ifile)
521                         return 0;
522                 have_binary = 1;
523         }
524
525         size = cfilelength(ifile);
526
527         MALLOC (subtitle_raw_data, char, size+1);
528
529         read_count = cfread(subtitle_raw_data, 1, size, ifile);
530
531         cfclose(ifile);
532
533         subtitle_raw_data[size] = 0;
534
535         if (read_count != size) {
536                 d_free(subtitle_raw_data);
537                 return 0;
538         }
539
540         p = subtitle_raw_data;
541
542         while (p && p < subtitle_raw_data+size) {
543                 char *endp;
544
545                 endp = strchr(p,'\n'); 
546                 if (endp) {
547                         if (endp[-1] == '\r')
548                                 endp[-1] = 0;           //handle 0d0a pair
549                         *endp = 0;                      //string termintor
550                 }
551
552                 if (have_binary)
553                         decode_text_line(p);
554
555                 if (*p != ';') {
556                         Subtitles[Num_subtitles].first_frame = atoi(p);
557                         p = next_field(p); if (!p) continue;
558                         Subtitles[Num_subtitles].last_frame = atoi(p);
559                         p = next_field(p); if (!p) continue;
560                         Subtitles[Num_subtitles].msg = p;
561
562                         Assert(Num_subtitles==0 || Subtitles[Num_subtitles].first_frame >= Subtitles[Num_subtitles-1].first_frame);
563                         Assert(Subtitles[Num_subtitles].last_frame >= Subtitles[Num_subtitles].first_frame);
564
565                         Num_subtitles++;
566                 }
567
568                 p = endp+1;
569
570         }
571
572         return 1;
573 }
574
575
576 void close_subtitles()
577 {
578         if (subtitle_raw_data)
579                 d_free(subtitle_raw_data);
580         subtitle_raw_data = NULL;
581         Num_subtitles = 0;
582 }
583
584
585 //draw the subtitles for this frame
586 void draw_subtitles(int frame_num)
587 {
588         static int active_subtitles[MAX_ACTIVE_SUBTITLES];
589         static int num_active_subtitles,next_subtitle,line_spacing;
590         int t,y;
591         int must_erase=0;
592
593         if (frame_num == 0) {
594                 num_active_subtitles = 0;
595                 next_subtitle = 0;
596                 gr_set_curfont( GAME_FONT );
597                 line_spacing = grd_curcanv->cv_font->ft_h + (grd_curcanv->cv_font->ft_h >> 2);
598                 gr_set_fontcolor(255,-1);
599         }
600
601         //get rid of any subtitles that have expired
602         for (t=0;t<num_active_subtitles;)
603                 if (frame_num > Subtitles[active_subtitles[t]].last_frame) {
604                         int t2;
605                         for (t2=t;t2<num_active_subtitles-1;t2++)
606                                 active_subtitles[t2] = active_subtitles[t2+1];
607                         num_active_subtitles--;
608                         must_erase = 1;
609                 }
610                 else
611                         t++;
612
613         //get any subtitles new for this frame 
614         while (next_subtitle < Num_subtitles && frame_num >= Subtitles[next_subtitle].first_frame) {
615                 if (num_active_subtitles >= MAX_ACTIVE_SUBTITLES)
616                         Error("Too many active subtitles!");
617                 active_subtitles[num_active_subtitles++] = next_subtitle;
618                 next_subtitle++;
619         }
620
621         //find y coordinate for first line of subtitles
622         y = grd_curcanv->cv_bitmap.bm_h-((line_spacing+1)*MAX_ACTIVE_SUBTITLES+2);
623
624         //erase old subtitles if necessary
625         if (must_erase) {
626                 gr_setcolor(0);
627                 gr_rect(0,y,grd_curcanv->cv_bitmap.bm_w-1,grd_curcanv->cv_bitmap.bm_h-1);
628         }
629
630         //now draw the current subtitles
631         for (t=0;t<num_active_subtitles;t++)
632                 if (active_subtitles[t] != -1) {
633                         gr_string(0x8000,y,Subtitles[active_subtitles[t]].msg);
634                         y += line_spacing+1;
635                 }
636 }
637
638
639 void close_movie(char *movielib, int is_robots)
640 {
641         int high_res;
642         char filename[FILENAME_LEN];
643
644         if (is_robots)
645                 high_res = MenuHiresAvailable;
646         else
647                 high_res = MovieHires;
648
649         sprintf(filename, "%s-%s.mvl", movielib, high_res?"h":"l");
650
651         if (!cfile_close(filename))
652         {
653                 Warning("Couldn't remove movielib <%s>: %s\n", filename, PHYSFS_getLastError());
654                 sprintf(filename, "%s-%s.mvl", movielib, high_res?"l":"h");
655
656                 if (!cfile_close(filename))
657                         Warning("Couldn't remove movielib <%s>: %s\n", filename, PHYSFS_getLastError());
658         }
659 }
660
661 void close_movies()
662 {
663         int i, is_robots;
664
665         for (i = 0 ; i < N_BUILTIN_MOVIE_LIBS ; i++)
666         {
667                 if (!strnicmp(movielib_files[i], "robot", 5))
668                         is_robots = 1;
669                 else
670                         is_robots = 0;
671
672                 close_movie(movielib_files[i], is_robots);
673         }
674 }
675
676
677 //ask user to put the D2 CD in.
678 //returns -1 if ESC pressed, 0 if OK chosen
679 //CD may not have been inserted
680 int request_cd(void)
681 {
682 #if 0
683         ubyte save_pal[256*3];
684         grs_canvas *save_canv,*tcanv;
685         int ret,was_faded=gr_palette_faded_out;
686
687         gr_palette_clear();
688
689         save_canv = grd_curcanv;
690         tcanv = gr_create_canvas(grd_curcanv->cv_w,grd_curcanv->cv_h);
691
692         gr_set_current_canvas(tcanv);
693         gr_ubitmap(0,0,&save_canv->cv_bitmap);
694         gr_set_current_canvas(save_canv);
695
696         gr_clear_canvas(BM_XRGB(0,0,0));
697
698         memcpy(save_pal,gr_palette,sizeof(save_pal));
699
700         memcpy(gr_palette,last_palette_for_color_fonts,sizeof(gr_palette));
701
702  try_again:;
703
704         ret = nm_messagebox( "CD ERROR", 1, "Ok", "Please insert your Descent II CD");
705
706         if (ret == -1) {
707                 int ret2;
708
709                 ret2 = nm_messagebox( "CD ERROR", 2, "Try Again", "Leave Game", "You must insert your\nDescent II CD to Continue");
710
711                 if (ret2 == -1 || ret2 == 0)
712                         goto try_again;
713         }
714
715         force_rb_register = 1;  //disc has changed; force register new CD
716
717         gr_palette_clear();
718
719         memcpy(gr_palette,save_pal,sizeof(save_pal));
720
721         gr_ubitmap(0,0,&tcanv->cv_bitmap);
722
723         if (!was_faded)
724                 gr_palette_load(gr_palette);
725
726         gr_free_canvas(tcanv);
727
728         return ret;
729 #else
730         con_printf(DEBUG_LEVEL, "STUB: movie: request_cd\n");
731         return 0;
732 #endif
733 }
734
735
736 void init_movie(char *movielib, int is_robots, int required)
737 {
738         int high_res;
739         char filename[FILENAME_LEN];
740
741         //for robots, load highres versions if highres menus set
742         if (is_robots)
743                 high_res = MenuHiresAvailable;
744         else
745                 high_res = MovieHires;
746
747         sprintf(filename, "%s-%s.mvl", movielib, high_res?"h":"l");
748
749         if (!cfile_init(filename))
750         {
751                 if (required)
752                         Warning("Cannot open movie file <%s>: %s\n", filename, PHYSFS_getLastError());
753
754                 sprintf(filename, "%s-%s.mvl", movielib, high_res?"l":"h");
755
756                 if (!cfile_init(filename))
757                         if (required)
758                                 Warning("Cannot open movie file <%s>: %s\n", filename, PHYSFS_getLastError());
759         }
760 }
761
762
763 //find and initialize the movie libraries
764 void init_movies()
765 {
766         int i;
767         int is_robots;
768
769         if (FindArg("-nomovies"))
770                 return;
771
772         for (i=0;i<N_BUILTIN_MOVIE_LIBS;i++) {
773
774                 if (!strnicmp(movielib_files[i],"robot",5))
775                         is_robots = 1;
776                 else
777                         is_robots = 0;
778
779                 init_movie(movielib_files[i], is_robots, 1);
780         }
781
782         atexit(close_movies);
783 }
784
785
786 void close_extra_robot_movie(void)
787 {
788         if (strlen(movielib_files[EXTRA_ROBOT_LIB]))
789                 if (!cfile_close(movielib_files[EXTRA_ROBOT_LIB]))
790                         Warning("Couldn't remove robot lib: %s\n", PHYSFS_getLastError());
791 }
792
793 void init_extra_robot_movie(char *movielib)
794 {
795         if (FindArg("-nomovies"))
796                 return;
797
798         close_extra_robot_movie();
799         init_movie(movielib, 1, 0);
800         strcpy(movielib_files[EXTRA_ROBOT_LIB], movielib);
801         atexit(close_extra_robot_movie);
802 }