int MVE_rmPrepMovie(void *src, int x, int y, int track) { int i; if (mve) { mve_reset(mve); return 0; } mve = mve_open(src); if (!mve) return 1; g_destX = x; g_destY = y; for (i = 0; i < 32; i++) mve_set_handler(mve, i, default_seg_handler); mve_set_handler(mve, MVE_OPCODE_ENDOFSTREAM, end_movie_handler); mve_set_handler(mve, MVE_OPCODE_ENDOFCHUNK, end_chunk_handler); mve_set_handler(mve, MVE_OPCODE_CREATETIMER, create_timer_handler); mve_set_handler(mve, MVE_OPCODE_INITAUDIOBUFFERS, create_audiobuf_handler); mve_set_handler(mve, MVE_OPCODE_STARTSTOPAUDIO, play_audio_handler); mve_set_handler(mve, MVE_OPCODE_INITVIDEOBUFFERS, create_videobuf_handler); mve_set_handler(mve, MVE_OPCODE_DISPLAYVIDEO, display_video_handler); mve_set_handler(mve, MVE_OPCODE_AUDIOFRAMEDATA, audio_data_handler); mve_set_handler(mve, MVE_OPCODE_AUDIOFRAMESILENCE, audio_data_handler); mve_set_handler(mve, MVE_OPCODE_INITVIDEOMODE, init_video_handler); mve_set_handler(mve, MVE_OPCODE_SETPALETTE, video_palette_handler); mve_set_handler(mve, MVE_OPCODE_SETPALETTECOMPRESSED, default_seg_handler); mve_set_handler(mve, MVE_OPCODE_SETDECODINGMAP, video_codemap_handler); mve_set_handler(mve, MVE_OPCODE_VIDEODATA, video_data_handler); mve_play_next_chunk(mve); /* video initialization chunk */ mve_play_next_chunk(mve); /* audio initialization chunk */ return 0; }
// Play one movie bool movie_play(char *name) { // mark the movie as viewable to the player when in a campaign // do this before anything else so that we're sure the movie is available // to the player even if it's not going to play right now if (Game_mode & GM_CAMPAIGN_MODE) { cutscene_mark_viewable(name); } extern int Mouse_hidden; extern int Is_standalone; if (Cmdline_nomovies || Is_standalone) return false; char full_name[MAX_PATH]; int rc = 0; memset(full_name, 0, sizeof(full_name)); rc = movie_find(name, full_name); if (rc == MOVIE_NONE) { strcpy_s(full_name, name); char *p = strrchr(full_name, '.'); if ( p ) *p = 0; mprintf(("Movie Error: Unable to open '%s' movie in any supported format.\n", full_name)); return false; } // clear the screen and hide the mouse cursor Mouse_hidden++; gr_reset_clip(); gr_set_color(255, 255, 255); gr_set_clear_color(0, 0, 0); gr_zbuffer_clear(0); // clear first buffer gr_clear(); gr_flip(); // clear second buffer (may not be one, but that's ok) gr_clear(); gr_flip(); // clear third buffer (may not be one, but that's ok) gr_clear(); if (rc == MOVIE_OGG) { THEORAFILE *movie_ogg = theora_open(name); if (movie_ogg) { // start playing ... theora_play(movie_ogg); // ... done playing, close the movie theora_close(movie_ogg); } else { // uh-oh, movie is invalid... Abory, Retry, Fail? mprintf(("MOVIE ERROR: Found invalid movie! (%s)\n", name)); Mouse_hidden--; // show the mouse cursor! return false; } } else if (rc == MOVIE_MVE) { MVESTREAM *movie_mve = mve_open(name); if (movie_mve) { // start playing ... mve_init(movie_mve); mve_play(movie_mve); // ... done playing, close the movie mve_shutdown(); mve_close(movie_mve); } else { // uh-oh, movie is invalid... Abory, Retry, Fail? mprintf(("MOVIE ERROR: Found invalid movie! (%s)\n", name)); Mouse_hidden--; // show the mouse cursor! return false; } } // show the mouse cursor again Mouse_hidden--; return true; }