[Scummvm-cvs-logs] CVS: scummvm boxes.cpp,1.40,1.41 costume.cpp,1.45,1.46 resource.cpp,1.103,1.104 script_v1.cpp,1.142,1.143 sound.cpp,1.129,1.130

James Brown ender at users.sourceforge.net
Tue Aug 20 02:59:03 CEST 2002


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

Modified Files:
	boxes.cpp costume.cpp resource.cpp script_v1.cpp sound.cpp 
Log Message:
Fix lighting on actors in V6+ games (eg, Sam and Max)
Move boxflags debug to debug level 2 (we default to 1)
Apply patches:
  595414: Simon 2 lockup workarounds
  595875: Simon 2 save/load dialog fix
  597422: Preliminary support for CREA sound format (for FT)
  597627: Use savedir for save/load-string opcodes



Index: boxes.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/boxes.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- boxes.cpp	15 Aug 2002 16:46:29 -0000	1.40
+++ boxes.cpp	20 Aug 2002 09:58:35 -0000	1.41
@@ -71,7 +71,7 @@
 
 void Scumm::setBoxFlags(int box, int val)
 {
-	debug(1, "setBoxFlags(%d, 0x%02x)", box, val);
+	debug(2, "setBoxFlags(%d, 0x%02x)", box, val);
 
 	/* FULL_THROTTLE stuff */
 	if (val & 0xC000) {

Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/costume.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- costume.cpp	19 Aug 2002 17:20:52 -0000	1.45
+++ costume.cpp	20 Aug 2002 09:58:35 -0000	1.46
@@ -1349,7 +1349,7 @@
 	byte color;
 
 	for (i = 0; i < _loaded._numColors; i++) {
-		if (_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_actor_color) {
+		if ((_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_actor_color) || (_vm->_features & GF_AFTER_V6)) {
 			color = palette[i];
 			if (color == 255)
 				color = _loaded._ptr[8 + i];

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/resource.cpp,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- resource.cpp	19 Aug 2002 12:56:12 -0000	1.103
+++ resource.cpp	20 Aug 2002 09:58:35 -0000	1.104
@@ -725,6 +725,11 @@
 		total_size = fileReadDwordBE();
 		fileRead(_fileHandle, createResource(type, idx, total_size), total_size - 8);
 		return 1;
+	} else if (basetag == MKID('Crea')) {
+		fileSeek(_fileHandle, -12, SEEK_CUR);
+		total_size = fileReadDwordBE();
+		fileRead(_fileHandle, createResource(type, idx, total_size), total_size - 8);
+		return 1;
 	} else {
 		fprintf(stderr, "WARNING: Unrecognized base tag 0x%08lx in sound %d\n", basetag, idx);
 	}
@@ -837,7 +842,6 @@
 {
 	byte *ptr;
 
-	debug(9, "nukeResource(%s,%d)", resTypeFromId(type), idx);
 
 	CHECK_HEAP if (!res.address[type])
 		  return;
@@ -845,6 +849,7 @@
 	assert(idx >= 0 && idx < res.num[type]);
 
 	if ((ptr = res.address[type][idx]) != NULL) {
+		debug(9, "nukeResource(%s,%d)", resTypeFromId(type), idx);
 		res.address[type][idx] = 0;
 		res.flags[type][idx] = 0;
 		_allocatedSize -= ((MemBlkHeader *)ptr)->size;

Index: script_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script_v1.cpp,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- script_v1.cpp	20 Aug 2002 02:20:40 -0000	1.142
+++ script_v1.cpp	20 Aug 2002 09:58:35 -0000	1.143
@@ -1989,7 +1989,10 @@
 			FILE *out;
 
 			a = getVarOrDirectByte(0x80);
-			s = buf;
+
+			// FIXME - check for buffer overflow
+			strcpy(buf, getSavePath());
+			s = buf + strlen(buf);
 			while ((*s++ = fetchScriptByte()));
 
 			// Use buf as filename
@@ -2007,7 +2010,10 @@
 			FILE *in;
 
 			a = getVarOrDirectByte(0x80);
-			s = buf;
+
+			// FIXME - check for buffer overflow
+			strcpy(buf, getSavePath());
+			s = buf + strlen(buf);
 			while ((*s++ = fetchScriptByte()));
 
 			// Use buf as filename

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound.cpp,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- sound.cpp	19 Aug 2002 12:56:12 -0000	1.129
+++ sound.cpp	20 Aug 2002 09:58:35 -0000	1.130
@@ -48,6 +48,11 @@
 		_scumm->_vars[_scumm->VAR_LAST_SOUND] = sound;
 		_scumm->ensureResourceLoaded(rtSound, sound);
 		addSoundToQueue2(sound);
+	} else {
+		// WARNING ! This may break something, maybe this sould be put inside if(_gameID == GID_FT) ? 
+		// But why addSoundToQueue should not queue sound ?
+		_scumm->ensureResourceLoaded(rtSound, sound);
+		addSoundToQueue2(sound);
 	}
 
 //	if (_features & GF_AUDIOTRACKS)
@@ -162,10 +167,59 @@
 	_soundQuePos = 0;
 }
 
+static char * read_creative_voc_file(byte * ptr, int & size, int & rate) {
+	assert(strncmp((char*)ptr, "Creative Voice File\x1A", 20) == 0);
+	int offset = READ_LE_UINT16(ptr+20);
+	short version = READ_LE_UINT16(ptr+22);
+	short code = READ_LE_UINT16(ptr+24);
+	assert(version == 0x010A || version == 0x0114);
+	assert(code == ~version + 0x1234);
+	bool quit = 0;
+	char * ret_sound = 0; size = 0;
+	while(!quit) {
+		int len = READ_LE_UINT32(ptr + offset);
+		offset += 4;
+		int code = len & 0xFF;		// FIXME not sure this is endian correct
+		len >>= 8;
+		switch(code) {
+			case 0: quit = 1; break;
+			case 1: {
+				int time_constant = ptr[offset++];
+				int packing = ptr[offset++];
+				len -= 2;
+				rate = 1000000L / (256L - time_constant);
+				debug(9, "VOC Data Bloc : %d, %d, %d", rate, packing, len);
+				if(packing == 0) {
+					if(size) {
+						ret_sound = (char*)realloc(ret_sound, size + len);
+					} else {
+						ret_sound = (char*)malloc(len);
+					}
+					memcpy(ret_sound + size, ptr + offset, len);
+					size += len;
+				} else {
+					warning("VOC file packing %d unsupported", packing);
+				}
+				} break;
+			case 6:	// begin of loop
+				debug(3, "loops in Creative files not supported");
+				break;
+			case 7:	// end of loop
+				break;
+			default:
+				warning("Invalid code in VOC file : %d", code);
+				//~ quit = 1;
+				break;
+		}
+		offset += len;
+	}
+	debug(9, "VOC Data Size : %d", size);
+	return ret_sound;
+}
+
 void Sound::playSound(int sound) {
 	byte *ptr;
-	IMuse *se = _scumm->_imuse;
-
+	
 	ptr = _scumm->getResourceAddress(rtSound, sound);
 	if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) {
 		ptr += 8;
@@ -180,11 +234,10 @@
 		_scumm->current_cd_sound = sound;
 		return;
 	}
-
 	// Support for SFX in Monkey Island 1, Mac version
 	// This is rather hackish right now, but works OK. SFX are not sounding
 	// 100% correct, though, not sure right now what is causing this.
-	if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('Mac1')) {
+	else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('Mac1')) {
 
 		// Read info from the header
 		int size = READ_UINT32_UNALIGNED(ptr+0x60);
@@ -216,6 +269,14 @@
 		_scumm->_mixer->play_raw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
 		return;
 	}
+	else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('Crea')) {
+		int size, rate;
+		char * sound = read_creative_voc_file(ptr, size, rate);
+		if(sound != NULL) {
+			_scumm->_mixer->play_raw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+		}
+		return;
+	}
 	// Support for sampled sound effects in Monkey1 and Monkey2
 	else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SBL ')) {
 		debug(2, "Using SBL sound effect");
@@ -332,6 +393,7 @@
 	if (_scumm->_gameId == GID_MONKEY_VGA)
 		return;											/* FIXME */
 
+	IMuse *se = _scumm->_imuse;
 	if (se) {
 		_scumm->getResourceAddress(rtSound, sound);
 		se->start_sound(sound);





More information about the Scummvm-git-logs mailing list