[Scummvm-cvs-logs] SF.net SVN: scummvm:[34518] scummvm/trunk/engines/scumm

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Sep 14 00:41:31 CEST 2008


Revision: 34518
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34518&view=rev
Author:   fingolfin
Date:     2008-09-13 22:41:30 +0000 (Sat, 13 Sep 2008)

Log Message:
-----------
SCUMM: Got rid of class Chunk

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/insane/insane.cpp
    scummvm/trunk/engines/scumm/insane/insane.h
    scummvm/trunk/engines/scumm/insane/insane_iact.cpp
    scummvm/trunk/engines/scumm/module.mk
    scummvm/trunk/engines/scumm/smush/channel.h
    scummvm/trunk/engines/scumm/smush/imuse_channel.cpp
    scummvm/trunk/engines/scumm/smush/saud_channel.cpp
    scummvm/trunk/engines/scumm/smush/smush_player.cpp
    scummvm/trunk/engines/scumm/smush/smush_player.h

Removed Paths:
-------------
    scummvm/trunk/engines/scumm/smush/chunk.cpp
    scummvm/trunk/engines/scumm/smush/chunk.h

Modified: scummvm/trunk/engines/scumm/insane/insane.cpp
===================================================================
--- scummvm/trunk/engines/scumm/insane/insane.cpp	2008-09-13 20:22:52 UTC (rev 34517)
+++ scummvm/trunk/engines/scumm/insane/insane.cpp	2008-09-13 22:41:30 UTC (rev 34518)
@@ -39,7 +39,6 @@
 
 #include "scumm/smush/smush_player.h"
 #include "scumm/smush/smush_font.h"
-#include "scumm/smush/chunk.h"
 
 #include "scumm/insane/insane.h"
 
@@ -1310,33 +1309,25 @@
 	free (string);
 }
 
-void Insane::procSKIP(Chunk &b) {
+void Insane::procSKIP(int32 subSize, Common::SeekableReadStream &b) {
 	int16 par1, par2;
 	_player->_skipNext = false;
 
 	if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformPC)) {
-		_player->checkBlock(b, MKID_BE('SKIP'), 2);
+		assert(subSize >= 2);
 		par1 = b.readUint16LE();
-		if (isBitSet(par1))
-			_player->_skipNext = true;
-		return;
+		par2 = 0;
+	} else {
+		assert(subSize >= 4);
+		par1 = b.readUint16LE();
+		par2 = b.readUint16LE();
 	}
 
-	_player->checkBlock(b, MKID_BE('SKIP'), 4);
-
-	par1 = b.readUint16LE();
-	par2 = b.readUint16LE();
-
-
 	if (!par2) {
 		if (isBitSet(par1))
 			_player->_skipNext = true;
-		return;
-	}
-
-	if (isBitSet(par1) != isBitSet(par2)) {
+	} else if (isBitSet(par1) != isBitSet(par2)) {
 		_player->_skipNext = true;
-		return;
 	}
 }
 

Modified: scummvm/trunk/engines/scumm/insane/insane.h
===================================================================
--- scummvm/trunk/engines/scumm/insane/insane.h	2008-09-13 20:22:52 UTC (rev 34517)
+++ scummvm/trunk/engines/scumm/insane/insane.h	2008-09-13 22:41:30 UTC (rev 34518)
@@ -31,7 +31,6 @@
 #include "scumm/nut_renderer.h"
 
 #include "scumm/smush/smush_player.h"
