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