[Scummvm-cvs-logs] CVS: scummvm insane.cpp,1.26,1.27 smush.h,1.4,1.5

James Brown ender at users.sourceforge.net
Sun May 12 04:48:02 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv16274

Modified Files:
	insane.cpp smush.h 
Log Message:
Fix some Full Throttle smush problems from implementing the new Dig codecs.

Added preliminary FT smush sound by jah - This needs work, it has to be
able to STREAM audio to the mixer and append an existing buffer, not
just create a new sample for each audio packet.


Index: insane.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/insane.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- insane.cpp	6 May 2002 15:32:32 -0000	1.26
+++ insane.cpp	12 May 2002 11:47:50 -0000	1.27
@@ -311,7 +311,7 @@
 }
 
 
-void codec37_proc5(byte *dst, byte *src, int next_offs, int bw, int bh,
+void codec37_proc5(int game, byte *dst, byte *src, int next_offs, int bw, int bh,
 									 int pitch, int16 * table)
 {
 	byte code, *tmp;
@@ -327,16 +327,18 @@
 		i = bw;
 		do {
 			code = *src++;
-			if (code == 0xFD) {
+
+			// FIXME: Full Throttle has different FD and FEs?
+			if ((game == GID_DIG) && (code == 0xFD)) {
  				t = src[0];
  				t += (t << 8) + (t << 16) + (t << 24);
  				*(uint32 *)(dst + 0) = t;
  				*(uint32 *)(dst + 320) = t;
  				*(uint32 *)(dst + 320 * 2) = t;
  				*(uint32 *)(dst + 320 * 3) = t;
-				 src += 1;
-				 dst += 4;
-			} else if (code == 0xFE) {
+				src += 1;
+				dst += 4;
+			} else if ((game == GID_DIG) && (code == 0xFE)) {
  				t = src[0];
  				t += (t << 8) + (t << 16) + (t << 24);
  				*(uint32 *)(dst + 0) = t;
@@ -493,7 +495,7 @@
 
 
 
-int codec37(CodecData * cd, PersistentCodecData37 * pcd)
+int codec37(int game, CodecData * cd, PersistentCodecData37 * pcd)
 {
 	int width_in_blocks, height_in_blocks;
 	int src_pitch;
@@ -550,10 +552,10 @@
 				pcd->curtable ^= 1;
 			}
 
-			codec37_proc5(pcd->deltaBufs[pcd->curtable], cd->src + 16,
-										pcd->deltaBufs[pcd->curtable ^ 1] -
-										pcd->deltaBufs[pcd->curtable], width_in_blocks,
-										height_in_blocks, src_pitch, pcd->table1);
+			codec37_proc5(game, pcd->deltaBufs[pcd->curtable], cd->src + 16,
+								pcd->deltaBufs[pcd->curtable ^ 1] -
+								pcd->deltaBufs[pcd->curtable], width_in_blocks,
+								height_in_blocks, src_pitch, pcd->table1);
 			break;
 
 		  }
@@ -633,16 +635,101 @@
 		codec1(&cd);
 		break;
 	case 37:
-		_frameChanged = codec37(&cd, &pcd37);
+		_frameChanged = codec37(sm->_gameId, &cd, &pcd37);
 		break;
 	default:
 		error("invalid codec %d", codec);
 	}
 }
 
-void SmushPlayer::parsePSAD()
-{
-	//printf("parse PSAD\n");
+void SmushPlayer::parsePSAD()	// FIXME: Needs to append to
+{								//		  a sound buffer
+	unsigned int pos, sublen, tag, idx, trk;
+	byte * buf;
+	
+	pos = 0;
+	
+	trk = READ_LE_UINT16(_cur + pos); /* FIXME: is this correct ? */
+	pos += 2;
+
+	/* FIXME: number 8 should be replaced with a sensible literal */
+
+	for (idx = 0; idx < 8; idx++) {
+		if (_psadTrk[idx] == trk)
+			break;
+	}
+
+	if (idx == 8) {
+		for (idx = 0; idx < 8; idx++) {
+			if (_psadTrk[idx] == 0) {
+				_psadTrk[idx] = trk;
+				break;
+			}
+		}
+	}
+
+	if (idx == 8) {
+		warning("PSAD table full\n");
+		return;
+	}
+
+	pos += 8; /* FIXME: what are these ? */
+	
+	while (pos < _frmeSize) {
+
+		if (_saudSize[idx] == 0) {
+			tag = READ_BE_UINT32(_cur + pos);
+			pos += 4;
+			if (tag != 'SAUD')
+				error("trk %d: SAUD tag not found", trk);
+			_saudSize[idx] = READ_BE_UINT32(_cur + pos);
+			pos += 4;
+		}
+	
+		if (_saudSubSize[idx] == 0) {
+			_saudSubTag[idx] = READ_BE_UINT32(_cur + pos);
+			pos += 4;
+			_saudSubSize[idx] = READ_BE_UINT32(_cur + pos);
+			pos += 4;
+			_saudSize[idx] -= 8;
+			debug(3, "trk %d: tag '%4s' size %x",
+			      trk, _cur + pos - 8, _saudSubSize[idx]);
+		}
+
+		sublen = _saudSubSize[idx] < (_frmeSize - pos) ?
+			_saudSubSize[idx] : (_frmeSize - pos);
+				
+		switch (_saudSubTag[idx]) {
+		case 'STRK' :
+			/* FIXME: what is this stuff ? */
+			_strkRate[idx] = 22050;
+			break;
+		case 'SDAT' :
+			buf = (byte *) malloc(sublen);
+
+			memcpy(buf, _cur + pos, sublen);
+
+			debug(3, "trk %d: SDAT part len 0x%x rate %d",
+			      trk, sublen, _strkRate[idx]);
+
+			g_scumm->_mixer->play_raw(NULL, buf,
+						  sublen, _strkRate[idx],
+						  SoundMixer::FLAG_UNSIGNED |
+						  SoundMixer::FLAG_AUTOFREE);
+			break;
+		case 'SMRK' :
+			_psadTrk[idx] = 0;
+			break;
+		case 'SHDR' :
+			/* FIXME: what is this stuff ? */
+			break;
+		default :
+			error("trk %d: unknown tag inside PSAD", trk);
+		}
+		_saudSubSize[idx] -= sublen;
+		_saudSize[idx] -= sublen;				
+		pos += sublen;	
+	}
 }
 
 void SmushPlayer::parseTRES()
@@ -720,6 +807,10 @@
 {
 	_renderBitmap = sm->_videoBuffer;
 	codec37_init(&pcd37, 320, 200);
+
+	memset(_saudSize, 0, sizeof(_saudSize));
+	memset(_saudSubSize, 0, sizeof(_saudSubSize));
+	memset(_psadTrk, 0, sizeof(_psadTrk));
 }
 
 void SmushPlayer::go()

Index: smush.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/smush.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- smush.h	6 May 2002 15:32:32 -0000	1.4
+++ smush.h	12 May 2002 11:47:50 -0000	1.5
@@ -65,6 +65,11 @@
         uint16 _fluPalMul129[768];
         uint16 _fluPalWords[768];
 
+		/* PSAD: Full Throttle audio */
+		uint32 _saudSize[8], _saudSubSize[8];
+		uint16 _psadTrk[8], _strkRate[8];
+		uint32 _saudSubTag[8];
+
         void openFile(byte* fileName);
         void nextBlock();
 
@@ -72,8 +77,7 @@
         uint32 fileReadLE32();
         void go();
 
-        bool parseTag();
-
+        bool parseTag();		
         void parseAHDR();
         void parseFRME();
 





More information about the Scummvm-git-logs mailing list