[Scummvm-cvs-logs] CVS: scummvm/scumm/smush smush_player.cpp,1.33,1.34 smush_player.h,1.6,1.7

Max Horn fingolfin at users.sourceforge.net
Wed Jun 18 06:15:09 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm/smush
In directory sc8-pr-cvs1:/tmp/cvs-serv22430

Modified Files:
	smush_player.cpp smush_player.h 
Log Message:
cleanup; tiny bug fix (file was opened, then opened again - not good)

Index: smush_player.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- smush_player.cpp	15 Jun 2003 01:42:16 -0000	1.33
+++ smush_player.cpp	18 Jun 2003 13:14:17 -0000	1.34
@@ -191,7 +191,7 @@
 
 SmushPlayer *player;
 
-void smush_callback(void *ptr) {
+void SmushPlayer::timerCallback(void *ptr) {
 	Scumm *scumm = (Scumm *)ptr;
 	if (!scumm->_smushPlay)
 		return;
@@ -208,7 +208,7 @@
 	_smixer = 0;
 	_strings = NULL;
 	_skipNext = false;
-	_data = NULL;
+	_dst = NULL;
 	_storeFrame = false;
 	_width = 0;
 	_height = 0;
@@ -247,8 +247,8 @@
 	_scumm->setDirtyColors(0, 255);
 	_smixer->_silentMixer = _scumm->_silentDigitalImuse;
 	_scumm->_smushPlay = true;
-	_data = _scumm->virtscr[0].screenPtr + _scumm->virtscr[0].xstart;
-	_scumm->_timer->installProcedure(&smush_callback, _speed);
+	_dst = _scumm->virtscr[0].screenPtr + _scumm->virtscr[0].xstart;
+	_scumm->_timer->installProcedure(&timerCallback, _speed);
 
 	_alreadyInit = false;
 }
@@ -256,7 +256,7 @@
 void SmushPlayer::deinit() {
 	_scumm->_smushPlay = false;
 	while (_smushProcessFrame) {}
-	_scumm->_timer->releaseProcedure(&smush_callback);
+	_scumm->_timer->releaseProcedure(&timerCallback);
 
 	for (int i = 0; i < 5; i++) {
 		if (_sf[i]) {
@@ -360,7 +360,7 @@
 	checkBlock(b, TYPE_FTCH, 6);
 
 	if (_frameBuffer != NULL) {
-		memcpy(_data, _frameBuffer, _width * _height);
+		memcpy(_dst, _frameBuffer, _width * _height);
 	}
 }
 
@@ -565,10 +565,10 @@
 	// bit 3 - wrap around  8
 	switch (flags & 9) {
 		case 0: 
-			sf->drawStringAbsolute(str, _data, _width, pos_x, pos_y);
+			sf->drawStringAbsolute(str, _dst, _width, pos_x, pos_y);
 			break;
 		case 1:
-			sf->drawStringCentered(str, _data, _width, _height, pos_x, MAX(pos_y, top));
+			sf->drawStringCentered(str, _dst, _width, _height, pos_x, MAX(pos_y, top));
 			break;
 		case 8:
 			// FIXME: Is 'right' the maximum line width here, just
@@ -576,7 +576,7 @@
 			// in The Dig's intro, where 'left' and 'right' are
 			// always 0 and 321 respectively, and apparently we
 			// handle that correctly.
-			sf->drawStringWrap(str, _data, _width, _height, pos_x, MAX(pos_y, top), left, right);
+			sf->drawStringWrap(str, _dst, _width, _height, pos_x, MAX(pos_y, top), left, right);
 			break;
 		case 9:
 			// In this case, the 'right' parameter is actually the
@@ -585,7 +585,7 @@
 			//
 			// Note that in The Dig's "Spacetime Six" movie it's
 			// 621. I have no idea what that means.
-			sf->drawStringWrapCentered(str, _data, _width, _height, pos_x, MAX(pos_y, top), left, MIN(left + right, _width));
+			sf->drawStringWrapCentered(str, _dst, _width, _height, pos_x, MAX(pos_y, top), left, MIN(left + right, _width));
 			break;
 		default:
 			warning("SmushPlayer::handleTextResource. Not handled flags: %d", flags);
@@ -709,17 +709,17 @@
 		// BTW regarding codec 3: I haven't yet actually seen it being used,
 		// but is it really identical to codec 1? Or isn't it maybe a
 		// 'reverse' version (see also bompDecodeLineReverse).
-		decompressBomp(_data, chunk_buffer, _width, _height);
+		decompressBomp(_dst, chunk_buffer, _width, _height);
 #else
 		extern void smush_decode_codec1(byte *dst, byte *src, int height);
-		smush_decode_codec1(_data, chunk_buffer, _height);
+		smush_decode_codec1(_dst, chunk_buffer, _height);
 #endif
 		break;
 	case 37:
-		_codec37.decode(_data, chunk_buffer);
+		_codec37.decode(_dst, chunk_buffer);
 		break;
 	case 47:
-		_codec47.decode(_data, chunk_buffer);
+		_codec47.decode(_dst, chunk_buffer);
 		break;
 	default:
 		error("Invalid codec for frame object : %d", (int)codec);
@@ -729,7 +729,7 @@
 		if (_frameBuffer == NULL) {
 			_frameBuffer = (byte *)malloc(_width * _height);
 		}
-		memcpy(_frameBuffer, _data, _width * _height);
+		memcpy(_frameBuffer, _dst, _width * _height);
 		_storeFrame = false;
 	}
 
@@ -806,8 +806,12 @@
 }
 
 void SmushPlayer::setupAnim(const char *file, const char *directory) {
+	Chunk *sub;
+	int i;
+	char file_font[11];
+
 	_base = new FileChunk(file, directory);
-	Chunk *sub = _base->subBlock();
+	sub = _base->subBlock();
 	checkBlock(*sub, TYPE_AHDR);
 	handleAnimHeader(*sub);
 
@@ -819,16 +823,14 @@
 		_sf[0]->loadFont("scummfnt.nut", directory);
 		_sf[2]->loadFont("titlfnt.nut", directory);
 	} else if (_scumm->_gameId == GID_DIG) {
-		for (int i = 0; i < 4; i++) {
-			char file_font[11];
-			sprintf((char *)&file_font, "font%d.nut", i);
+		for (i = 0; i < 4; i++) {
+			sprintf(file_font, "font%d.nut", i);
 			_sf[i] = new SmushFont(i != 0, false);
 			_sf[i]->loadFont(file_font, directory);
 		}
 	} else if (_scumm->_gameId == GID_CMI) {
-		for (int i = 0; i < 5; i++) {
-			char file_font[11];
-			sprintf((char *)&file_font, "font%d.nut", i);
+		for (i = 0; i < 5; i++) {
+			sprintf(file_font, "font%d.nut", i);
 			_sf[i] = new SmushFont(false, true);
 			_sf[i]->loadFont(file_font, directory);
 		}
@@ -856,16 +858,15 @@
 	delete sub;
 }
 
-void SmushPlayer::setPalette(byte *palette) {
+void SmushPlayer::setPalette(const byte *palette) {
 	byte palette_colors[1024];
 	byte *p = palette_colors;
-	byte *data = palette;
 
-	for (int i = 0; i != 256; i++, data += 3, p += 4) {
-		p[0] = data[0]; // red
-		p[1] = data[1]; // green
-		p[2] = data[2]; // blue
-		p[3] = 0;
+	for (int i = 0; i != 256; ++i) {
+		*p++ = *palette++; // red
+		*p++ = *palette++; // green
+		*p++ = *palette++; // blue
+		*p++ = 0;
 	}
 
 	_scumm->_system->set_palette(palette_colors, 0, 256);
@@ -873,22 +874,26 @@
 
 void SmushPlayer::updateScreen() {
 	uint32 end_time, start_time = _scumm->_system->get_msecs();
-	_scumm->_system->copy_rect(_data, _width, 0, 0, _width, _height);
+	_scumm->_system->copy_rect(_dst, _width, 0, 0, _width, _height);
 	_updateNeeded = true;
 	end_time = _scumm->_system->get_msecs();
 	debug(4, "Smush stats: updateScreen( %03d )", end_time - start_time);
 }
 
 void SmushPlayer::play(const char *filename, const char *directory) {
+
+	// Verify the specified file exists
 	File f;
 	f.open(filename, directory);
 	if (!f.isOpen()) {
 		warning("SmushPlayer::play() File not found %s", filename);
 		return;
 	}
+	f.close();
 
 	_updateNeeded = false;
 
+	// Load the video
 	setupAnim(filename, directory);
 	init();
 
@@ -897,16 +902,17 @@
 		_scumm->processKbd();
 		if (_updateNeeded) {
 			
-			uint32 end_time, start_time = _scumm->_system->get_msecs();
+			uint32 end_time, start_time;
+			
+			start_time = _scumm->_system->get_msecs();
 			_scumm->_system->update_screen();
 			_updateNeeded = false;
 			end_time = _scumm->_system->get_msecs();
+
 			debug(4, "Smush stats: BackendUpdateScreen( %03d )", end_time - start_time);
 
 		}
-		if (_scumm->_videoFinished || _scumm->_quit)
-			break;
-		if (_scumm->_saveLoadFlag)
+		if (_scumm->_videoFinished || _scumm->_quit || _scumm->_saveLoadFlag)
 			break;
 		_scumm->_system->delay_msecs(10);
 	};

Index: smush_player.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- smush_player.h	26 May 2003 19:57:00 -0000	1.6
+++ smush_player.h	18 Jun 2003 13:14:17 -0000	1.7
@@ -33,7 +33,6 @@
 
 class SmushPlayer {
 private:
-
 	Scumm *_scumm;
 	int _version;
 	int32 _nbframes;
@@ -44,7 +43,6 @@
 	SmushFont *_sf[5];
 	Codec37Decoder _codec37;
 	Codec47Decoder _codec47;
-	int dst_width, dst_height;
 	FileChunk *_base;
 	byte *_frameBuffer;
 
@@ -63,25 +61,26 @@
 	int _speed;
 	bool _outputSound;
 
-public:
-
 	int _width, _height;
-	byte *_data;
-	volatile bool _smushProcessFrame;
+	byte *_dst;
 	bool _updateNeeded;
 
+	volatile bool _smushProcessFrame;
+
+public:
 	SmushPlayer(Scumm *, int, bool);
 	~SmushPlayer();
+
+	void play(const char *filename, const char *directory);
+
+private:
 	void updatePalette(void);
 	void parseNextFrame();
 	void init();
 	void deinit();
 	void setupAnim(const char *file, const char *directory);
 	void updateScreen();
-	void play(const char *filename, const char *directory);
-	void setPalette(byte *palette);
-
-protected:
+	void setPalette(const byte *palette);
 
 	bool readString(const char *file, const char *directory);
 	void checkBlock(const Chunk &, Chunk::type, uint32 = 0);
@@ -99,6 +98,8 @@
 	void handleTextResource(Chunk &);
 	void handleDeltaPalette(Chunk &);
 	void readPalette(byte *, Chunk &);
+	
+	static void timerCallback(void *ptr);
 };
 
 #endif





More information about the Scummvm-git-logs mailing list