aboutsummaryrefslogtreecommitdiff
path: root/graphics/animation.cpp
diff options
context:
space:
mode:
authorMax Horn2004-03-22 20:46:30 +0000
committerMax Horn2004-03-22 20:46:30 +0000
commitd24be923f3dbe27e740cbc5da410d5b7dac24fff (patch)
tree4c072857c5a263bd3d3cd83e7af2291e512ba1cc /graphics/animation.cpp
parent8f9ffdf43afa8a99ce23fd62ee9480317eec78ad (diff)
downloadscummvm-rg350-d24be923f3dbe27e740cbc5da410d5b7dac24fff.tar.gz
scummvm-rg350-d24be923f3dbe27e740cbc5da410d5b7dac24fff.tar.bz2
scummvm-rg350-d24be923f3dbe27e740cbc5da410d5b7dac24fff.zip
share 'init' method, too
svn-id: r13361
Diffstat (limited to 'graphics/animation.cpp')
-rw-r--r--graphics/animation.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/graphics/animation.cpp b/graphics/animation.cpp
index d8219c5a55..4808402a46 100644
--- a/graphics/animation.cpp
+++ b/graphics/animation.cpp
@@ -47,6 +47,109 @@ BaseAnimationState::~BaseAnimationState() {
}
+bool BaseAnimationState::init(const char *name) {
+#ifdef USE_MPEG2
+ char tempFile[512];
+
+ decoder = NULL;
+ mpgfile = NULL;
+ sndfile = NULL;
+ bgSoundStream = NULL;
+
+#ifdef BACKEND_8BIT
+
+ uint i, p;
+
+ // Load lookup palettes
+ // TODO: Binary format so we can use File class
+ sprintf(tempFile, "%s.pal", name);
+ FILE *f = fopen(tempFile, "r");
+
+ if (!f) {
+ warning("Cutscene: %s.pal palette missing", name);
+ return false;
+ }
+
+ p = 0;
+ while (!feof(f)) {
+ int end, cnt;
+
+ if (fscanf(f, "%i %i", &end, &cnt) != 2)
+ break;
+
+ palettes[p].end = (uint) end;
+ palettes[p].cnt = (uint) cnt;
+
+ for (i = 0; i < palettes[p].cnt; i++) {
+ int r, g, b;
+ fscanf(f, "%i", &r);
+ fscanf(f, "%i", &g);
+ fscanf(f, "%i", &b);
+ palettes[p].pal[4 * i] = r;
+ palettes[p].pal[4 * i + 1] = g;
+ palettes[p].pal[4 * i + 2] = b;
+ palettes[p].pal[4 * i + 3] = 0;
+ }
+ for (; i < 256; i++) {
+ palettes[p].pal[4 * i] = 0;
+ palettes[p].pal[4 * i + 1] = 0;
+ palettes[p].pal[4 * i + 2] = 0;
+ palettes[p].pal[4 * i + 3] = 0;
+ }
+ p++;
+ }
+ fclose(f);
+
+ palnum = 0;
+ maxPalnum = p;
+ setPalette(palettes[palnum].pal);
+ lut = lut2 = lookup[0];
+ curpal = -1;
+ cr = 0;
+ buildLookup(palnum, 256);
+ lut2 = lookup[1];
+ lutcalcnum = (BITDEPTH + palettes[palnum].end + 2) / (palettes[palnum].end + 2);
+#else
+ buildLookup();
+ overlay = (OverlayColor*)calloc(MOVIE_WIDTH * MOVIE_HEIGHT, sizeof(OverlayColor));
+ _sys->show_overlay();
+#endif
+
+ // Open MPEG2 stream
+ mpgfile = new File();
+ sprintf(tempFile, "%s.mp2", name);
+ if (!mpgfile->open(tempFile)) {
+ warning("Cutscene: Could not open %s", tempFile);
+ return false;
+ }
+
+ // Load and configure decoder
+ decoder = mpeg2_init();
+ if (decoder == NULL) {
+ warning("Cutscene: Could not allocate an MPEG2 decoder");
+ return false;
+ }
+
+ info = mpeg2_info(decoder);
+ framenum = 0;
+ frameskipped = 0;
+ ticks = _sys->get_msecs();
+
+ // Play audio
+ sndfile = new File();
+ bgSoundStream = AudioStream::openStreamFile(name, sndfile);
+
+ if (bgSoundStream != NULL) {
+ _snd->playInputStream(&bgSound, bgSoundStream, false, 255, 0, -1, false);
+ } else {
+ warning("Cutscene: Could not open Audio Track for %s", name);
+ }
+
+ return true;
+#else /* USE_MPEG2 */
+ return false;
+#endif
+}
bool BaseAnimationState::checkPaletteSwitch() {
#ifdef BACKEND_8BIT