[Scummvm-git-logs] scummvm master -> 021d47cbac8266cd0887dd9a5255a9a77b3f4a31

Die4Ever noreply at scummvm.org
Thu Dec 9 17:42:49 UTC 2021


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:
021d47cbac GROOVIE: fix ROQ _restoreArea


Commit: 021d47cbac8266cd0887dd9a5255a9a77b3f4a31
    https://github.com/scummvm/scummvm/commit/021d47cbac8266cd0887dd9a5255a9a77b3f4a31
Author: Die4Ever (die4ever2005 at gmail.com)
Date: 2021-12-09T11:42:26-06:00

Commit Message:
GROOVIE: fix ROQ _restoreArea

Setting it to all 0s meant that the min function gave the wrong results. Needed to top and left to be large numbers so that the min function has the correct affect on them. 9999 is a better choice here than 640 and 480, because before it looked like a full screen rectangle until you realized it was inverted.

Changed paths:
    engines/groovie/script.cpp
    engines/groovie/video/roq.cpp
    engines/groovie/video/roq.h


diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index a6aaeaa9be..3a92873190 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -2083,7 +2083,7 @@ void Script::o2_videofromref() {
 	// Show the debug information just when starting the playback
 	if (fileref != _videoRef) {
 		debugC(1, kDebugScript, "Groovie::Script: VIDEOFROMREF(0x%08X) (Not fully imp): Play video file from ref", fileref);
-		debugC(2, kDebugVideo, "\nGroovie::Script: @0x%04X: Playing video %d via 0x09", _currentInstruction-5, fileref);
+		debugC(2, kDebugVideo, "\nGroovie::Script: @0x%04X: Playing video %d via 0x09 (o2_videofromref)", _currentInstruction-5, fileref);
 	}
 
 	// Clear bit 1
@@ -2102,7 +2102,7 @@ void Script::o2_vdxtransition() {
 	// Show the debug information just when starting the playback
 	if (fileref != _videoRef) {
 		debugC(1, kDebugScript, "Groovie::Script: VDX transition fileref = 0x%08X", fileref);
-		debugC(2, kDebugVideo, "\nGroovie::Script: @0x%04X: Playing video %d with transition via 0x1C", _currentInstruction-5, fileref);
+		debugC(2, kDebugVideo, "\nGroovie::Script: @0x%04X: Playing video %d with transition via 0x1C (o2_vdxtransition)", _currentInstruction-5, fileref);
 	}
 
 	// Set bit 1
diff --git a/engines/groovie/video/roq.cpp b/engines/groovie/video/roq.cpp
index 1fe7b314f8..ff1e945fb6 100644
--- a/engines/groovie/video/roq.cpp
+++ b/engines/groovie/video/roq.cpp
@@ -133,14 +133,14 @@ void ROQPlayer::stopAudioStream() {
 uint16 ROQPlayer::loadInternal() {
 	if (DebugMan.isDebugChannelEnabled(kDebugVideo)) {
 		int8 i;
-		debugN(1, "Groovie::ROQ: Loading video. New ROQ: bitflags are ");
+		debugCN(1, kDebugVideo, "Groovie::ROQ: Loading video. New ROQ: bitflags are ");
 		for (i = 15; i >= 0; i--) {
-			debugN(1, "%d", _flags & (1 << i)? 1 : 0);
+			debugCN(1, kDebugVideo, "%d", _flags & (1 << i) ? 1 : 0);
 			if (i % 4 == 0) {
-				debugN(1, " ");
+				debugCN(1, kDebugVideo, " ");
 			}
 		}
-		debug(1, " <- 0 ");
+		debugC(1, kDebugVideo, " <- 0 ");
 	}
 
 	// Flags:
@@ -168,8 +168,8 @@ uint16 ROQPlayer::loadInternal() {
 
 	// Clear the dirty flag and restore area
 	_dirty = false;
-	_restoreArea->top = 0;
-	_restoreArea->left = 0;
+	_restoreArea->top = 9999;
+	_restoreArea->left = 9999;
 	_restoreArea->bottom = 0;
 	_restoreArea->right = 0;
 
@@ -211,6 +211,45 @@ void ROQPlayer::calcStartStop(int &start, int &stop, int origin, int length) {
 	}
 }
 
+void ROQPlayer::redrawRestoreArea(int screenOffset) {
+	// Restore the background by data from the foreground. Only restore the area which was overwritten during the last frame
+	// Therefore we have the _restoreArea which reduces the area for restoring. We also use the _prevBuf to only overwrite the
+	// Pixels which have been written during the last frame. This means _restoreArea is just an optimization.
+	if (!_alpha)
+		return;
+	if (_restoreArea->isEmpty())
+		return;
+
+	int width = _restoreArea->right - _restoreArea->left;
+	Graphics::Surface *screen = _vm->_system->lockScreen();
+	assert(screen->format == _bg->format);
+	assert(screen->format.bytesPerPixel == 4);
+	for (int line = _restoreArea->top; line < _restoreArea->bottom; line++) {
+		byte *dst = (byte *)screen->getBasePtr(_restoreArea->left, line + screenOffset);
+		byte *src = (byte *)_bg->getBasePtr(_restoreArea->left, line);
+		byte *prv = (byte *)_prevBuf->getBasePtr((_restoreArea->left - _origX) / _scaleX, (line - _origY) / _scaleY);
+		byte *ovr = (byte *)_overBuf->getBasePtr(_restoreArea->left, line);
+
+		for (int i = 0; i < width; i++) {
+			if (prv[kAIndex] != 0) {
+				copyPixel(dst, src);
+				copyPixelWithA(dst, ovr);
+			}
+			src += _bg->format.bytesPerPixel;
+			dst += _bg->format.bytesPerPixel;
+			prv += _bg->format.bytesPerPixel;
+			ovr += _bg->format.bytesPerPixel;
+		}
+	}
+	_vm->_system->unlockScreen();
+
+	// Reset _restoreArea for the next frame
+	_restoreArea->top = 9999;
+	_restoreArea->left = 9999;
+	_restoreArea->bottom = 0;
+	_restoreArea->right = 0;
+}
+
 void ROQPlayer::buildShowBuf() {
 	// Calculate screen offset for normal / fullscreen videos and images
 	int screenOffset = 0;
@@ -218,40 +257,8 @@ void ROQPlayer::buildShowBuf() {
 		screenOffset = 80;
 	}
 
-	// Restore the background by data from the foreground. Only restore the area which was overwritten during the last frame
-	// Therefore we have the _restoreArea which reduces the area for restoring. We also use the _prevBuf to only overwrite the
-	// Pixels which have been written during the last frame. This means _restoreArea is just an optimization.
 	if (_alpha) {
-		if (!_restoreArea->isEmpty()) {
-			int width = _restoreArea->right - _restoreArea->left;
-			Graphics::Surface *screen = _vm->_system->lockScreen();
-			assert(screen->format == _bg->format);
-			assert(screen->format.bytesPerPixel == 4);
-			for (int line = _restoreArea->top; line < _restoreArea->bottom; line++) {
-				byte *dst = (byte *)screen->getBasePtr(_restoreArea->left, line + screenOffset);
-				byte *src = (byte *)_bg->getBasePtr(_restoreArea->left, line);
-				byte *prv = (byte *)_prevBuf->getBasePtr((_restoreArea->left - _origX) / _scaleX, (line - _origY) / _scaleY);
-				byte *ovr = (byte *)_overBuf->getBasePtr(_restoreArea->left, line);
-
-				for (int i = 0; i < width; i++) {
-					if (prv[kAIndex] != 0) {
-						copyPixel(dst, src);
-						copyPixelWithA(dst, ovr);
-					}
-					src += _bg->format.bytesPerPixel;
-					dst += _bg->format.bytesPerPixel;
-					prv += _bg->format.bytesPerPixel;
-					ovr += _bg->format.bytesPerPixel;
-				}
-			}
-			_vm->_system->unlockScreen();
-		}
-
-		// Reset _restoreArea for the next frame
-		_restoreArea->top = 0;
-		_restoreArea->left = 0;
-		_restoreArea->bottom = 0;
-		_restoreArea->right = 0;
+		redrawRestoreArea(screenOffset);
 	}
 
 
diff --git a/engines/groovie/video/roq.h b/engines/groovie/video/roq.h
index 11bc050987..46888f9672 100644
--- a/engines/groovie/video/roq.h
+++ b/engines/groovie/video/roq.h
@@ -99,6 +99,7 @@ private:
 	bool _flagMasked; //!< Clear the video instead of play it, used in pente
 
 	// Buffers
+	void redrawRestoreArea(int screenOffset);
 	void buildShowBuf();
 	byte _scaleX, _scaleY;
 	byte _offScale;




More information about the Scummvm-git-logs mailing list