[Scummvm-cvs-logs] SF.net SVN: scummvm:[47993] scummvm/trunk/engines/drascula

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Mon Feb 8 17:13:31 CET 2010


Revision: 47993
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47993&view=rev
Author:   peres001
Date:     2010-02-08 16:13:31 +0000 (Mon, 08 Feb 2010)

Log Message:
-----------
Reduced references to _arj to the minimum. It is passed as a
SeekableReadStream everywhere.

Modified Paths:
--------------
    scummvm/trunk/engines/drascula/drascula.h
    scummvm/trunk/engines/drascula/graphics.cpp

Modified: scummvm/trunk/engines/drascula/drascula.h
===================================================================
--- scummvm/trunk/engines/drascula/drascula.h	2010-02-08 16:13:09 UTC (rev 47992)
+++ scummvm/trunk/engines/drascula/drascula.h	2010-02-08 16:13:31 UTC (rev 47993)
@@ -541,8 +541,8 @@
 	void mixVideo(byte *OldScreen, byte *NewScreen);
 	void decodeRLE(byte *BufferRLE, byte *MiVideoRLE);
 	void decodeOffset(byte *BufferOFF, byte *MiVideoOFF, int length);
-	byte *TryInMem();
-	int playFrameSSN();
+	byte *TryInMem(Common::SeekableReadStream &stream);
+	int playFrameSSN(Common::SeekableReadStream &stream);
 
 	bool _useMemForArj;
 	byte CHUNK;
@@ -553,7 +553,7 @@
 
 	int flag_tv;
 
-	void showFrame(bool firstFrame = false);
+	void showFrame(Common::SeekableReadStream &stream, bool firstFrame = false);
 	int getTime();
 	void reduce_hare_chico(int, int, int, int, int, int, int, byte *, byte *);
 	void quadrant_1();

Modified: scummvm/trunk/engines/drascula/graphics.cpp
===================================================================
--- scummvm/trunk/engines/drascula/graphics.cpp	2010-02-08 16:13:09 UTC (rev 47992)
+++ scummvm/trunk/engines/drascula/graphics.cpp	2010-02-08 16:13:31 UTC (rev 47993)
@@ -25,7 +25,9 @@
 
 #include "drascula/drascula.h"
 #include "graphics/surface.h"
+#include "common/stream.h"
 
+
 namespace Drascula {
 
 void DrasculaEngine::allocMemory() {
@@ -115,15 +117,15 @@
 	setRGB((byte *)cPal, colorCount);
 }
 
-void DrasculaEngine::showFrame(bool firstFrame) {
-	int dataSize = _arj.readSint32LE();
+void DrasculaEngine::showFrame(Common::SeekableReadStream &stream, bool firstFrame) {
+	int dataSize = stream.readSint32LE();
 	byte *pcxData = (byte *)malloc(dataSize);
-	_arj.read(pcxData, dataSize);
+	stream.read(pcxData, dataSize);
 
 	for (int i = 0; i < 256; i++) {
-		cPal[i * 3 + 0] = _arj.readByte();
-		cPal[i * 3 + 1] = _arj.readByte();
-		cPal[i * 3 + 2] = _arj.readByte();
+		cPal[i * 3 + 0] = stream.readByte();
+		cPal[i * 3 + 1] = stream.readByte();
+		cPal[i * 3 + 2] = stream.readByte();
 	}
 
 	byte *prevFrame = (byte *)malloc(64000);
@@ -476,10 +478,13 @@
 	FrameSSN = 0;
 	_useMemForArj = false;
 	_arj.open(filefli);
-	mSession = TryInMem();
+	// TODO: mSession is treated like a stream from playFrameSSN, so turn it
+	// into a stream, and pass it to playFrameSSN. Get rid of _useMemForArj
+	// as well.
+	mSession = TryInMem(_arj);
 	LastFrame = _system->getMillis();
 
-	while (playFrameSSN() && (!term_int)) {
+	while (playFrameSSN(_arj) && (!term_int)) {
 		if (getScan() == Common::KEYCODE_ESCAPE)
 			term_int = 1;
 	}
@@ -490,13 +495,13 @@
 	_arj.close();
 }
 
-int DrasculaEngine::playFrameSSN() {
+int DrasculaEngine::playFrameSSN(Common::SeekableReadStream &stream) {
 	int Exit = 0;
 	uint32 length;
 	byte *BufferSSN;
 
 	if (!_useMemForArj)
-		CHUNK = _arj.readByte();
+		CHUNK = stream.readByte();
 	else {
 		memcpy(&CHUNK, mSession, 1);
 		mSession += 1;
@@ -506,9 +511,9 @@
 	case kFrameSetPal:
 		if (!_useMemForArj) {
 			for (int i = 0; i < 256; i++) {
-				dacSSN[i * 3 + 0] = _arj.readByte();
-				dacSSN[i * 3 + 1] = _arj.readByte();
-				dacSSN[i * 3 + 2] = _arj.readByte();
+				dacSSN[i * 3 + 0] = stream.readByte();
+				dacSSN[i * 3 + 1] = stream.readByte();
+				dacSSN[i * 3 + 2] = stream.readByte();
 			}
 		} else {
 			memcpy(dacSSN, mSession, 768);
@@ -521,8 +526,8 @@
 		break;
 	case kFrameInit:
 		if (!_useMemForArj) {
-			CMP = _arj.readByte();
-			length = _arj.readUint32LE();
+			CMP = stream.readByte();
+			length = stream.readUint32LE();
 		} else {
 			memcpy(&CMP, mSession, 1);
 			mSession += 1;
@@ -532,7 +537,7 @@
 		if (CMP == kFrameCmpRle) {
 			BufferSSN = (byte *)malloc(length);
 			if (!_useMemForArj) {
-				_arj.read(BufferSSN, length);
+				stream.read(BufferSSN, length);
 			} else {
 				memcpy(BufferSSN, mSession, length);
 				mSession += length;
@@ -554,7 +559,7 @@
 			if (CMP == kFrameCmpOff) {
 				BufferSSN = (byte *)malloc(length);
 				if (!_useMemForArj) {
-					_arj.read(BufferSSN, length);
+					stream.read(BufferSSN, length);
 				} else {
 					memcpy(BufferSSN, mSession, length);
 					mSession += length;
@@ -585,16 +590,16 @@
 	return (!Exit);
 }
 
-byte *DrasculaEngine::TryInMem() {
+byte *DrasculaEngine::TryInMem(Common::SeekableReadStream &stream) {
 	int length;
 
-	_arj.seek(0, SEEK_END);
-	length = _arj.pos();
-	_arj.seek(0, SEEK_SET);
+	stream.seek(0, SEEK_END);
+	length = stream.pos();
+	stream.seek(0, SEEK_SET);
 	memPtr = (byte *)malloc(length);
 	if (memPtr == NULL)
 		return NULL;
-	_arj.read(memPtr, length);
+	stream.read(memPtr, length);
 	_useMemForArj = true;
 
 	return memPtr;
@@ -662,10 +667,10 @@
 	}
 
 	NFrames = _arj.readSint32LE();
-	showFrame(true);
+	showFrame(_arj, true);
 	_system->delayMillis(1000 / FPS);
 	while (cnt < NFrames) {
-		showFrame();
+		showFrame(_arj);
 		_system->delayMillis(1000 / FPS);
 		cnt++;
 		byte key = getScan();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list