[Scummvm-cvs-logs] scummvm master -> 149fdbfb60b90d6659cc4ad426335e376b707311

athrxx athrxx at scummvm.org
Sat Sep 17 21:35:48 CEST 2011


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

Summary:
867f2887e8 SCUMM FM-TOWNS: fix invalid mem accesses
0d1d974e14 SCUMM FM-TOWNS: fix regression and cleanup
149fdbfb60 SCUMM FM-TOWNS: fix another regression


Commit: 867f2887e8b3c74dda2b66ea58a26148286db1a3
    https://github.com/scummvm/scummvm/commit/867f2887e8b3c74dda2b66ea58a26148286db1a3
Author: athrxx (athrxx at scummvm.org)
Date: 2011-09-17T12:15:41-07:00

Commit Message:
SCUMM FM-TOWNS: fix invalid mem accesses

- handle some invalid sound resources that come up when starting LOOM
- fix typo in midi driver code (causing invalid mem reads)

Changed paths:
    audio/softsynth/fmtowns_pc98/towns_midi.cpp
    engines/scumm/player_towns.cpp



diff --git a/audio/softsynth/fmtowns_pc98/towns_midi.cpp b/audio/softsynth/fmtowns_pc98/towns_midi.cpp
index d69ed73..b820394 100644
--- a/audio/softsynth/fmtowns_pc98/towns_midi.cpp
+++ b/audio/softsynth/fmtowns_pc98/towns_midi.cpp
@@ -563,7 +563,7 @@ int TownsMidiOutputChannel::getEffectModLevel(int lvl, int mod) {
 		if (lvl < 0)
 			return -_driver->_operatorLevelTable[((-lvl) << 5) + mod];
 		else
-			return _driver->_operatorLevelTable[((-lvl) << 5) + mod];
+			return _driver->_operatorLevelTable[(lvl << 5) + mod];
 	}
 
 	return 0;
diff --git a/engines/scumm/player_towns.cpp b/engines/scumm/player_towns.cpp
index dd7630d..f6f493a 100644
--- a/engines/scumm/player_towns.cpp
+++ b/engines/scumm/player_towns.cpp
@@ -242,7 +242,8 @@ void Player_Towns_v1::startSound(int sound) {
 		}
 
 		velocity = velocity ? velocity >> 2 : ptr[14] >> 1;
