]> icculus.org git repositories - taylor/freespace2.git/blob - src/movie/movie.cpp
various cleanups
[taylor/freespace2.git] / src / movie / movie.cpp
1 /*
2  * $Logfile: /Freespace2/src/movie/movie.cpp $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Frontend for MVE playing
8  *
9  * $Log$
10  * Revision 1.5  2005/10/01 21:48:01  taylor
11  * various cleanups
12  * fix decoder to swap opcode 0xb since it screws up on PPC
13  * the previous opcode 0xc change was wrong since we had already determined that it messes up FS1 movies
14  *
15  * Revision 1.4  2005/03/29 07:50:34  taylor
16  * Update to newest movie code with much better video support and audio support from
17  *   Pierre Willenbrock.  Movies are enabled always now (no longer a build option)
18  *   and but can be skipped with the "--nomovies" or "-n" cmdline options.
19  *
20  *
21  *
22  * $NoKeywords: $
23  *
24  */
25
26 #include "pstypes.h"
27 #include "mvelib.h"
28 #include "movie.h"
29 #include "cutscenes.h"
30 #include "freespace.h"
31 #include "mouse.h"
32 #include "sound.h"
33 #include "cmdline.h"
34 #include "gamesequence.h"
35 #include "mainhallmenu.h"
36
37 int movie_play(char *filename, int cd_prompt)
38 {
39         // mark the movie as viewable in the techroom if in a campaign
40         if (Game_mode & GM_CAMPAIGN_MODE) {
41                 cutscene_mark_viewable(filename);
42         }
43
44         if (Cmdline_play_movies) {
45                 MVESTREAM *movie;
46
47                 // umm, yeah
48         //      if ( cd_prompt == -1 )
49         //              cd_prompt = require_cd;
50
51                 // look for correct CD when viewing movies in the tech room
52         //      if (gameseq_get_state() == GS_STATE_VIEW_CUTSCENES) {
53         //              cutscenes_validate_cd(filename, cd_prompt);
54         //      }
55
56                 movie = mve_open(filename);
57
58                 if (movie) {
59                         // kill all background sounds
60                         game_stop_looped_sounds();
61                         main_hall_stop_music();
62                         main_hall_stop_ambient();
63
64                         // clear the screen and hide the mouse cursor
65                         Mouse_hidden++;
66                         gr_reset_clip();
67                         gr_clear();
68                         gr_flip();
69                         gr_zbuffer_clear(1);    // G400, blah
70                         
71                         // ready to play...
72                         mve_init(movie);
73                         mve_play(movie);
74
75                         // ...done playing, close the mve and show the cursor again
76                         mve_shutdown();
77                         mve_close(movie);
78
79                         Mouse_hidden--;
80                         main_hall_start_ambient();
81                 } else {
82                         printf("Can't open movie file: '%s'\n", filename);
83                         return 0;
84                 }
85         
86         } else {
87                 mprintf(("Movies are disabled, skipping...\n"));
88         }
89
90         return 1;
91 }
92
93 int movie_play_two(char *filename1, char *filename2)
94 {
95         // FIXME: part of the CD code which isn't included yet
96         int require_cd = 0;
97
98         // make sure the first movie played correctly, then play the second one
99         if (movie_play(filename1, require_cd)) {
100                 movie_play(filename2, require_cd);
101         } else {
102                 printf("Not playing second movie: %s\n", filename2);
103                 return 0;
104         }
105
106         return 1;
107 }