[Scummvm-cvs-logs] scummvm master -> c1f93815ee9d41d4e505dde87fdd503f94e31dae

Strangerke Strangerke at scummvm.org
Sun Aug 4 10:47:29 CEST 2013


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

Summary:
c1f93815ee MORTEVIELLE: Compute real buffer size in order to avoid ticks at the end of the song


Commit: c1f93815ee9d41d4e505dde87fdd503f94e31dae
    https://github.com/scummvm/scummvm/commit/c1f93815ee9d41d4e505dde87fdd503f94e31dae
Author: Strangerke (strangerke at scummvm.org)
Date: 2013-08-04T01:46:10-07:00

Commit Message:
MORTEVIELLE: Compute real buffer size in order to avoid ticks at the end of the song

Changed paths:
    engines/mortevielle/sound.cpp
    engines/mortevielle/sound.h
    engines/mortevielle/utils.cpp



diff --git a/engines/mortevielle/sound.cpp b/engines/mortevielle/sound.cpp
index 76495c6..3cb5284 100644
--- a/engines/mortevielle/sound.cpp
+++ b/engines/mortevielle/sound.cpp
@@ -148,11 +148,13 @@ SoundManager::~SoundManager() {
 /**
  * Decode music data
  */
-void SoundManager::decodeMusic(const byte *PSrc, byte *PDest, int size) {
+int SoundManager::decodeMusic(const byte *PSrc, byte *PDest, int size) {
 	static const int tab[16] = { -96, -72, -48, -32, -20, -12, -8, -4, 0, 4, 8, 12, 20, 32, 48, 72 };
 
 	uint seed = 128;
 	int v;
+	int decompSize = 0;
+	int skipSize = 0;
 
 	for (int idx1 = 0; idx1 < size; ++idx1) {
 		byte srcByte = *PSrc++;
@@ -163,7 +165,15 @@ void SoundManager::decodeMusic(const byte *PSrc, byte *PDest, int size) {
 		v = tab[srcByte & 0xf];
 		seed += v;
 		*PDest++ = seed & 0xff;
+
+		if (srcByte == 0)
+			skipSize += 2;
+		else {
+			decompSize += skipSize + 2;
+			skipSize = 0;
+		}
 	}
+	return decompSize;
 }
 
 void SoundManager::litph(tablint &t, int typ, int tempo) {
diff --git a/engines/mortevielle/sound.h b/engines/mortevielle/sound.h
index c1df98e..313859d 100644
--- a/engines/mortevielle/sound.h
+++ b/engines/mortevielle/sound.h
@@ -105,7 +105,7 @@ public:
 	void setParent(MortevielleEngine *vm);
 	void playNote(int frequency, int32 length);
 
-	void decodeMusic(const byte *PSrc, byte *PDest, int size);
+	int decodeMusic(const byte *PSrc, byte *PDest, int size);
 	void playSong(const byte *buf, int size);
 
 	void litph(tablint &t, int typ, int tempo);
diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp
index b729d59..d5dc678 100644
--- a/engines/mortevielle/utils.cpp
+++ b/engines/mortevielle/utils.cpp
@@ -2207,7 +2207,7 @@ void MortevielleEngine::music() {
 	f.read(compMusicBuf, size);
 	f.close();
 
-	_soundManager.decodeMusic(compMusicBuf, musicBuf, size);
+	int musicSize = _soundManager.decodeMusic(compMusicBuf, musicBuf, size);
 	free(compMusicBuf);
 
 	_addFix = (float)((kTempoMusic - 8)) / 256;
@@ -2217,7 +2217,7 @@ void MortevielleEngine::music() {
 	int k = 0;
 	do {
 		fin = keyPressed();
-		_soundManager.playSong(musicBuf, size * 2);
+		_soundManager.playSong(musicBuf, musicSize);
 		++k;
 		fin = fin | keyPressed() | (k >= 5);
 	} while (!fin);






More information about the Scummvm-git-logs mailing list