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

SupSuper noreply at scummvm.org
Fri Jun 14 12:27:16 UTC 2024


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:
aa629b7e30 BAGEL: Add support for Mac resource forks
f012b06812 VIDEO: Return decoded frame when force seeking SmackerDecoder
f36a17a645 BAGEL: Rework frame skipping in CBagCharacterObject


Commit: aa629b7e30e35ccfb235b7f5874428425c2d576d
    https://github.com/scummvm/scummvm/commit/aa629b7e30e35ccfb235b7f5874428425c2d576d
Author: SupSuper (supsuper at gmail.com)
Date: 2024-06-14T13:25:39+01:00

Commit Message:
BAGEL: Add support for Mac resource forks

Changed paths:
    engines/bagel/boflib/file.cpp
    engines/bagel/boflib/file_functions.cpp


diff --git a/engines/bagel/boflib/file.cpp b/engines/bagel/boflib/file.cpp
index 38407b8af4b..1fb398bdeb4 100644
--- a/engines/bagel/boflib/file.cpp
+++ b/engines/bagel/boflib/file.cpp
@@ -19,10 +19,13 @@
  *
  */
 
-#include "common/file.h"
+#include "common/macresman.h"
+#include "common/stream.h"
 #include "common/system.h"
 #include "common/savefile.h"
+#include "bagel/bagel.h"
 #include "bagel/boflib/file.h"
+#include "bagel/boflib/file_functions.h"
 #include "bagel/boflib/debug.h"
 #include "bagel/boflib/log.h"
 