-#include "scumm/smush/chunk.h"
 
 namespace Scumm {
 
@@ -67,9 +66,9 @@
 	void procPostRendering(byte *renderBitmap, int32 codecparam, int32 setupsan12,
 						   int32 setupsan13, int32 curFrame, int32 maxFrame);
 	void procIACT(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-				  int32 setupsan13, Chunk &b, int32 size, int32 flags, int16 par1,
+				  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags, int16 par1,
 				  int16 par2, int16 par3, int16 par4);
-	void procSKIP(Chunk &b);
+	void procSKIP(int32 subSize, Common::SeekableReadStream &b);
 	void escapeKeyHandler(void);
 
  private:
@@ -434,22 +433,22 @@
 	void ouchSoundEnemy(void);
 	bool weaponEnemyIsEffective(void);
 	void iactScene1(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-				  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+				  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 				  int16 par1, int16 par2, int16 par3, int16 par4);
 	void iactScene3(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-				  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+				  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 				  int16 command, int16 par1, int16, int16);
 	void iactScene4(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-				  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+				  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 				  int16 par1, int16 par2, int16 par3, int16 par4);
 	void iactScene6(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-				  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+				  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 				  int16 par1, int16 par2, int16 par3, int16 par4);
 	void iactScene17(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-				  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+				  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 				  int16 par1, int16 par2, int16 par3, int16 par4);
 	void iactScene21(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-				  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+				  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 				  int16 par1, int16 par2, int16 par3, int16 par4);
 	bool isBitSet(int n);
 	void setBit(int n);

Modified: scummvm/trunk/engines/scumm/insane/insane_iact.cpp
===================================================================
--- scummvm/trunk/engines/scumm/insane/insane_iact.cpp	2008-09-13 20:22:52 UTC (rev 34517)
+++ scummvm/trunk/engines/scumm/insane/insane_iact.cpp	2008-09-13 22:41:30 UTC (rev 34518)
@@ -30,14 +30,13 @@
 #include "scumm/scumm.h"
 
 #include "scumm/smush/smush_player.h"
-#include "scumm/smush/chunk.h"
 
 #include "scumm/insane/insane.h"
 
 namespace Scumm {
 
 void Insane::procIACT(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-					  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+					  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 					  int16 par1, int16 par2, int16 par3, int16 par4) {
 	if (_keyboardDisable)
 		return;
@@ -67,7 +66,7 @@
 }
 
 void Insane::iactScene1(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-					  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+					  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 					  int16 par1, int16 par2, int16 par3, int16 par4) {
 	int16 par5, par6, par7, par9, par11, par13, tmp;
 
@@ -294,7 +293,7 @@
 }
 
 void Insane::iactScene3(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-					  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+					  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 					  int16 command, int16 par1, int16, int16) {
 	int par2, par3;
 	if (command == 6) {
@@ -317,7 +316,7 @@
 }
 
 void Insane::iactScene4(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-					  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+					  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 					  int16 par1, int16 par2, int16 par3, int16 par4) {
 	int16 par5;
 
@@ -393,7 +392,7 @@
 }
 
 void Insane::iactScene6(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-					  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+					  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 					  int16 par1, int16 par2, int16 par3, int16 par4) {
 	int16 par5;
 
@@ -478,7 +477,7 @@
 }
 
 void Insane::iactScene17(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-					  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+					  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 					  int16 par1, int16 par2, int16 par3, int16 par4) {
 	switch (par1) {
 	case 2:
@@ -524,7 +523,7 @@
 }
 
 void Insane::iactScene21(byte *renderBitmap, int32 codecparam, int32 setupsan12,
-					  int32 setupsan13, Chunk &b, int32 size, int32 flags,
+					  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
 					  int16 par1, int16 par2, int16 par3, int16 par4) {
 	// void implementation
 }

Modified: scummvm/trunk/engines/scumm/module.mk
===================================================================
--- scummvm/trunk/engines/scumm/module.mk	2008-09-13 20:22:52 UTC (rev 34517)
+++ scummvm/trunk/engines/scumm/module.mk	2008-09-13 22:41:30 UTC (rev 34518)
@@ -81,7 +81,6 @@
 	insane/insane_scenes.o \
 	insane/insane_iact.o \
 	smush/channel.o \
-	smush/chunk.o \
 	smush/codec1.o \
 	smush/codec37.o \
 	smush/codec47.o \

Modified: scummvm/trunk/engines/scumm/smush/channel.h
===================================================================
--- scummvm/trunk/engines/scumm/smush/channel.h	2008-09-13 20:22:52 UTC (rev 34517)
+++ scummvm/trunk/engines/scumm/smush/channel.h	2008-09-13 22:41:30 UTC (rev 34518)
@@ -28,11 +28,12 @@
 
 #include "common/util.h"
 
+namespace Common {
+	class SeekableReadStream;
+}
+
 namespace Scumm {
 
-class Chunk;
-class ContChunk;
-
 class SmushChannel {
 protected:
 	int32 _track;				//!< the track number
@@ -55,7 +56,7 @@
 public:
 	SmushChannel(int32 track);
 	virtual ~SmushChannel();
-	virtual bool appendData(Chunk &b, int32 size) = 0;
+	virtual bool appendData(Common::SeekableReadStream &b, int32 size) = 0;
 	virtual bool setParameters(int32, int32, int32, int32, int32) = 0;
 	virtual bool checkParameters(int32, int32, int32, int32, int32) = 0;
 	virtual bool isTerminated() const = 0;
@@ -83,7 +84,7 @@
 	bool isTerminated() const;
 	bool setParameters(int32 duration, int32 flags, int32 vol1, int32 vol2, int32 index);
 	bool checkParameters(int32 index, int32 duration, int32 flags, int32 vol1, int32 vol2);
-	bool appendData(Chunk &b, int32 size);
+	bool appendData(Common::SeekableReadStream &b, int32 size);
 	byte *getSoundData();
 	int32 getRate() { return 22050; }
 	bool getParameters(bool &stereo, bool &is_16bit, int32 &vol, int32 &pan) {
@@ -113,7 +114,7 @@
 	bool isTerminated() const;
 	bool setParameters(int32 nbframes, int32 size, int32 track_flags, int32 unk1, int32);
 	bool checkParameters(int32 index, int32 nbframes, int32 size, int32 track_flags, int32 unk1);
-	bool appendData(Chunk &b, int32 size);
+	bool appendData(Common::SeekableReadStream &b, int32 size);
 	byte *getSoundData();
 	int32 getRate() { return _rate; }
 	bool getParameters(bool &stereo, bool &is_16bit, int32 &vol, int32 &pan) {

Deleted: scummvm/trunk/engines/scumm/smush/chunk.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/chunk.cpp	2008-09-13 20:22:52 UTC (rev 34517)
+++ scummvm/trunk/engines/scumm/smush/chunk.cpp	2008-09-13 22:41:30 UTC (rev 34518)
@@ -1,121 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-
-#include "scumm/smush/chunk.h"
-#include "scumm/scumm.h"
-#include "scumm/file.h"
-
-#include "common/file.h"
-#include "common/str.h"
-#include "common/util.h"
-
-namespace Scumm {
-
-bool Chunk::seek(int32 delta, int dir) {
-	switch (dir) {
-	case SEEK_CUR:
-		_curPos += delta;
-		break;
-	case SEEK_SET:
-		if (delta < 0)
-			error("invalid seek request");
-		_curPos = (uint32)delta;
-		break;
-	case SEEK_END:
-		if (delta > 0 || _size < (uint32)-delta)
-			error("invalid seek request");
-		_curPos = (uint32)(_size + delta);
-		break;
-	default:
-		break;
-	}
-
-	if (_curPos > _size) {
-		// It may happen that user misused our SAN compression tool
-		// and ignored FLU index for videos which are used by INSANE.
-		// This will lead to incorrect seek requests
-		//
-		// In fact it may happen only within INSANE, so do not even check for it
-		warning("Looks like you compressed file %s in wrong way. It has FLU index which was not updated", _name.c_str());
-		error("invalid seek request : %d > %d (delta == %d)", _curPos, _size, delta);
-	}
-	
-	return true;
-}
-
-Chunk::Chunk(BaseScummFile *data, int offset)
- : _type(0), _size(0), _curPos(0) {
-	_data = data;
-	_deleteData = false;
-
-	_data->seek(offset, SEEK_SET);
-	_type = _data->readUint32BE();
-	_size = _data->readUint32BE();
-	_offset = _data->pos();
-	_curPos = 0;
-}
-
-Chunk::Chunk(const Common::String &name, int offset)
- : _type(0), _size(0), _curPos(0) {
-	_data = new ScummFile();
-	_deleteData = true;
-	if (!g_scumm->openFile(*_data, name))
-		error("Chunk: Unable to open file %s", name.c_str());
-
-	_data->seek(offset, SEEK_SET);
-	_type = _data->readUint32BE();
-	_size = _data->readUint32BE();
-	_offset = _data->pos();
-	_curPos = 0;
-	_name = name;
-}
-
-Chunk::~Chunk() {
-	if (_deleteData)
-		delete _data;
-}
-
-Chunk *Chunk::subBlock() {
-	Chunk *ptr = new Chunk(_data, _offset + _curPos);
-	skip(sizeof(Chunk::type) + sizeof(uint32) + ptr->size());
-	return ptr;
-}
-
-void Chunk::reseek() {
-	_data->seek(_offset + _curPos, SEEK_SET);
-}
-
-uint32 Chunk::read(void *buffer, uint32 dataSize) {
-	if (dataSize <= 0 || (_curPos + dataSize) > _size)
-		error("invalid buffer read request");
-
-	dataSize = _data->read(buffer, dataSize);
-	_curPos += dataSize;
-
-	return dataSize;
-}
-
-} // End of namespace Scumm

Deleted: scummvm/trunk/engines/scumm/smush/chunk.h
===================================================================
--- scummvm/trunk/engines/scumm/smush/chunk.h	2008-09-13 20:22:52 UTC (rev 34517)
+++ scummvm/trunk/engines/scumm/smush/chunk.h	2008-09-13 22:41:30 UTC (rev 34518)
@@ -1,70 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef SCUMM_SMUSH_CHUNK_H
-#define SCUMM_SMUSH_CHUNK_H
-
-#include "common/scummsys.h"
-#include "common/str.h"
-#include "common/stream.h"
-
-namespace Scumm {
-
-class BaseScummFile;
-
-class Chunk : public Common::SeekableReadStream {
-public:
-	typedef uint32 type;
-
-protected:
-	Chunk::type _type;
-	uint32 _size;
-	uint32 _curPos;
-	Common::String _name;
-
-	BaseScummFile *_data;
-	bool _deleteData;
-	uint32 _offset;
-
-	Chunk(BaseScummFile *data, int offset);
-
-public:
-	Chunk(const Common::String &name, int offset = 0);
-	virtual ~Chunk();
-
-	Chunk::type getType() const { return _type; }
-	Chunk *subBlock();
-	void reseek();
-
-	int32 size() const { return _size; }
-	bool eos() const { return _curPos >= _size; }
-	int32 pos() const { return _curPos; }
-	bool seek(int32 delta, int dir);
-	uint32 read(void *buffer, uint32 size);
-};
-
-} // End of namespace Scumm
-
-#endif

Modified: scummvm/trunk/engines/scumm/smush/imuse_channel.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/imuse_channel.cpp	2008-09-13 20:22:52 UTC (rev 34517)
+++ scummvm/trunk/engines/scumm/smush/imuse_channel.cpp	2008-09-13 22:41:30 UTC (rev 34518)
@@ -29,7 +29,6 @@
 #include "scumm/scumm.h"	// For DEBUG_SMUSH
 #include "scumm/util.h"
 #include "scumm/smush/channel.h"
-#include "scumm/smush/chunk.h"
 
 namespace Scumm {
 
@@ -60,10 +59,10 @@
 	return true;
 }
 
-bool ImuseChannel::appendData(Chunk &b, int32 size) {
+bool ImuseChannel::appendData(Common::SeekableReadStream &b, int32 size) {
 	if (_dataSize == -1) {
 		assert(size > 8);
-		Chunk::type imus_type = b.readUint32BE();
+		uint32 imus_type = b.readUint32BE();
 		/*uint32 imus_size =*/ b.readUint32BE();
 		if (imus_type != MKID_BE('iMUS'))
 			error("Invalid Chunk for imuse_channel");
@@ -197,7 +196,7 @@
 
 bool ImuseChannel::handleSubTags(int32 &offset) {
 	if (_tbufferSize - offset >= 8) {
-		Chunk::type type = READ_BE_UINT32(_tbuffer + offset);
+		uint32 type = READ_BE_UINT32(_tbuffer + offset);
 		uint32 size = READ_BE_UINT32(_tbuffer + offset + 4);
 		uint32 available_size = _tbufferSize - offset;
 		switch (type) {

Modified: scummvm/trunk/engines/scumm/smush/saud_channel.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/saud_channel.cpp	2008-09-13 20:22:52 UTC (rev 34517)
+++ scummvm/trunk/engines/scumm/smush/saud_channel.cpp	2008-09-13 22:41:30 UTC (rev 34518)
@@ -25,10 +25,10 @@
 
 
 #include "common/endian.h"
+#include "common/stream.h"
 
 #include "scumm/util.h"
 #include "scumm/smush/channel.h"
-#include "scumm/smush/chunk.h"
 
 namespace Scumm {
 
@@ -45,7 +45,7 @@
 
 bool SaudChannel::handleSubTags(int32 &offset) {
 	if (_tbufferSize - offset >= 8) {
-		Chunk::type type = READ_BE_UINT32(_tbuffer + offset);
+		uint32 type = READ_BE_UINT32(_tbuffer + offset);
 		uint32 size = READ_BE_UINT32(_tbuffer + offset + 4);
 		uint32 available_size = _tbufferSize - offset;
 
@@ -121,10 +121,10 @@
 	return true;
 }
 
-bool SaudChannel::appendData(Chunk &b, int32 size) {
+bool SaudChannel::appendData(Common::SeekableReadStream &b, int32 size) {
 	if (_dataSize == -1) {
 		assert(size > 8);
-		Chunk::type saud_type = b.readUint32BE();
+		uint32 saud_type = b.readUint32BE();
 		/*uint32 saud_size =*/ b.readUint32BE();
 		if (saud_type != MKID_BE('SAUD'))
 			error("Invalid Chunk for SaudChannel : %X", saud_type);

Modified: scummvm/trunk/engines/scumm/smush/smush_player.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_player.cpp	2008-09-13 20:22:52 UTC (rev 34517)
+++ scummvm/trunk/engines/scumm/smush/smush_player.cpp	2008-09-13 22:41:30 UTC (rev 34518)
@@ -23,8 +23,6 @@
  *
  */
 
-
-
 #include "engines/engine.h"
 
 #include "common/config-manager.h"
@@ -42,7 +40,6 @@
 #include "scumm/sound.h"
 #include "scumm/util.h"
 #include "scumm/smush/channel.h"
-#include "scumm/smush/chunk.h"
 #include "scumm/smush/codec37.h"
 #include "scumm/smush/codec47.h"
 #include "scumm/smush/smush_font.h"
@@ -315,16 +312,7 @@
 	_codec47 = 0;
 }
 
-void SmushPlayer::checkBlock(const Chunk &b, Chunk::type type_expected, int32 min_size) {
-	if (type_expected != b.getType()) {
-		error("Chunk type is different from expected : %x != %x", b.getType(), type_expected);
-	}
-	if (min_size > b.size()) {
-		error("Chunk size is inferior than minimum required size : %d < %d", b.size(), min_size);
-	}
-}
-
-void SmushPlayer::handleSoundBuffer(int32 track_id, int32 index, int32 max_frames, int32 flags, int32 vol, int32 pan, Chunk &b, int32 size) {
+void SmushPlayer::handleSoundBuffer(int32 track_id, int32 index, int32 max_frames, int32 flags, int32 vol, int32 pan, Common::SeekableReadStream &b, int32 size) {
 	debugC(DEBUG_SMUSH, "SmushPlayer::handleSoundBuffer(%d, %d)", track_id, index);
 //	if ((flags & 128) == 128) {
 //		return;
@@ -347,8 +335,7 @@
 	c->appendData(b, size);
 }
 
-void SmushPlayer::handleSoundFrame(Chunk &b) {
-	checkBlock(b, MKID_BE('PSAD'));
+void SmushPlayer::handleSoundFrame(int32 subSize, Common::SeekableReadStream &b) {
 	debugC(DEBUG_SMUSH, "SmushPlayer::handleSoundFrame()");
 
 	int32 track_id = b.readUint16LE();
@@ -360,28 +347,28 @@
 	if (index == 0) {
 		debugC(DEBUG_SMUSH, "track_id:%d, max_frames:%d, flags:%d, vol:%d, pan:%d", track_id, max_frames, flags, vol, pan);
 	}
-	int32 size = b.size() - 10;
+	int32 size = subSize - 10;
 	handleSoundBuffer(track_id, index, max_frames, flags, vol, pan, b, size);
 }
 
-void SmushPlayer::handleStore(Chunk &b) {
+void SmushPlayer::handleStore(int32 subSize, Common::SeekableReadStream &b) {
 	debugC(DEBUG_SMUSH, "SmushPlayer::handleStore()");
-	checkBlock(b, MKID_BE('STOR'), 4);
+	assert(subSize >= 4);
 	_storeFrame = true;
 }
 
-void SmushPlayer::handleFetch(Chunk &b) {
+void SmushPlayer::handleFetch(int32 subSize, Common::SeekableReadStream &b) {
 	debugC(DEBUG_SMUSH, "SmushPlayer::handleFetch()");
-	checkBlock(b, MKID_BE('FTCH'), 6);
+	assert(subSize >= 6);
 
 	if (_frameBuffer != NULL) {
 		memcpy(_dst, _frameBuffer, _width * _height);
 	}
 }
 
-void SmushPlayer::handleIACT(Chunk &b) {
-	checkBlock(b, MKID_BE('IACT'), 8);
+void SmushPlayer::handleIACT(int32 subSize, Common::SeekableReadStream &b) {
 	debugC(DEBUG_SMUSH, "SmushPlayer::IACT()");
+	assert(subSize >= 8);
 
 	int code = b.readUint16LE();
 	int flags = b.readUint16LE();
@@ -402,7 +389,7 @@
 	int index = b.readUint16LE();
 	int nbframes = b.readUint16LE();
 	int32 size = b.readUint32LE();
-	int32 bsize = b.size() - 18;
+	int32 bsize = subSize - 18;
 
 	if (_vm->_game.id != GID_CMI) {
 		int32 track = track_id;
@@ -506,7 +493,7 @@
 	}
 }
 
-void SmushPlayer::handleTextResource(Chunk &b) {
+void SmushPlayer::handleTextResource(uint32 subType, int32 subSize, Common::SeekableReadStream &b) {
 	int pos_x = b.readSint16LE();
 	int pos_y = b.readSint16LE();
 	int flags = b.readSint16LE();
@@ -518,10 +505,10 @@
 
 	const char *str;
 	char *string = NULL, *string2 = NULL;
-	if (b.getType() == MKID_BE('TEXT')) {
-		string = (char *)malloc(b.size() - 16);
+	if (subType == MKID_BE('TEXT')) {
+		string = (char *)malloc(subSize - 16);
 		str = string;
-		b.read(string, b.size() - 16);
+		b.read(string, subSize - 16);
 	} else {
 		int string_id = b.readUint16LE();
 		if (!_strings)
@@ -689,7 +676,7 @@
 	return false;
 }
 
-void SmushPlayer::readPalette(byte *out, Chunk &in) {
+void SmushPlayer::readPalette(byte *out, Common::SeekableReadStream &in) {
 	in.read(out, 0x300);
 }
 
@@ -698,11 +685,10 @@
 	return CLIP(t, 0, 255);
 }
 
-void SmushPlayer::handleDeltaPalette(Chunk &b) {
-	checkBlock(b, MKID_BE('XPAL'));
+void SmushPlayer::handleDeltaPalette(int32 subSize, Common::SeekableReadStream &b) {
 	debugC(DEBUG_SMUSH, "SmushPlayer::handleDeltaPalette()");
 
-	if (b.size() == 0x300 * 3 + 4) {
+	if (subSize == 0x300 * 3 + 4) {
 
 		b.readUint16LE();
 		b.readUint16LE();
@@ -712,7 +698,7 @@
 		}
 		readPalette(_pal, b);
 		setDirtyColors(0, 255);
-	} else if (b.size() == 6) {
+	} else if (subSize == 6) {
 
 		b.readUint16LE();
 		b.readUint16LE();
@@ -727,9 +713,9 @@
 	}
 }
 
-void SmushPlayer::handleNewPalette(Chunk &b) {
-	checkBlock(b, MKID_BE('NPAL'), 0x300);
+void SmushPlayer::handleNewPalette(int32 subSize, Common::SeekableReadStream &b) {
 	debugC(DEBUG_SMUSH, "SmushPlayer::handleNewPalette()");
+	assert(subSize >= 0x300);
 
 	if (_skipPalette)
 		return;
@@ -792,13 +778,13 @@
 }
 
 #ifdef USE_ZLIB
-void SmushPlayer::handleZlibFrameObject(Chunk &b) {
+void SmushPlayer::handleZlibFrameObject(int32 subSize, Common::SeekableReadStream &b) {
 	if (_skipNext) {
 		_skipNext = false;
 		return;
 	}
 
-	int32 chunkSize = b.size();
+	int32 chunkSize = subSize;
 	byte *chunkBuffer = (byte *)malloc(chunkSize);
 	assert(chunkBuffer);
 	b.read(chunkBuffer, chunkSize);
@@ -823,8 +809,8 @@
 }
 #endif
 
-void SmushPlayer::handleFrameObject(Chunk &b) {
-	checkBlock(b, MKID_BE('FOBJ'), 14);
+void SmushPlayer::handleFrameObject(int32 subSize, Common::SeekableReadStream &b) {
+	assert(subSize >= 14);
 	if (_skipNext) {
 		_skipNext = false;
 		return;
@@ -839,7 +825,7 @@
 	b.readUint16LE();
 	b.readUint16LE();
 
-	int32 chunk_size = b.size() - 14;
+	int32 chunk_size = subSize - 14;
 	byte *chunk_buffer = (byte *)malloc(chunk_size);
 	assert(chunk_buffer);
 	b.read(chunk_buffer, chunk_size);
@@ -849,8 +835,7 @@
 	free(chunk_buffer);
 }
 
-void SmushPlayer::handleFrame(Chunk &b) {
-	checkBlock(b, MKID_BE('FRME'));
+void SmushPlayer::handleFrame(int32 frameSize, Common::SeekableReadStream &b) {
 	debugC(DEBUG_SMUSH, "SmushPlayer::handleFrame(%d)", _frame);
 	_skipNext = false;
 
@@ -858,54 +843,57 @@
 		_vm->_insane->procPreRendering();
 	}
 
-	while (!b.eos()) {
-		Chunk *sub = b.subBlock();
-		switch (sub->getType()) {
+	while (frameSize > 0) {
+		const uint32 subType = b.readUint32BE();
+		const int32 subSize = b.readUint32BE();
+		const int32 subOffset = b.pos();
+		switch (subType) {
 		case MKID_BE('NPAL'):
-			handleNewPalette(*sub);
+			handleNewPalette(subSize, b);
 			break;
 		case MKID_BE('FOBJ'):
-			handleFrameObject(*sub);
+			handleFrameObject(subSize, b);
 			break;
 #ifdef USE_ZLIB
 		case MKID_BE('ZFOB'):
-			handleZlibFrameObject(*sub);
+			handleZlibFrameObject(subSize, b);
 			break;
 #endif
 		case MKID_BE('PSAD'):
 			if (!_compressedFileMode)
-				handleSoundFrame(*sub);
+				handleSoundFrame(subSize, b);
 			break;
 		case MKID_BE('TRES'):
-			handleTextResource(*sub);
+			handleTextResource(subType, subSize, b);
 			break;
 		case MKID_BE('XPAL'):
-			handleDeltaPalette(*sub);
+			handleDeltaPalette(subSize, b);
 			break;
 		case MKID_BE('IACT'):
-			handleIACT(*sub);
+			handleIACT(subSize, b);
 			break;
 		case MKID_BE('STOR'):
-			handleStore(*sub);
+			handleStore(subSize, b);
 			break;
 		case MKID_BE('FTCH'):
-			handleFetch(*sub);
+			handleFetch(subSize, b);
 			break;
 		case MKID_BE('SKIP'):
-			_vm->_insane->procSKIP(*sub);
+			_vm->_insane->procSKIP(subSize, b);
 			break;
 		case MKID_BE('TEXT'):
-			handleTextResource(*sub);
+			handleTextResource(subType, subSize, b);
 			break;
 		default:
-			error("Unknown frame subChunk found : %s, %d", tag2str(sub->getType()), sub->size());
+			error("Unknown frame subChunk found : %s, %d", tag2str(subType), subSize);
 		}
 
-		b.reseek();
-		if (sub->size() & 1)
+		frameSize -= subSize + 8;
+		b.seek(subOffset + subSize, SEEK_SET);
+		if (subSize & 1) {
 			b.skip(1);
-
-		delete sub;
+			frameSize--;
+		}
 	}
 
 	if (_insanity) {
@@ -920,9 +908,9 @@
 	_frame++;
 }
 
-void SmushPlayer::handleAnimHeader(Chunk &b) {
-	checkBlock(b, MKID_BE('AHDR'), 0x300 + 6);
+void SmushPlayer::handleAnimHeader(int32 subSize, Common::SeekableReadStream &b) {
 	debugC(DEBUG_SMUSH, "SmushPlayer::handleAnimHeader()");
+	assert(subSize >= 0x300 + 6);
 
 	/* _version = */ b.readUint16LE();
 	_nbframes = b.readUint16LE();
@@ -984,7 +972,6 @@
 }
 
 void SmushPlayer::parseNextFrame() {
-	Chunk *sub;
 
 	if (_seekPos >= 0) {
 		if (_smixer)
@@ -992,15 +979,23 @@
 
 		if (_seekFile.size() > 0) {
 			delete _base;
-			_base = new Chunk(_seekFile);
 
+			ScummFile *tmp = new ScummFile();
+			if (!g_scumm->openFile(*tmp, _seekFile))
+				error("SmushPlayer: Unable to open file %s", _seekFile.c_str());
+			_base = tmp;
+			_base->readUint32BE();
+			_base->readUint32BE();
+
 			if (_seekPos > 0) {
 				assert(_seekPos > 8);
 				// In this case we need to get palette and number of frames
-				sub = _base->subBlock();
-				checkBlock(*sub, MKID_BE('AHDR'));
-				handleAnimHeader(*sub);
-				delete sub;
+				const uint32 subType = _base->readUint32BE();
+				const int32 subSize = _base->readUint32BE();
+				const int32 subOffset = _base->pos();
+				assert(subType == MKID_BE('AHDR'));
+				handleAnimHeader(subSize, *_base);
+				_base->seek(subOffset + subSize, SEEK_SET);
 
 				_middleAudio = true;
 				_seekPos -= 8;
@@ -1014,7 +1009,7 @@
 			_skipPalette = true;
 		}
 
-		_base->seek(_seekPos, SEEK_SET);
+		_base->seek(_seekPos + 8, SEEK_SET);
 		_frame = _seekFrame;
 		_startFrame = _frame;
 		_startTime = _vm->_system->getMillis();
@@ -1029,21 +1024,22 @@
 		return;
 	}
 
-	sub = _base->subBlock();
+	const uint32 subType = _base->readUint32BE();
+	const int32 subSize = _base->readUint32BE();
+	const int32 subOffset = _base->pos();
 
-	switch (sub->getType()) {
+	switch (subType) {
 	case MKID_BE('AHDR'): // FT INSANE may seek file to the beginning
-		handleAnimHeader(*sub);
+		handleAnimHeader(subSize, *_base);
 		break;
 	case MKID_BE('FRME'):
-		handleFrame(*sub);
+		handleFrame(subSize, *_base);
 		break;
 	default:
-		error("Unknown Chunk found at %x: %x, %d", _base->pos(), sub->getType(), sub->size());
+		error("Unknown Chunk found at %x: %x, %d", subOffset, subType, subSize);
 	}
-	delete sub;
 
-	_base->reseek();
+	_base->seek(subOffset + subSize, SEEK_SET);
 
 	if (_insanity)
 		_vm->_sound->processSound();

Modified: scummvm/trunk/engines/scumm/smush/smush_player.h
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_player.h	2008-09-13 20:22:52 UTC (rev 34517)
+++ scummvm/trunk/engines/scumm/smush/smush_player.h	2008-09-13 22:41:30 UTC (rev 34518)
@@ -27,7 +27,6 @@
 #define SCUMM_SMUSH_PLAYER_H
 
 #include "common/util.h"
-#include "scumm/smush/chunk.h"
 #include "scumm/sound.h"
 
 namespace Scumm {
@@ -51,7 +50,7 @@
 	StringResource *_strings;
 	Codec37Decoder *_codec37;
 	Codec47Decoder *_codec47;
-	Chunk *_base;
+	Common::SeekableReadStream *_base;
 	byte *_frameBuffer;
 	byte *_specialBuffer;
 
@@ -121,22 +120,21 @@
 
 	bool readString(const char *file);
 	void decodeFrameObject(int codec, const uint8 *src, int left, int top, int width, int height);
-	void checkBlock(const Chunk &, Chunk::type, int32 = 0);
-	void handleAnimHeader(Chunk &);
-	void handleFrame(Chunk &);
-	void handleNewPalette(Chunk &);
+	void handleAnimHeader(int32 subSize, Common::SeekableReadStream &);
+	void handleFrame(int32 frameSize, Common::SeekableReadStream &);
+	void handleNewPalette(int32 subSize, Common::SeekableReadStream &);
 #ifdef USE_ZLIB
-	void handleZlibFrameObject(Chunk &b);
+	void handleZlibFrameObject(int32 subSize, Common::SeekableReadStream &b);
 #endif
-	void handleFrameObject(Chunk &);
-	void handleSoundBuffer(int32, int32, int32, int32, int32, int32, Chunk &, int32);
-	void handleSoundFrame(Chunk &);
-	void handleStore(Chunk &);
-	void handleFetch(Chunk &);
-	void handleIACT(Chunk &);
-	void handleTextResource(Chunk &);
-	void handleDeltaPalette(Chunk &);
-	void readPalette(byte *, Chunk &);
+	void handleFrameObject(int32 subSize, Common::SeekableReadStream &);
+	void handleSoundBuffer(int32, int32, int32, int32, int32, int32, Common::SeekableReadStream &, int32);
+	void handleSoundFrame(int32 subSize, Common::SeekableReadStream &);
+	void handleStore(int32 subSize, Common::SeekableReadStream &);
+	void handleFetch(int32 subSize, Common::SeekableReadStream &);
+	void handleIACT(int32 subSize, Common::SeekableReadStream &);
+	void handleTextResource(uint32 subType, int32 subSize, Common::SeekableReadStream &);
+	void handleDeltaPalette(int32 subSize, Common::SeekableReadStream &);
+	void readPalette(byte *, Common::SeekableReadStream &);
 
 	void timerCallback();
 };


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