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

wjp wjp at usecode.org
Thu Dec 24 16:18:05 CET 2015


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

Summary:
442c1538a2 LAB: Clean up diff chunk handling
dacbf9881c LAB: Make _dispBitmap handling more explicit


Commit: 442c1538a21e5826b167aed52ec8d95cba65db64
    https://github.com/scummvm/scummvm/commit/442c1538a21e5826b167aed52ec8d95cba65db64
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2015-12-24T16:02:22+01:00

Commit Message:
LAB: Clean up diff chunk handling

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/dispman.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 2127e86..9507e0a 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -40,7 +40,6 @@ namespace Lab {
 
 Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_lastBlockHeader = 0;
-	_curBit = 0;
 	_numChunks = 1;
 	_headerdata._width = 0;
 	_headerdata._height = 0;
@@ -82,17 +81,18 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 	BitMap *disp = _vm->_graphics->_dispBitMap;
 	if (disp->_drawOnScreen)
-		disp->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
+		disp->_buffer = _vm->_graphics->getCurrentDrawingBuffer();
 
-	disp->_planes[1] = disp->_planes[0] + 0x10000;
-	disp->_planes[2] = disp->_planes[1] + 0x10000;
-	disp->_planes[3] = disp->_planes[2] + 0x10000;
-	disp->_planes[4] = disp->_planes[3] + 0x10000;
+	byte *endOfBuf = disp->_buffer + (int)_diffWidth * _diffHeight;
 
 	_vm->_event->mouseHide();
 
+	int curBit = 0;
+
 	while (1) {
-		if (_curBit >= _numChunks) {
+		byte *buf = disp->_buffer + 0x10000 * curBit;
+
+		if (buf >= endOfBuf) {
 			_vm->_event->mouseShow();
 
 			if (!onlyDiffData) {
@@ -123,7 +123,6 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 				_diffFileStart = _diffFile->pos();
 
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
-			_curBit = 0;
 
 			if (disp->_drawOnScreen)
 				_vm->_graphics->screenUpdate();
@@ -146,50 +145,50 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 		case 10:
 			if (onlyDiffData) {
-				if (_curBit > 0)
-					error("diffNextFrame: attempt to read screen to non-zero plane (%d)", _curBit);
+				if (curBit > 0)
+					error("diffNextFrame: attempt to read screen to non-zero plane (%d)", curBit);
 				delete[] _scrollScreenBuffer;
 				_scrollScreenBuffer = new byte[_headerdata._width * _headerdata._height];
 				_diffFile->read(_scrollScreenBuffer, _size);
 			} else {
-				_diffFile->read(disp->_planes[_curBit], _size);
+				_diffFile->read(buf, _size);
 			}
-			_curBit++;
+			curBit++;
 			break;
 
 		case 11:
 			curPos = _diffFile->pos();
 			_diffFile->skip(4);
-			_vm->_utils->runLengthDecode(disp->_planes[_curBit], _diffFile);
-			_curBit++;
+			_vm->_utils->runLengthDecode(buf, _diffFile);
+			curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 12:
 			curPos = _diffFile->pos();
 			_diffFile->skip(4);
-			_vm->_utils->verticalRunLengthDecode(disp->_planes[_curBit], _diffFile, disp->_bytesPerRow);
-			_curBit++;
+			_vm->_utils->verticalRunLengthDecode(buf, _diffFile, disp->_bytesPerRow);
+			curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 20:
 			curPos = _diffFile->pos();
-			_vm->_utils->unDiff(disp->_planes[_curBit], disp->_planes[_curBit], _diffFile, disp->_bytesPerRow, false);
-			_curBit++;
+			_vm->_utils->unDiff(buf, buf, _diffFile, disp->_bytesPerRow, false);
+			curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 21:
 			curPos = _diffFile->pos();
-			_vm->_utils->unDiff(disp->_planes[_curBit], disp->_planes[_curBit], _diffFile, disp->_bytesPerRow, true);
-			_curBit++;
+			_vm->_utils->unDiff(buf, buf, _diffFile, disp->_bytesPerRow, true);
+			curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 25:
 		case 26:
-			_curBit++;
+			curBit++;
 			break;
 
 		case 30:
@@ -264,7 +263,6 @@ void Anim::stopDiffEnd() {
 void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 	_playOnce = playOnce;
 	_delayMicros = 0;
-	_curBit = 0;
 	_frameNum = 0;
 	_numChunks = 1;
 	_donePal = false;
@@ -323,13 +321,6 @@ void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 	_diffHeight = _headerdata._height;
 	_vm->_utils->setBytesPerRow(_diffWidth);
 
-	_numChunks = (((int32)_diffWidth) * _diffHeight) / 0x10000;
-
-	if ((uint32)(_numChunks * 0x10000) < (uint32)(((int32)_diffWidth) * _diffHeight))
-		_numChunks++;
-
-	assert(_numChunks < 16);
-
 	delete[] _scrollScreenBuffer;
 	_scrollScreenBuffer = nullptr;
 
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index db2e23e..de14035 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -46,7 +46,7 @@ struct DIFFHeader {
 struct BitMap {
 	uint16 _bytesPerRow;
 	bool _drawOnScreen;
-	byte *_planes[16];
+	byte *_buffer;
 };
 
 class Anim {
@@ -54,7 +54,6 @@ private:
 	LabEngine *_vm;
 
 	uint32 _lastBlockHeader;
-	uint16 _curBit;
 	uint16 _numChunks;
 	uint32 _delayMicros;
 	bool _continuous;
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 8808675..2f376ac 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -98,7 +98,7 @@ void DisplayMan::readPict(const Common::String filename, bool playOnce, bool onl
 	_dispBitMap->_bytesPerRow  = _screenWidth;
 	_dispBitMap->_drawOnScreen = (memoryBuffer == nullptr);
 	if (memoryBuffer)
-		_dispBitMap->_planes[0] = memoryBuffer;
+		_dispBitMap->_buffer = memoryBuffer;
 
 	_vm->_anim->readDiff(_curBitmap, playOnce, onlyDiffData);
 }


Commit: dacbf9881c72177369e4dde250bc6e9a907f7b00
    https://github.com/scummvm/scummvm/commit/dacbf9881c72177369e4dde250bc6e9a907f7b00
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2015-12-24T16:16:48+01:00

Commit Message:
LAB: Make _dispBitmap handling more explicit

Changed paths:
    engines/lab/anim.cpp
    engines/lab/dispman.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 9507e0a..7f7e488 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -80,17 +80,24 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		return;
 
 	BitMap *disp = _vm->_graphics->_dispBitMap;
-	if (disp->_drawOnScreen)
-		disp->_buffer = _vm->_graphics->getCurrentDrawingBuffer();
-
-	byte *endOfBuf = disp->_buffer + (int)_diffWidth * _diffHeight;
+	bool drawOnScreen = disp->_drawOnScreen;
+	byte *startOfBuf = disp->_buffer;
+	int bufPitch = disp->_bytesPerRow;
+
+	if (drawOnScreen) {
+		startOfBuf = _vm->_graphics->getCurrentDrawingBuffer();
+		bufPitch = _vm->_graphics->_screenWidth;
+	} else {
+		assert(startOfBuf);
+	}
+	byte *endOfBuf = startOfBuf + (int)_diffWidth * _diffHeight;
 
 	_vm->_event->mouseHide();
 
 	int curBit = 0;
 
 	while (1) {
-		byte *buf = disp->_buffer + 0x10000 * curBit;
+		byte *buf = startOfBuf + 0x10000 * curBit;
 
 		if (buf >= endOfBuf) {
 			_vm->_event->mouseShow();
@@ -124,7 +131,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
 
-			if (disp->_drawOnScreen)
+			if (drawOnScreen)
 				_vm->_graphics->screenUpdate();
 
 			// done with the next frame.
@@ -167,21 +174,21 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		case 12:
 			curPos = _diffFile->pos();
 			_diffFile->skip(4);
-			_vm->_utils->verticalRunLengthDecode(buf, _diffFile, disp->_bytesPerRow);
+			_vm->_utils->verticalRunLengthDecode(buf, _diffFile, bufPitch);
 			curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 20:
 			curPos = _diffFile->pos();
-			_vm->_utils->unDiff(buf, buf, _diffFile, disp->_bytesPerRow, false);
+			_vm->_utils->unDiff(buf, buf, _diffFile, bufPitch, false);
 			curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 21:
 			curPos = _diffFile->pos();
-			_vm->_utils->unDiff(buf, buf, _diffFile, disp->_bytesPerRow, true);
+			_vm->_utils->unDiff(buf, buf, _diffFile, bufPitch, true);
 			curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
@@ -218,7 +225,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 						_vm->updateMusicAndEvents();
 						_vm->waitTOF();
 
-						if (disp->_drawOnScreen)
+						if (drawOnScreen)
 							didTOF = true;
 					}
 				}
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 2f376ac..7f581e7 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -97,8 +97,7 @@ void DisplayMan::readPict(const Common::String filename, bool playOnce, bool onl
 
 	_dispBitMap->_bytesPerRow  = _screenWidth;
 	_dispBitMap->_drawOnScreen = (memoryBuffer == nullptr);
-	if (memoryBuffer)
-		_dispBitMap->_buffer = memoryBuffer;
+	_dispBitMap->_buffer       = memoryBuffer;
 
 	_vm->_anim->readDiff(_curBitmap, playOnce, onlyDiffData);
 }






More information about the Scummvm-git-logs mailing list