-		playPcmTrack(sound, ptr + 6, velocity, 64, note ? note : ptr[50], READ_LE_UINT16(ptr + 10));
+		uint16 len = READ_LE_UINT16(ptr) + 2;
+		playPcmTrack(sound, ptr + 6, velocity, 64, note ? note : (len > 50 ? ptr[50] : 60), READ_LE_UINT16(ptr + 10));
 
 	} else if (type == 1) {
 		playEuphonyTrack(sound, ptr + 6);


Commit: 0d1d974e14f80dda31e306716b4f9e779c6c35fc
    https://github.com/scummvm/scummvm/commit/0d1d974e14f80dda31e306716b4f9e779c6c35fc
Author: athrxx (athrxx at scummvm.org)
Date: 2011-09-17T12:15:44-07:00

Commit Message:
SCUMM FM-TOWNS: fix regression and cleanup

(LOOM mouse cursor was broken in b1cb88ddc25da64772bbba253bd2210678189ace)

Changed paths:
    engines/scumm/charset.cpp
    engines/scumm/charset.h



diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index f7b98e2..5c53ac7 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -511,14 +511,15 @@ void CharsetRendererV3::enableShadow(bool enable) {
 	_shadowMode = enable;
 }
 
-void CharsetRendererV3::drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth) {
-	int y, x;
+void CharsetRendererV3::drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height) {
+	byte *dst = (byte *)dest.getBasePtr(x, y);
+
 	byte bits = 0;
 	uint8 col = _color;
-	int pitch = s.pitch - width * bitDepth;
-	byte *dst2 = dst + s.pitch;
+	int pitch = dest.pitch - width * dest.format.bytesPerPixel;
+	byte *dst2 = dst + dest.pitch;
 
-	for (y = 0; y < height && y + drawTop < s.h; y++) {
+	for (y = 0; y < height && y + drawTop < dest.h; y++) {
 		for (x = 0; x < width; x++) {
 			if ((x % 8) == 0)
 				bits = *src++;
@@ -527,8 +528,8 @@ void CharsetRendererV3::drawBits1(const Graphics::Surface &s, byte *dst, const b
 					dst[1] = dst2[0] = dst2[1] = _shadowColor;
 				dst[0] = col;
 			}
-			dst += bitDepth;
-			dst2 += bitDepth;
+			dst += dest.format.bytesPerPixel;
+			dst2 += dest.format.bytesPerPixel;
 		}
 
 		dst += pitch;
@@ -591,7 +592,6 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) {
 	int width, height, origWidth = 0, origHeight;
 	VirtScreen *vs;
 	const byte *charPtr;
-	byte *dst;
 	int is2byte = (chr >= 256 && _vm->_useCJKMode) ? 1 : 0;
 
 	assertRange(0, _curId, _vm->_numCharsets - 1, "charset");
@@ -636,13 +636,10 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) {
 		_textScreenID = vs->number;
 	}
 
-	if ((ignoreCharsetMask || !vs->hasTwoBuffers)) {
-		dst = vs->getPixels(_left, drawTop);
-		drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->format.bytesPerPixel);
-	} else {
-		dst = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier);
-		drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.format.bytesPerPixel);
-	}
+	if ((ignoreCharsetMask || !vs->hasTwoBuffers) && (_vm->_game.platform != Common::kPlatformFMTowns))
+		drawBits1(*vs, _left + vs->xstart, drawTop, charPtr, drawTop, origWidth, origHeight);
+	else
+		drawBits1(_vm->_textSurface, _left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier, charPtr, drawTop, origWidth, origHeight);
 	
 	if (is2byte) {
 		origWidth /= _vm->_textSurfaceMultiplier;
@@ -669,9 +666,7 @@ void CharsetRendererV3::drawChar(int chr, Graphics::Surface &s, int x, int y) {
 	int width = getDrawWidthIntern(chr);
 	int height = getDrawHeightIntern(chr);
 	setDrawCharIntern(chr);
-
-	byte *dst = (byte *)s.pixels + y * s.pitch + x;
-	drawBits1(s, dst, charPtr, y, width, height, s.format.bytesPerPixel);
+	drawBits1(s, x, y, charPtr, y, width, height);
 }
 
 void CharsetRenderer::translateColor() {
@@ -993,50 +988,43 @@ void CharsetRendererTownsV3::enableShadow(bool enable) {
 #endif
 }
 
-void CharsetRendererTownsV3::drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth) {
+void CharsetRendererTownsV3::drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height) {
 #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
 #ifdef USE_RGB_COLOR
 	if (_sjisCurChar) {
 		assert(_vm->_cjkFont);
-		_vm->_cjkFont->drawChar(_vm->_textSurface, _sjisCurChar, _left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier, _color, _shadowColor);
+		_vm->_cjkFont->drawChar(dest, _sjisCurChar, x, y, _color, _shadowColor);
 		return;
 	}
 #endif
-
-	dst = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier);
-	int sfPitch = _vm->_textSurface.pitch;
-	int sfHeight = _vm->_textSurface.h;
-	bool scale2x = (_vm->_textSurfaceMultiplier == 2 && !(_sjisCurChar >= 256 && _vm->_useCJKMode));
-#else
-	int sfPitch = s.pitch;
-	int sfHeight = s.h;
+	byte *dst = (byte *)dest.getBasePtr(x, y);
+	bool scale2x = ((&dest == &_vm->_textSurface) && (_vm->_textSurfaceMultiplier == 2) && !(_sjisCurChar >= 256 && _vm->_useCJKMode));
 #endif
 
-	int y, x;
 	byte bits = 0;
 	uint8 col = _color;
-	int pitch = sfPitch - width * bitDepth;
-	byte *dst2 = dst + sfPitch;
+	int pitch = dest.pitch - width * dest.format.bytesPerPixel;
+	byte *dst2 = dst + dest.pitch;
 
 #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
 	byte *dst3 = dst2;
 	byte *dst4 = dst2;
 	if (scale2x) {
-		dst3 = dst2 + sfPitch;
-		dst4 = dst3 + sfPitch;
+		dst3 = dst2 + dest.pitch;
+		dst4 = dst3 + dest.pitch;
 		pitch <<= 1;
 	}
 #endif
 
-	for (y = 0; y < height && y + drawTop < sfHeight; y++) {
+	for (y = 0; y < height && y + drawTop < dest.h; y++) {
 		for (x = 0; x < width; x++) {
 			if ((x % 8) == 0)
 				bits = *src++;
 			if ((bits & revBitMask(x % 8)) && y + drawTop >= 0) {
-				if (bitDepth == 2) {
+				if (dest.format.bytesPerPixel == 2) {
 					if (_shadowMode) {
 						WRITE_UINT16(dst + 2, _vm->_16BitPalette[_shadowColor]);
-						WRITE_UINT16(dst + sfPitch, _vm->_16BitPalette[_shadowColor]);
+						WRITE_UINT16(dst + dest.pitch, _vm->_16BitPalette[_shadowColor]);
 					}
 					WRITE_UINT16(dst, _vm->_16BitPalette[_color]);
 				} else {
@@ -1059,8 +1047,8 @@ void CharsetRendererTownsV3::drawBits1(const Graphics::Surface &s, byte *dst, co
 #endif
 				}
 			}
-			dst += bitDepth;
-			dst2 += bitDepth;
+			dst += dest.format.bytesPerPixel;
+			dst2 += dest.format.bytesPerPixel;
 #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
 			if (scale2x) {
 				dst++;
@@ -1106,45 +1094,45 @@ void CharsetRendererTownsV3::setDrawCharIntern(uint16 chr) {
 #endif
 
 #ifdef USE_RGB_COLOR
-void CharsetRendererPCE::drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth) {
+void CharsetRendererPCE::drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height) {
+	byte *dst = (byte *)dest.getBasePtr(x, y);
 	if (_sjisCurChar) {
 		assert(_vm->_cjkFont);
 		uint16 col1 = _color;
 		uint16 col2 = _shadowColor;
 
-		if (s.format.bytesPerPixel == 2) {
+		if (dest.format.bytesPerPixel == 2) {
 			col1 = _vm->_16BitPalette[col1];
 			col2 = _vm->_16BitPalette[col2];
 		}
 
-		_vm->_cjkFont->drawChar(dst, _sjisCurChar, s.pitch, s.format.bytesPerPixel, col1, col2, -1, -1);
+		_vm->_cjkFont->drawChar(dst, _sjisCurChar, dest.pitch, dest.format.bytesPerPixel, col1, col2, -1, -1);
 		return;
 	}
 
-	int y, x;
 	byte bits = 0;
 
-	for (y = 0; y < height && y + drawTop < s.h; y++) {
+	for (y = 0; y < height && y + drawTop < dest.h; y++) {
 		int bitCount = 0;
 		for (x = 0; x < width; x++) {
 			if ((bitCount % 8) == 0)
 				bits = *src++;
 			if ((bits & revBitMask(bitCount % 8)) && y + drawTop >= 0) {
-				if (bitDepth == 2) {
+				if (dest.format.bytesPerPixel == 2) {
 					if (_shadowMode)
-						WRITE_UINT16(dst + s.pitch + 2, _vm->_16BitPalette[_shadowColor]);
+						WRITE_UINT16(dst + dest.pitch + 2, _vm->_16BitPalette[_shadowColor]);
 					WRITE_UINT16(dst, _vm->_16BitPalette[_color]);
 				} else {
 					if (_shadowMode)
-						*(dst + s.pitch + 1) = _shadowColor;
+						*(dst + dest.pitch + 1) = _shadowColor;
 					*dst = _color;
 				}
 			}
-			dst += bitDepth;
+			dst += dest.format.bytesPerPixel;
 			bitCount++;
 		}
 
-		dst += s.pitch - width * bitDepth;
+		dst += dest.pitch - width * dest.format.bytesPerPixel;
 	}
 }
 
@@ -1282,7 +1270,7 @@ void CharsetRendererNut::printChar(int chr, bool ignoreCharsetMask) {
 void CharsetRendererNES::printChar(int chr, bool ignoreCharsetMask) {
 	int width, height, origWidth, origHeight;
 	VirtScreen *vs;
-	byte *charPtr, *dst;
+	byte *charPtr;
 
 	// Init it here each time since it is cheap and fixes bug with
 	// charset after game load
@@ -1322,13 +1310,10 @@ void CharsetRendererNES::printChar(int chr, bool ignoreCharsetMask) {
 		_textScreenID = vs->number;
 	}
 
-	if (ignoreCharsetMask || !vs->hasTwoBuffers) {
-		dst = vs->getPixels(_left, drawTop);
-		drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->format.bytesPerPixel);
-	} else {
-		dst = (byte *)_vm->_textSurface.pixels + _top * _vm->_textSurface.pitch + _left;
-		drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.format.bytesPerPixel);
-	}
+	if (ignoreCharsetMask || !vs->hasTwoBuffers)
+		drawBits1(*vs, _left + vs->xstart, drawTop, charPtr, drawTop, origWidth, origHeight);
+	else
+		drawBits1(_vm->_textSurface, _left, _top, charPtr, drawTop, origWidth, origHeight);
 
 	if (_str.left > _left)
 		_str.left = _left;
@@ -1346,7 +1331,7 @@ void CharsetRendererNES::printChar(int chr, bool ignoreCharsetMask) {
 }
 
 void CharsetRendererNES::drawChar(int chr, Graphics::Surface &s, int x, int y) {
-	byte *charPtr, *dst;
+	byte *charPtr;
 	int width, height;
 
 	if (!_trTable)
@@ -1356,8 +1341,7 @@ void CharsetRendererNES::drawChar(int chr, Graphics::Surface &s, int x, int y) {
 	width = getCharWidth(chr);
 	height = 8;
 
-	dst = (byte *)s.pixels + y * s.pitch + x;
-	drawBits1(s, dst, charPtr, y, width, height, s.format.bytesPerPixel);
+	drawBits1(s, x, y, charPtr, y, width, height);
 }
 
 #ifdef USE_RGB_COLOR
@@ -1557,14 +1541,15 @@ void CharsetRendererTownsClassic::processCharsetColors() {
 #endif
 #endif
 
-void CharsetRendererNES::drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth) {
+void CharsetRendererNES::drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height) {
+	byte *dst = (byte *)dest.getBasePtr(x, y);
 	for (int i = 0; i < 8; i++) {
 		byte c0 = src[i];
 		byte c1 = src[i + 8];
 		for (int j = 0; j < 8; j++)
 			dst[j] = _vm->_NESPalette[0][((c0 >> (7 - j)) & 1) | (((c1 >> (7 - j)) & 1) << 1) |
 			(_color ? 12 : 8)];
-		dst += s.pitch;
+		dst += dest.pitch;
 	}
 }
 
diff --git a/engines/scumm/charset.h b/engines/scumm/charset.h
index fabb82b..b8f1d84 100644
--- a/engines/scumm/charset.h
+++ b/engines/scumm/charset.h
@@ -156,7 +156,7 @@ class CharsetRendererNES : public CharsetRendererCommon {
 protected:
 	byte *_trTable;
 
-	void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth);
+	void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
 
 public:
 	CharsetRendererNES(ScummEngine *vm) : CharsetRendererCommon(vm) {}
@@ -172,7 +172,7 @@ public:
 class CharsetRendererV3 : public CharsetRendererCommon {
 protected:
 	virtual void enableShadow(bool enable);
-	virtual void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth);
+	virtual void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
 	virtual int getDrawWidthIntern(uint16 chr);
 	virtual int getDrawHeightIntern(uint16 chr);
 	virtual void setDrawCharIntern(uint16 chr) {}
@@ -198,7 +198,7 @@ public:
 	
 private:
 	void enableShadow(bool enable);
-	void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth);
+	void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
 #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
 	int getDrawWidthIntern(uint16 chr);
 	int getDrawHeightIntern(uint16 chr);
@@ -210,7 +210,7 @@ private:
 #ifdef USE_RGB_COLOR
 class CharsetRendererPCE : public CharsetRendererV3 {
 private:
-	void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth);
+	void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
 
 	int getDrawWidthIntern(uint16 chr);
 	int getDrawHeightIntern(uint16 chr);


Commit: 149fdbfb60b90d6659cc4ad426335e376b707311
    https://github.com/scummvm/scummvm/commit/149fdbfb60b90d6659cc4ad426335e376b707311
Author: athrxx (athrxx at scummvm.org)
Date: 2011-09-17T12:15:46-07:00

Commit Message:
SCUMM FM-TOWNS: fix another regression

(pcm sound effects broken in 69adb13c2f3cadd4dac2bba8164aa0b8a9400abc)

Changed paths:
    engines/scumm/sound.cpp



diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index d823520..ba8c6e2 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -1150,19 +1150,20 @@ int ScummEngine::readSoundResource(ResId idx) {
 			if ((_sound->_musicType == MDT_PCSPK || _sound->_musicType == MDT_PCJR) && pri != 11)
 				pri = -1;
 
-			// We only allow ADL resources when AdLib or FM-Towns is used as
-			// primary audio output. This fixes some odd sounds when Indy and
-			// Sophia leave Atlantis with the submarine in Indy4. (Easy to
-			// check with bootparam 4061 in the CD version). It seems the game
-			// only contains a ROL resource for sound id 60. Formerly we tried
-			// to play that via the AdLib or FM-Towns audio driver resulting
-			// in strange noises. Now we behave like the original did.
+			// We only allow ADL, SBL and TOWS resources when AdLib
+			// or FM-Towns is used as primary audio output. This fixes some
+			// odd sounds when Indy and Sophia leave Atlantis with the
+			// submarine in Indy4. (Easy to check with bootparam 4061 in
+			// the CD version). It seems the game only contains a ROL resource
+			// for sound id 60. Formerly we tried to play that via the AdLib
+			// or FM-Towns audio driver resulting in strange noises. Now we
+			// behave like the original did.
 			// We make an exception for Macintosh, which uses priority 2 for
 			// its sound resources, and Amiga games, which feature only ROL
 			// resources, since we are a doing Midi -> AdLib conversion for
 			// these.
-			if ((_sound->_musicType == MDT_ADLIB || _sound->_musicType == MDT_TOWNS) && pri != 10
-				&& pri != 2 && _game.platform != Common::kPlatformAmiga)
+			if ((_sound->_musicType == MDT_ADLIB || _sound->_musicType == MDT_TOWNS) && pri != 16 
+				&& pri != 15 && pri != 10 && pri != 2 && _game.platform != Common::kPlatformAmiga)
 				pri = -1;
 
 			debugC(DEBUG_RESOURCE, "    tag: %s, total_size=%d, pri=%d", tag2str(tag), size, pri);






More information about the Scummvm-git-logs mailing list