[Scummvm-git-logs] scummvm master -> a286db2d3c32d3396a056a6e2f30078a9c9a4ab4

mgerhardy martin.gerhardy at gmail.com
Sat Oct 31 12:02:41 UTC 2020


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
04651701a3 TWINE: endian safe file parsing (at least partially)
ff40266934 TWINE: convert all hqr errors into warnings
cc4e3a30d8 TWINE: fixed voice samples
a286db2d3c TWINE: use voice volume for speech


Commit: 04651701a30c5f727ab4674f2c56ded7aba52fae
    https://github.com/scummvm/scummvm/commit/04651701a30c5f727ab4674f2c56ded7aba52fae
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-31T13:02:07+01:00

Commit Message:
TWINE: endian safe file parsing (at least partially)

Changed paths:
    engines/twine/hqr.cpp


diff --git a/engines/twine/hqr.cpp b/engines/twine/hqr.cpp
index 9ddb51d699..c980904b13 100644
--- a/engines/twine/hqr.cpp
+++ b/engines/twine/hqr.cpp
@@ -82,31 +82,26 @@ static int voxEntrySize(const char *filename, int32 index, int32 hiddenIndex) {
 		error("HQR: Could not open %s", filename);
 	}
 
-	uint32 headerSize;
-	wrap(file.read(&headerSize, 4))
-
+	uint32 headerSize = file.readUint32LE();
 	if ((uint32)index >= headerSize / 4) {
 		warning("HQR: Invalid entry index");
 		return 0;
 	}
 
 	wrap(file.seek(index * 4))
-	uint32 offsetToData;
-	wrap(file.read(&offsetToData, 4))
+	uint32 offsetToData = file.readUint32LE();
 
 	wrap(file.seek(offsetToData))
-	uint32 realSize;
-	wrap(file.read(&realSize, 4))
-	uint32 compSize;
-	wrap(file.read(&compSize, 4))
+	uint32 realSize = file.readUint32LE();
+	uint32 compSize = file.readUint32LE();
 
 	    // exist hidden entries
 	for (int32 i = 0; i < hiddenIndex; i++) {
 		wrap(file.seek(offsetToData + compSize + 10)) // hidden entry
 		offsetToData = offsetToData + compSize + 10;  // current hidden offset
 
-		wrap(file.read(&realSize, 4))
-		wrap(file.read(&compSize, 4))
+		realSize = file.readUint32LE();
+		compSize = file.readUint32LE();
 	}
 
 	return realSize;
@@ -168,21 +163,17 @@ int32 entrySize(const char *filename, int32 index) {
 		return 0;
 	}
 
-	uint32 headerSize;
-	wrap(file.read(&headerSize, 4))
-
+	uint32 headerSize = file.readUint32LE();
 	if ((uint32)index >= headerSize / 4) {
 		warning("HQR: Invalid entry index");
 		return 0;
 	}
 
 	wrap(file.seek(index * 4))
-	uint32 offsetToData;
-	wrap(file.read(&offsetToData, 4))
+	uint32 offsetToData = file.readUint32LE();
 
 	wrap(file.seek(offsetToData))
-	uint32 realSize;
-	wrap(file.read(&realSize, 4))
+	uint32 realSize = file.readUint32LE();
 
 	return realSize;
 }
@@ -197,8 +188,8 @@ int32 numEntries(const char *filename) {
 		error("HQR: Could not open %s", filename);
 	}
 