@@ -102,7 +105,7 @@ ErrorCode CBofFile::open(const char *pszFileName, uint32 lFlags) {
 		return _errCode;
 
 	if ((lFlags & CBF_CREATE) && ((lFlags & CBF_SAVEFILE) ||
-			!Common::File::exists(pszFileName))) {
+			!fileExists(pszFileName))) {
 		create(pszFileName, lFlags);
 
 	} else {
@@ -116,16 +119,17 @@ ErrorCode CBofFile::open(const char *pszFileName, uint32 lFlags) {
 				reportError(ERR_FOPEN, "Could not open %s", pszFileName);
 
 		} else {
-			Common::File *f = new Common::File();
-
-			if (f->open(pszFileName)) {
-				_stream = f;
+			if (g_engine->getPlatform() == Common::kPlatformMacintosh) {
+				_stream = Common::MacResManager::openFileOrDataFork(pszFileName);
+			} else {
+				_stream = SearchMan.createReadStreamForMember(pszFileName);
+			}
 
+			if (_stream) {
 				if (g_pDebugOptions != nullptr && g_pDebugOptions->_bShowIO) {
 					logInfo(buildString("Opened file '%s'", _szFileName));
 				}
 			} else {
-				delete f;
 				reportError(ERR_FOPEN, "Could not open %s", pszFileName);
 			}
 		}
diff --git a/engines/bagel/boflib/file_functions.cpp b/engines/bagel/boflib/file_functions.cpp
index bdd44b8873b..947c801d742 100644
--- a/engines/bagel/boflib/file_functions.cpp
+++ b/engines/bagel/boflib/file_functions.cpp
@@ -23,19 +23,36 @@
 #include "common/savefile.h"
 #include "common/file.h"
 #include "common/fs.h"
+#include "common/macresman.h"
 #include "bagel/boflib/file_functions.h"
 #include "bagel/boflib/string.h"
 #include "bagel/baglib/bagel.h"
+#include "bagel/bagel.h"
 
 namespace Bagel {
 
 bool fileExists(const char *pszFileName) {
-	return Common::File::exists(pszFileName);
+	if (g_engine->getPlatform() == Common::kPlatformMacintosh) {
+		return Common::MacResManager::exists(pszFileName);
+	} else {
+		return Common::File::exists(pszFileName);
+	}
 }
 
 int32 fileLength(const char *pszFileName) {
-	Common::File f;
-	return f.open(pszFileName) ? f.size() : -1;
+	Common::SeekableReadStream *stream = nullptr;
+	if (g_engine->getPlatform() == Common::kPlatformMacintosh) {
+		stream = Common::MacResManager::openFileOrDataFork(pszFileName);
+	} else {
+		stream = SearchMan.createReadStreamForMember(pszFileName);
+	}
+
+	int32 length = -1;
+	if (stream) {
+		length = stream->size();
+		delete stream;
+	}
+	return length;
 }
 
 char *fileGetFullPath(char *pszDstBuf, const char *pszSrcBuf) {


Commit: f012b068120dc216fa6d24295df37c38f23a9e57
    https://github.com/scummvm/scummvm/commit/f012b068120dc216fa6d24295df37c38f23a9e57
Author: SupSuper (supsuper at gmail.com)
Date: 2024-06-14T13:25:40+01:00

Commit Message:
VIDEO: Return decoded frame when force seeking SmackerDecoder

Changed paths:
    video/smk_decoder.cpp
    video/smk_decoder.h


diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp
index 058cad61386..6b8b041470b 100644
--- a/video/smk_decoder.cpp
+++ b/video/smk_decoder.cpp
@@ -451,7 +451,7 @@ bool SmackerDecoder::rewind() {
 	return true;
 }
 
-void SmackerDecoder::forceSeekToFrame(uint frame) {
+const Graphics::Surface *SmackerDecoder::forceSeekToFrame(uint frame) {
 	uint seekFrame;
 	if (frame >= 10)
 		seekFrame = MAX<uint>(frame - 10, 0);
@@ -459,13 +459,13 @@ void SmackerDecoder::forceSeekToFrame(uint frame) {
 		seekFrame = 0;
 
 	if (!isVideoLoaded())
-		return;
+		return nullptr;
 
 	if (seekFrame >= getFrameCount())
-		return;
+		return nullptr;
 
 	if (!rewind())
-		return;
+		return nullptr;
 
 	stopAudio();
 	SmackerVideoTrack *videoTrack = (SmackerVideoTrack *)getTrack(0);
@@ -484,10 +484,11 @@ void SmackerDecoder::forceSeekToFrame(uint frame) {
 	}
 
 	if (!_fileStream->seek(startPos + offset, SEEK_SET))
-		return;
+		return nullptr;
 
+	const Graphics::Surface *surface = nullptr;
 	while (getCurFrame() < (int)frame) {
-		decodeNextFrame();
+		surface = decodeNextFrame();
 	}
 
 	_lastTimeChange = videoTrack->getFrameTime(frame);
@@ -495,6 +496,7 @@ void SmackerDecoder::forceSeekToFrame(uint frame) {
 		_startTime = g_system->getMillis() - (_lastTimeChange.msecs() / getRate()).toInt();
 	}
 	resetPauseStartTime();
+	return surface;
 }
 
 void SmackerDecoder::readNextPacket() {
diff --git a/video/smk_decoder.h b/video/smk_decoder.h
index 03daba3b84f..e95b02ba4cd 100644
--- a/video/smk_decoder.h
+++ b/video/smk_decoder.h
@@ -64,6 +64,7 @@ typedef Common::BitStreamImpl<Common::BitStreamMemoryStream, uint32, 8, false, f
  *
  * Video decoder used in engines:
  *  - agos
+ *  - bagel
  *  - saga
  *  - scumm (he)
  *  - sword1
@@ -79,7 +80,7 @@ public:
 
 	virtual bool loadStream(Common::SeekableReadStream *stream);
 	void close();
-	void forceSeekToFrame(uint frame);
+	const Graphics::Surface *forceSeekToFrame(uint frame);
 	bool rewind();
 
 	Common::Rational getFrameRate() const;


Commit: f36a17a6452c84e72ed6c1a553ad174c3a597c71
    https://github.com/scummvm/scummvm/commit/f36a17a6452c84e72ed6c1a553ad174c3a597c71
Author: SupSuper (supsuper at gmail.com)
Date: 2024-06-14T13:25:40+01:00

Commit Message:
BAGEL: Rework frame skipping in CBagCharacterObject

Fixes bugs with jammer, microwave, etc, showing the wrong values

Changed paths:
    engines/bagel/baglib/character_object.cpp
    engines/bagel/baglib/fmovie.cpp


diff --git a/engines/bagel/baglib/character_object.cpp b/engines/bagel/baglib/character_object.cpp
index c11423a34a7..d9899ca23ac 100644
--- a/engines/bagel/baglib/character_object.cpp
+++ b/engines/bagel/baglib/character_object.cpp
@@ -132,7 +132,7 @@ ErrorCode CBagCharacterObject::attach() {
 
 		// If the state is not the default(0) then move to the correct frame
 		if (nState != 0)
-			setFrame(nState + 1);
+			setFrame(nState);
 	}
 
 	if (_numOfLoops != 0) {
@@ -285,14 +285,16 @@ bool CBagCharacterObject::doAdvance() {
 						_smacker->rewind();
 						_smacker->start();
 					}
-				} else if ((_smacker->getCurFrame() == _endFrame) || (_smacker->getCurFrame() == 1)) {
-					if (_numOfLoops > 0)
-						_numOfLoops--; // decrement num of loops
-
-					// Get next frame, will loop to beginning
-					setFrame(_startFrame);
 				} else {
-					setFrame(_smacker->getCurFrame() - 2); // HACK: Reverse playback
+					if (_smacker->getCurFrame() == _endFrame || _smacker->getCurFrame() == 1) {
+						if (_numOfLoops > 0)
+							_numOfLoops--; // decrement num of loops
+
+						// Get next frame, will loop to beginning
+						setFrame(_startFrame);
+					} else {
+						setFrame(_smacker->getCurFrame() - 1); // HACK: Reverse playback
+					}
 				}
 			}
 		} else if (_firstFrame) {
@@ -558,7 +560,12 @@ void CBagCharacterObject::setPlaybackSpeed(int n) {
 
 		_playbackSpeed = n;
 		arrangeFrames();
-		setCurrentFrame(getStartFrame());
+
+		int frame = getStartFrame();
+		if (n < 0 && frame == (int)_smacker->getFrameCount()) {
+			frame--; // HACK: Reverse rewind
+		}
+		setCurrentFrame(frame);
 	}
 }
 
@@ -587,17 +594,22 @@ void CBagCharacterObject::setCurrentFrame(int n) {
 	// a .BIN file, then it would not have worked.
 	updatePosition();
 
-	refreshCurrentFrame();
+	//refreshCurrentFrame();
 }
 
 void CBagCharacterObject::setFrame(int n) {
 	// Make sure that it is within specified values?
 	if (_smacker != nullptr) {
-		if (n == (int)_smacker->getFrameCount()) {
-			n -= 3; // HACK: Reverse rewind
-		}
+		n--;
 		n = CLIP<int>(n, 0, _smacker->getFrameCount() - 1);
-		_smacker->forceSeekToFrame(n);
+		const Graphics::Surface *surf = _smacker->forceSeekToFrame(n);
+		if (surf) {
+			Graphics::ManagedSurface &destSurf = *_bmpBuf;
+
+			// Copy the decoded frame into the offscreen bitmap
+			destSurf.setPalette(_smacker->getPalette(), 0, 256);
+			destSurf.blitFrom(*surf);
+		}
 	}
 }
 
diff --git a/engines/bagel/baglib/fmovie.cpp b/engines/bagel/baglib/fmovie.cpp
index 6aa47d3716d..f17f80effe6 100644
--- a/engines/bagel/baglib/fmovie.cpp
+++ b/engines/bagel/baglib/fmovie.cpp
@@ -201,14 +201,16 @@ void CBagFMovie::onMainLoop() {
 				_smk->start();
 			}
 		}
-	} else if ((_movieStatus == MOVIE_REVERSE) && ((_smk->getCurFrame() == 0) || (_smk->getCurFrame() == 1))) {
-		if (_loopFl == false) {
-			onMovieDone();
+	} else if (_movieStatus == MOVIE_REVERSE) {
+		if (_smk->getCurFrame() == 0 || _smk->getCurFrame() == 1) {
+			if (_loopFl == false) {
+				onMovieDone();
+			} else {
+				seekToEnd();
+			}
 		} else {
-			seekToEnd();
+			setFrame(_smk->getCurFrame() - 2); // HACK: Reverse playback
 		}
-	} else {
-		setFrame(_smk->getCurFrame() - 2); // HACK: Reverse playback
 	}
 }
 




More information about the Scummvm-git-logs mailing list