[Scummvm-cvs-logs] CVS: scummvm/scumm/smush codec44.cpp,1.3,1.4 frenderer.cpp,1.11,1.12 player.cpp,1.30,1.31 player.h,1.9,1.10

Pawel Kolodziejski aquadran at users.sourceforge.net
Sat Jan 18 13:52:02 CET 2003


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

Modified Files:
	codec44.cpp frenderer.cpp player.cpp player.h 
Log Message:
added preliminary support for subtitles in smush comi

Index: codec44.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/codec44.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- codec44.cpp	30 Aug 2002 07:24:45 -0000	1.3
+++ codec44.cpp	18 Jan 2003 21:51:00 -0000	1.4
@@ -27,45 +27,47 @@
 bool Codec44Decoder::decode(Blitter & dst, Chunk & src) {
 	int32 size_line;
 	int32 num;
-	int32 w, width = getRect().width() + 1;
-	int32 h, height = getRect().height() + 1;
-	bool zero;
-#ifdef DEBUG_CODEC44
-	debug(7, "codec44 : %dx%d", width, height);
-#endif
+	int32 length = src.getSize() - 14;
+	int32 width = getRect().width();
+	int32 height = getRect().height();
+	byte * src2 = (byte*)malloc(length);
+	byte * org_src2 = src2;
+	src.read(src2, length);
+	byte * dst2 = (byte*)malloc(2000);
+	byte * org_dst2 = dst2;
+	byte val;
 
-	for(h = 0; h < height - 1; h++) {
-		w = width;
-		size_line = src.getWord(); // size of compressed line !
-#ifdef DEBUG_CODEC44
-		debug(7, "codec44 : h == %d, size_line == %d", h, size_line);
-#endif
-		zero = true;
-		while(size_line > 1) {
-			num = src.getWord();
+	do {
+		size_line = READ_LE_UINT16(src2);
+		src2 += 2;
+		length -= 2;
+
+		while (size_line != 0) {
+			num = *src2++;
+			val = *src2++;
+			memset(dst2, val, num);
+			dst2 += num;
+			length -= 2;
 			size_line -= 2;
-			if(zero) {
-#ifdef DEBUG_CODEC44
-				debug(7, "codec44 : zeroing %d, entries", num);
-#endif
-				if(w == num)
-					num--;
-				w -= num;
-				if(num)
-					dst.put(0, num);
-			} else {
-				num += 1;
-#ifdef DEBUG_CODEC44
-				debug(7, "codec44 : blitting %d, entries", num);
-#endif
-				if(w == num)
-					num--;
-				w -= num;
-				dst.blit(src, num);
-				size_line -= num;
-			}
-			zero = !zero;
+			if (size_line == 0)
+				break;
+
+			num = READ_LE_UINT16(src2) + 1;
+			src2 += 2;
+			memcpy(dst2, src2, num);
+			dst2 += num;
+			src2 += num;
+			length -= num + 2;
+			size_line -= num + 2;
 		}
-	}
+		dst2--;
+
+	} while (length > 1);
+
+	dst.blit(org_dst2, width * height);
+
+	free(org_src2);
+	free(org_dst2);
+
 	return true;
 }

Index: frenderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/frenderer.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- frenderer.cpp	21 Nov 2002 17:50:14 -0000	1.11
+++ frenderer.cpp	18 Jan 2003 21:51:00 -0000	1.12
@@ -114,12 +114,12 @@
 }
 
 static char * * split(const char * str, char sep) {
-	char * * ret = new char *[32];
+	char * * ret = new char *[62];
 	int32 n = 0;
 	const char * i = str, * j = strchr(i, sep);
 
 	while(j != NULL) {
-		assert(n < 30);
+		assert(n < 60);
 		ret[n] = new char[j - i + 1];
 		memcpy(ret[n], i, j - i);
 		ret[n++][j - i] = 0;
@@ -160,7 +160,10 @@
 
 bool FontRenderer::drawStringCentered(const char * str, char * buffer, const Point & size, int32 y, int32 xmin, int32 width, int32 offset) const {
 	debug(9, "FontRenderer::drawStringCentered(%s, %d, %d)", str, xmin, y);
-	assert(strchr(str, '\n') == 0);
+	if ((strchr(str, '\n') != 0)) {
+		char * j = strchr(str, '\n');
+		*j = 0;
+	}
 	char * * words = split(str, ' ');
 	int32 nb_sub = 0;
 
@@ -235,7 +238,10 @@
 
 bool FontRenderer::drawStringWrap(const char * str, char * buffer, const Point & size, int32 x, int32 y, int32 width) const {
 	debug(9, "FontRenderer::drawStringWrap(%s, %d, %d)", str, x, y);
-	assert(strchr(str, '\n') == 0);
+	if ((strchr(str, '\n') != 0)) {
+		char * j = strchr(str, '\n');
+		*j = 0;
+	}
 	char * * words = split(str, ' ');
 	int32 nb_sub = 0;
 
@@ -308,7 +314,10 @@
 bool FontRenderer::drawStringWrapCentered(const char * str, char * buffer, const Point & size, int32 x, int32 y, int32 width) const {
 	int32 max_substr_width = 0;
 	debug(9, "FontRenderer::drawStringWrapCentered(%s, %d, %d)", str, x, y);
-	assert(strchr(str, '\n') == 0);
+	if ((strchr(str, '\n') != 0)) {
+		char * j = strchr(str, '\n');
+		*j = 0;
+	}
 	char * * words = split(str, ' ');
 	int32 nb_sub = 0;
 

Index: player.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/player.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- player.cpp	18 Jan 2003 14:58:37 -0000	1.30
+++ player.cpp	18 Jan 2003 21:51:00 -0000	1.31
@@ -23,7 +23,6 @@
 #include "common/file.h"
 #include "common/util.h"
 #include "common/engine.h" // for debug, warning, error
-#include "common/engine.h" // for debug, warning, error
 #include "scumm/scumm.h"
 #include "sound/mixer.h"
 
@@ -209,7 +208,7 @@
 							_bgmusic(true),
 							_voices(true),
 							_curBuffer(0) {
-	_fr[0] = _fr[1] = _fr[2] = _fr[3] = 0;
+	_fr[0] = _fr[1] = _fr[2] = _fr[3] = _fr[4] = 0;
 	assert(_renderer != 0);
 	_IACTchannel = -1;
 	_IACTrest = 0;
@@ -231,6 +230,7 @@
 	if(_fr[1]) delete _fr[1];
 	if(_fr[2]) delete _fr[2];
 	if(_fr[3]) delete _fr[3];
+	if(_fr[4]) delete _fr[4];
 }
 
 void SmushPlayer::checkBlock(const Chunk & b, Chunk::type type_expected, uint32 min_size) {
@@ -430,7 +430,6 @@
 }
 
 void SmushPlayer::handleTextResource(Chunk & b) {
-	checkBlock(b, TYPE_TRES, 18); 
 	int32 pos_x = b.getShort();
 	int32 pos_y = b.getShort();
 	int32 flags = b.getShort();
@@ -439,18 +438,30 @@
 	int32 width = b.getShort();
 	/*int32 height =*/ b.getShort();
 	/*int32 unk2 =*/ b.getWord();
-	int32 string_id = b.getWord();
-	debug(6, "SmushPlayer::handleTextResource(%d)", string_id);
-	if(!_strings) return;
+
+	const char * str;
+	char * string;
+	if (g_scumm->_gameId == GID_CMI) {
+		string = (char*)malloc(b.getSize() - 16);
+		str = string;
+		b.read(string, b.getSize() - 16);
+	} else {
+		int32 string_id = b.getWord();
+		debug(6, "SmushPlayer::handleTextResource(%d)", string_id);
+		if(!_strings)
+			return;
+		str = _strings->get(string_id);
+	}
 
 	// if subtitles disabled and bit 3 is set, then do not draw
 	if((!_subtitles) && ((flags & 8) == 8))
 		return;
-	const char * str = _strings->get(string_id);
 
 	FontRenderer * fr = _fr[0];
 	int32 color = 15;
 	while(*str == '/') str++; // For Full Throttle text resources
+	if (g_scumm->_gameId == GID_CMI)
+		while(*str++ != '/');
 	while(str[0] == '^') {
 		switch(str[1]) {
 		case 'f':
@@ -503,6 +514,10 @@
 	}
 	else
 		warning("SmushPlayer::handleTextResource. Not handled flags: %d\n", flags);
+
+	if (g_scumm->_gameId == GID_CMI) {
+		free (string);
+	}
 }
 
 void SmushPlayer::readPalette(Palette & out, Chunk & in) {
@@ -607,7 +622,6 @@
 		decodeCodec(b, r, _codec1);
 		break;
 	case 37:
-		// assert(left == 0 && top == 0);
 		initSize(r, true, false);
 		decodeCodec(b, r, _codec37);
 		_codec37Called = true;
@@ -665,6 +679,7 @@
 				handleSkip(*sub);
 				break;
 			case TYPE_TEXT:
+				handleTextResource(*sub);
 				break;
 			default:
 				error("Unknown frame subChunk found : %s, %d", Chunk::ChunkString(sub->getType()), sub->getSize());
@@ -806,10 +821,10 @@
 	clean();
 	
 	if(_wait) {
-		bool isFullthrottle;
+		bool isFullthrottle = false;
 		if(!readString(file, directory, isFullthrottle))
 			debug(2, "unable to read text information for \"%s\"", file);
-		if(_strings) {
+		if((_strings) || (g_scumm->_gameId == GID_CMI)) {
 			if(isFullthrottle) {
 				_fr[0] = loadFont("scummfnt.nut", directory, true);
 				_fr[2] = loadFont("titlfnt.nut", directory, true);
@@ -819,6 +834,13 @@
 					sprintf((char*)&file_font, "font%d.nut", i);
 					_fr[i] = loadFont(file_font, directory, i != 0);
 				}
+			}
+		}
+		if(g_scumm->_gameId == GID_CMI) {
+			for(int i = 0; i < 5; i++) {
+				char file_font[20];
+				sprintf((char*)&file_font, "font%d.nut", i);
+				_fr[i] = loadFont(file_font, directory, i != 0);
 			}
 		}
 	}

Index: player.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/player.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- player.h	18 Jan 2003 13:54:26 -0000	1.9
+++ player.h	18 Jan 2003 21:51:00 -0000	1.10
@@ -53,7 +53,7 @@
 	int16 _deltaPal[768];		//!< the delta palette information set by an xpal
 	Renderer * _renderer;		//!< pointer to the ::renderer
 	StringResource * _strings;	//!< pointer to the string resources associated with the animation
-	FontRenderer * _fr[4];		//!< pointers to the fonts for the animation
+	FontRenderer * _fr[5];		//!< pointers to the fonts for the animation
 	Codec1Decoder _codec1;	//!< the ::decoder for codec 1 and 3
 	Codec37Decoder _codec37;	//!< the ::decoder for codec 37
 	Codec47Decoder _codec47;	//!< the ::decoder for codec 47





More information about the Scummvm-git-logs mailing list