-	uint32 headerSize;
-	wrap(file.read(&headerSize, 4)) return ((int)headerSize / 4) - 1;
+	uint32 headerSize = file.readUint32LE();
+	return ((int)headerSize / 4) - 1;
 }
 
 int32 getAllocEntry(uint8 **ptr, const char *filename, int32 index) {
@@ -226,8 +217,7 @@ int32 getVoxEntry(uint8 *ptr, const char *filename, int32 index, int32 hiddenInd
 		error("HQR: Could not open %s", filename);
 	}
 
-	uint32 headerSize;
-	wrap(file.read(&headerSize, 4))
+	uint32 headerSize = file.readUint32LE();
 
 	if ((uint32)index >= headerSize / 4) {
 		warning("HQR: Invalid entry index");
@@ -235,25 +225,21 @@ int32 getVoxEntry(uint8 *ptr, const char *filename, int32 index, int32 hiddenInd
 	}
 
 	wrap(file.seek(index * 4))
-	uint32 offsetToData;
-	wrap(file.read(&offsetToData, 4))
+	uint32 offsetToData = file.readUint32LE();
 
 	wrap(file.seek(offsetToData))
-	uint32 realSize;
-	wrap(file.read(&realSize, 4))
-	uint32 compSize;
-	wrap(file.read(&compSize, 4))
-	uint16 mode;
-	wrap(file.read(&mode, 2))
+	uint32 realSize = file.readUint32LE();
+	uint32 compSize = file.readUint32LE();
+	uint16 mode = file.readSint16LE();
 
 	// exist hidden entries
 	for (int32 i = 0; i < hiddenIndex; i++) {
 		wrap(file.seek(offsetToData + compSize + 10)) // hidden entry
 		offsetToData = offsetToData + compSize + 10;  // current hidden offset
 
-		wrap(file.read(&realSize, 4))
-		wrap(file.read(&compSize, 4))
-			wrap(file.read(&mode, 2))
+		realSize = file.readUint32LE();
+		compSize = file.readUint32LE();
+		mode = file.readUint16LE();
 	}
 
 	// uncompressed
@@ -262,8 +248,7 @@ int32 getVoxEntry(uint8 *ptr, const char *filename, int32 index, int32 hiddenInd
 	}
 	// compressed: modes (1 & 2)
 	else if (mode == 1 || mode == 2) {
-		uint8 *compDataPtr = 0;
-		compDataPtr = (uint8 *)malloc(compSize);
+		uint8 *compDataPtr = (uint8 *)malloc(compSize);
 		wrap(file.read(compDataPtr, compSize))
 		decompressEntry(ptr, compDataPtr, realSize, mode);
 		free(compDataPtr);


Commit: ff402669343c2efd94572226c6f3747515a940ba
    https://github.com/scummvm/scummvm/commit/ff402669343c2efd94572226c6f3747515a940ba
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-31T13:02:07+01:00

Commit Message:
TWINE: convert all hqr errors into warnings

Changed paths:
    engines/twine/hqr.cpp


diff --git a/engines/twine/hqr.cpp b/engines/twine/hqr.cpp
index c980904b13..2837c0883e 100644
--- a/engines/twine/hqr.cpp
+++ b/engines/twine/hqr.cpp
@@ -79,7 +79,8 @@ static int voxEntrySize(const char *filename, int32 index, int32 hiddenIndex) {
 
 	Common::File file;
 	if (!file.open(filename)) {
-		error("HQR: Could not open %s", filename);
+		warning("HQR: Could not open %s", filename);
+		return 0;
 	}
 
 	uint32 headerSize = file.readUint32LE();
@@ -117,7 +118,7 @@ int32 getEntry(uint8 *ptr, const char *filename, int32 index) {
 
 	Common::File file;
 	if (!file.open(filename)) {
-		debug("HQR: Could not open %s", filename);
+		warning("HQR: Could not open %s", filename);
 		return 0;
 	}
 
@@ -185,7 +186,8 @@ int32 numEntries(const char *filename) {
 
 	Common::File file;
 	if (!file.open(filename)) {
-		error("HQR: Could not open %s", filename);
+		warning("HQR: Could not open %s", filename);
+		return 0;
 	}
 
 	uint32 headerSize = file.readUint32LE();
@@ -214,7 +216,8 @@ int32 getVoxEntry(uint8 *ptr, const char *filename, int32 index, int32 hiddenInd
 
 	Common::File file;
 	if (!file.open(filename)) {
-		error("HQR: Could not open %s", filename);
+		warning("HQR: Could not open %s", filename);
+		return 0;
 	}
 
 	uint32 headerSize = file.readUint32LE();


Commit: cc4e3a30d8fd348b96caca81b707cbe775dcbcc2
    https://github.com/scummvm/scummvm/commit/cc4e3a30d8fd348b96caca81b707cbe775dcbcc2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-31T13:02:07+01:00

Commit Message:
TWINE: fixed voice samples

Changed paths:
    engines/twine/sound.cpp


diff --git a/engines/twine/sound.cpp b/engines/twine/sound.cpp
index ef185193a3..7cc4123a09 100644
--- a/engines/twine/sound.cpp
+++ b/engines/twine/sound.cpp
@@ -119,6 +119,7 @@ void Sound::playVoxSample(int32 index) {
 	if (*sampPtr != 'C') {
 		_engine->_text->hasHiddenVox = *sampPtr != '\0';
 		_engine->_text->voxHiddenIndex++;
+		*sampPtr = 'C';
 	}
 
 	playSample(channelIdx, index, sampPtr, sampSize, 1, _engine->_text->currentVoxBankFile.c_str());


Commit: a286db2d3c32d3396a056a6e2f30078a9c9a4ab4
    https://github.com/scummvm/scummvm/commit/a286db2d3c32d3396a056a6e2f30078a9c9a4ab4
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-31T13:02:07+01:00

Commit Message:
TWINE: use voice volume for speech

Changed paths:
    engines/twine/sound.cpp
    engines/twine/sound.h


diff --git a/engines/twine/sound.cpp b/engines/twine/sound.cpp
index 7cc4123a09..9271c5f273 100644
--- a/engines/twine/sound.cpp
+++ b/engines/twine/sound.cpp
@@ -94,7 +94,7 @@ void Sound::playSample(int32 index, int32 frequency, int32 repeat, int32 x, int3
 
 	uint8 *sampPtr = _engine->_resources->samplesTable[index];
 	int32 sampSize = _engine->_resources->samplesSizeTable[index];
-	playSample(channelIdx, index, sampPtr, sampSize, repeat, Resources::HQR_SAMPLES_FILE, DisposeAfterUse::NO);
+	playSample(channelIdx, index, sampPtr, sampSize, repeat, Resources::HQR_SAMPLES_FILE, Audio::Mixer::kPlainSoundType, DisposeAfterUse::NO);
 }
 
 void Sound::playVoxSample(int32 index) {
@@ -122,17 +122,17 @@ void Sound::playVoxSample(int32 index) {
 		*sampPtr = 'C';
 	}
 
-	playSample(channelIdx, index, sampPtr, sampSize, 1, _engine->_text->currentVoxBankFile.c_str());
+	playSample(channelIdx, index, sampPtr, sampSize, 1, _engine->_text->currentVoxBankFile.c_str(), Audio::Mixer::kSpeechSoundType);
 }
 
-bool Sound::playSample(int channelIdx, int index, uint8 *sampPtr, int32 sampSize, int32 loop, const char *name, DisposeAfterUse::Flag disposeFlag) {
+bool Sound::playSample(int channelIdx, int index, uint8 *sampPtr, int32 sampSize, int32 loop, const char *name, Audio::Mixer::SoundType soundType, DisposeAfterUse::Flag disposeFlag) {
 	Common::MemoryReadStream *stream = new Common::MemoryReadStream(sampPtr, sampSize, disposeFlag);
 	Audio::SeekableAudioStream *audioStream = Audio::makeVOCStream(stream, DisposeAfterUse::YES);
 	if (audioStream == nullptr) {
 		warning("Failed to create audio stream for %s", name);
 		return false;
 	}
-	_engine->_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &samplesPlaying[channelIdx], audioStream, index);
+	_engine->_system->getMixer()->playStream(soundType, &samplesPlaying[channelIdx], audioStream, index);
 	return true;
 }
 
diff --git a/engines/twine/sound.h b/engines/twine/sound.h
index fddbf48d95..fc9d9c1bad 100644
--- a/engines/twine/sound.h
+++ b/engines/twine/sound.h
@@ -59,7 +59,7 @@ private:
 	/** Samples playing at a actors position */
 	int32 samplesPlayingActors[NUM_CHANNELS]{0};
 
-	bool playSample(int channelIdx, int index, uint8 *sampPtr, int32 sampSize, int32 loop, const char *name, DisposeAfterUse::Flag disposeFlag = DisposeAfterUse::YES);
+	bool playSample(int channelIdx, int index, uint8 *sampPtr, int32 sampSize, int32 loop, const char *name, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType, DisposeAfterUse::Flag disposeFlag = DisposeAfterUse::YES);
 
 	bool isChannelPlaying(int32 channel);
 




More information about the Scummvm-git-logs mailing list