diff options
| author | Torbjörn Andersson | 2004-01-14 08:14:25 +0000 | 
|---|---|---|
| committer | Torbjörn Andersson | 2004-01-14 08:14:25 +0000 | 
| commit | 15738c13d3ebab0c34152669a9752f6c3b773096 (patch) | |
| tree | bfc3d3f7f2f78b47161af20b9ed09f6aab85c7bd | |
| parent | 2fb7d4c553e01cebc5a3f30485db015fd884ff80 (diff) | |
| download | scummvm-rg350-15738c13d3ebab0c34152669a9752f6c3b773096.tar.gz scummvm-rg350-15738c13d3ebab0c34152669a9752f6c3b773096.tar.bz2 scummvm-rg350-15738c13d3ebab0c34152669a9752f6c3b773096.zip | |
I wanted to Valgrind the cutscene code, so I had to fix the warnings about
uninitialized values. Now the only warnings I got were from libmpeg2
itself, and I don't know how serious that is.
I've also added some code - disabled by default - to allow the cutscenes to
run with libmpeg 0.3.1, since that's what I've got on my Linux box. It
appears to work on that one, though I only have the "eye" cutscene on it
yet.
Ogg Vorbis playback is still broken for me under Windows, though. I wonder
if it is because I don't have the very latest Ogg Vorbis libraries on it
(since I didn't manage to compile them under MinGW). But surely the file
format hasn't changed in any important way...?
svn-id: r12374
| -rw-r--r-- | sword2/driver/animation.cpp | 26 | ||||
| -rw-r--r-- | sword2/driver/animation.h | 12 | 
2 files changed, 33 insertions, 5 deletions
| diff --git a/sword2/driver/animation.cpp b/sword2/driver/animation.cpp index 514da5ceb7..4c621692ba 100644 --- a/sword2/driver/animation.cpp +++ b/sword2/driver/animation.cpp @@ -25,7 +25,6 @@  #include "sword2/driver/menu.h"  #include "sword2/driver/render.h" -  #include "common/file.h"  namespace Sword2 { @@ -37,7 +36,8 @@ AnimationState::AnimationState(Sword2Engine *vm)  AnimationState::~AnimationState() {  #ifdef USE_MPEG2  	_vm->_mixer->stopHandle(bgSound); -	mpeg2_close(decoder); +	if (decoder) +		mpeg2_close(decoder);  	delete mpgfile;  	delete sndfile;  #endif @@ -49,8 +49,12 @@ bool AnimationState::init(const char *name) {  	char basename[512], tempFile[512];    	int i, p; +	decoder = NULL; +	mpgfile = NULL; +	sndfile = NULL; +  	strcpy(basename, name); -	basename[strlen(basename)-4] = 0;	// FIXME: hack to remove extension +	basename[strlen(basename) - 4] = 0;	// FIXME: hack to remove extension  	// Load lookup palettes  	// TODO: Binary format so we can use File class @@ -64,8 +68,9 @@ bool AnimationState::init(const char *name) {  	p = 0;  	while (!feof(f)) { -		fscanf(f, "%i %i", &palettes[p].end, &palettes[p].cnt); -  		for (i = 0; i < palettes[p].cnt; i++) { +		if (fscanf(f, "%i %i", &palettes[p].end, &palettes[p].cnt) != 2) +			break; +		for (i = 0; i < palettes[p].cnt; i++) {    			int r, g, b;    			fscanf(f, "%i", &r);    			fscanf(f, "%i", &g); @@ -73,12 +78,20 @@ bool AnimationState::init(const char *name) {  			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;  	_vm->_graphics->setPalette(0, 256, palettes[palnum].pal, RDPAL_INSTANT);  	lut = lut2 = lookup[0];  	curpal = -1; @@ -131,6 +144,9 @@ bool AnimationState::init(const char *name) {  void AnimationState::buildLookup(int p, int lines) {  	int y, cb;  	int r, g, b, ii; + +	if (p >= maxPalnum) +		return;  	if (p != curpal) {  		curpal = p; diff --git a/sword2/driver/animation.h b/sword2/driver/animation.h index 31f03aa34d..3e0b701dc4 100644 --- a/sword2/driver/animation.h +++ b/sword2/driver/animation.h @@ -22,13 +22,24 @@  #ifndef ANIMATION_H  #define ANIMATION_H +// Uncomment this if you are using libmpeg2 0.3.1. +// #define USE_MPEG2_0_3_1 +  #ifndef _MSC_VER  #include <inttypes.h>  #endif +  #ifdef USE_MPEG2  extern "C" {  	#include <mpeg2dec/mpeg2.h>  } + +#ifdef USE_MPEG2_0_3_1 +typedef int mpeg2_state_t; +typedef sequence_t mpeg2_sequence_t; +#define STATE_BUFFER -1 +#endif +  #endif  namespace Sword2 { @@ -46,6 +57,7 @@ private:  	Sword2Engine *_vm;  	int palnum; +	int maxPalnum;  	byte lookup[2][BITDEPTH * BITDEPTH * BITDEPTH];  	byte *lut; | 
