[Scummvm-cvs-logs] SF.net SVN: scummvm:[49478] scummvm/trunk/engines/m4

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Mon Jun 7 11:19:43 CEST 2010


Revision: 49478
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49478&view=rev
Author:   dreammaster
Date:     2010-06-07 09:19:42 +0000 (Mon, 07 Jun 2010)

Log Message:
-----------
Initial conversion of the AnimviewView class to use the expanded MadsAnimation class, rather than the older AAFile skeleton class

Modified Paths:
--------------
    scummvm/trunk/engines/m4/animation.cpp
    scummvm/trunk/engines/m4/animation.h
    scummvm/trunk/engines/m4/graphics.cpp
    scummvm/trunk/engines/m4/mads_anim.cpp
    scummvm/trunk/engines/m4/mads_anim.h
    scummvm/trunk/engines/m4/mads_menus.cpp
    scummvm/trunk/engines/m4/viewmgr.h

Modified: scummvm/trunk/engines/m4/animation.cpp
===================================================================
--- scummvm/trunk/engines/m4/animation.cpp	2010-06-07 09:10:22 UTC (rev 49477)
+++ scummvm/trunk/engines/m4/animation.cpp	2010-06-07 09:19:42 UTC (rev 49478)
@@ -39,6 +39,11 @@
 	_skipLoad = false;
 	_unkIndex = -1;
 	_messageCtr= 0;
+	_field12 = 0;
+
+	_currentFrame = 0;
+	_oldFrameEntry = 0;
+	_nextFrameTimer = _madsVm->_currentTimer;
 }
 
 MadsAnimation::~MadsAnimation() {
@@ -237,12 +242,14 @@
 	_messageCtr = 0;
 	_skipLoad = true;
 
+/* TODO:  figure out extra stuff in this routine
 	if (_field12) {
 		_unkIndex = -1;
 		int listIndex = _spriteListIndexes[_spriteListIndex];
 		SpriteAsset &spriteSet = _view->_spriteSlots.getSprite(listIndex);
-warning("%d", spriteSet.getCount());
+		..?..
 	}
+*/
 
 	// Initialise miscellaneous fields
 	_currentFrame = 0;
@@ -463,9 +470,6 @@
 		MadsSceneResources sceneResources;
 		sceneResources.load(_roomNumber, _interfaceFile.c_str(), 0, depthSurface, interfaceSurface);
 
-		// Rex only supports a single dialog draw style
-		assert(sceneResources.drawStyle == 2);
-
 	} else if (_animMode == 4) {
 		// Load a scene interface
 		interfaceSurface->madsLoadInterface(_interfaceFile);

Modified: scummvm/trunk/engines/m4/animation.h
===================================================================
--- scummvm/trunk/engines/m4/animation.h	2010-06-07 09:10:22 UTC (rev 49477)
+++ scummvm/trunk/engines/m4/animation.h	2010-06-07 09:19:42 UTC (rev 49478)
@@ -63,7 +63,7 @@
 
 #define ANIM_SPRITE_SET_SIZE 50
 
-enum MadsAnimationFlags {ANIM_CUSTOM_FONT = 0x20};
+enum MadsAnimationFlags {ANIM_CUSTOM_FONT = 0x20, ANIM_HAS_SOUND = 0x8000};
 
 class MadsAnimation: public Animation {
 private:
@@ -114,6 +114,7 @@
 	virtual void setCurrentFrame(int frameNumber);
 
 	bool freeFlag() const { return _freeFlag; }
+	int roomNumber() const { return _roomNumber; }
 };
 
 } // End of namespace M4

Modified: scummvm/trunk/engines/m4/graphics.cpp
===================================================================
--- scummvm/trunk/engines/m4/graphics.cpp	2010-06-07 09:10:22 UTC (rev 49477)
+++ scummvm/trunk/engines/m4/graphics.cpp	2010-06-07 09:19:42 UTC (rev 49478)
@@ -633,16 +633,6 @@
 	int sceneWidth = sourceUnc->readUint16LE();
 	int sceneHeight = sourceUnc->readUint16LE();
 	int sceneSize = sceneWidth * sceneHeight;
-	if (sceneWidth > this->width()) {
-		warning("Background width is %i, too large to fit in screen. Setting it to %i", sceneWidth, this->width());
-		sceneWidth = this->width();
-		sceneSize = sceneWidth * sceneHeight;
-	}
-	if (sceneHeight > this->height()) {
-		warning("Background height is %i, too large to fit in screen.Setting it to %i", sceneHeight, this->height());
-		sceneHeight = this->height();
-		sceneSize = sceneWidth * sceneHeight;
-	}
 
 	// Set palette
 	if (!palData) {
@@ -658,6 +648,7 @@
 	sourceUnc = packData.getItemStream(1);
 	assert((int)sourceUnc->size() >= sceneSize);
 
+	create(sceneWidth, sceneHeight, 1);
 	byte *pData = (byte *)pixels;
 	sourceUnc->read(pData, sceneSize);
 

Modified: scummvm/trunk/engines/m4/mads_anim.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_anim.cpp	2010-06-07 09:10:22 UTC (rev 49477)
+++ scummvm/trunk/engines/m4/mads_anim.cpp	2010-06-07 09:19:42 UTC (rev 49478)
@@ -441,8 +441,12 @@
 
 AnimviewView::AnimviewView(MadsM4Engine *vm):
 		View(vm, Common::Rect(0, 0, vm->_screen->width(), vm->_screen->height())),
-		_bgSurface(vm->_screen->width(), MADS_SURFACE_HEIGHT) {
+		MadsView(this), _backgroundSurface(MADS_SURFACE_WIDTH, MADS_SURFACE_HEIGHT),
+		_codeSurface(MADS_SURFACE_WIDTH, MADS_SURFACE_HEIGHT) {
 
+	MadsView::_bgSurface = &_backgroundSurface;
+	MadsView::_depthSurface = &_codeSurface;
+
 	_screenType = VIEWID_ANIMVIEW;
 	_screenFlags.layer = LAYER_BACKGROUND;
 	_screenFlags.visible = true;
@@ -452,27 +456,28 @@
 	_palData = NULL;
 	_previousUpdate = 0;
 	_transition = kTransitionNone;
+	_activeAnimation = NULL;
 	reset();
 
 	// Set up system palette colors
 	_vm->_palette->setMadsSystemPalette();
 
 	clear();
-	_bgSurface.clear();
+	_backgroundSurface.clear();
 
-	int y = (height() - MADS_SURFACE_HEIGHT) / 2;
 	setColor(2);
-	hLine(0, width() - 1, y - 2);
-	hLine(0, width() - 1, height() - y + 1);
+	hLine(0, width() - 1, MADS_Y_OFFSET - 2);
+	hLine(0, width() - 1, MADS_Y_OFFSET + MADS_SURFACE_HEIGHT + 2);
 }
 
 AnimviewView::~AnimviewView() {
 	if (_script)
 		_vm->res()->toss(_resourceName);
+	delete _activeAnimation;
 }
 
 void AnimviewView::reset() {
-	_bgSurface.clear();
+	_backgroundSurface.clear();
 	_soundDriverLoaded = false;
 }
 
@@ -515,19 +520,26 @@
 		_previousUpdate = g_system->getMillis();
 	}
 
-	// Check if we're ready for the next command
-	bool animRunning = false;
-	if (!animRunning) {
+	if (!_activeAnimation) {
+		readNextCommand();
+		assert(_activeAnimation);
+	}
+
+	// Update the current animation
+	_activeAnimation->update();
+	if (_activeAnimation->freeFlag()) {
+		delete _activeAnimation;
+		_activeAnimation = NULL;
+
 		if (_script->eos() ||  _script->err()) {
 			scriptDone();
 			return;
 		}
 
 		readNextCommand();
-
-		// FIXME: Replace flag with proper animation end check
-		animRunning = true;
 	}
+
+	refresh();
 }
 
 void AnimviewView::readNextCommand() {
@@ -562,46 +574,15 @@
 	if (strchr(_currentLine, '.') == NULL)
 		strcat(_currentLine, ".aa");
 
-	AAFile aaFile(_currentLine, _vm);
+	_activeAnimation = new MadsAnimation(_vm, this);
+	_activeAnimation->load(_currentLine, 0);
 
-	// Initial validation
-	if (aaFile.flags & AA_HAS_FONT) {
-		assert(_vm->_resourceManager->resourceExists(aaFile.fontResource.c_str()));
-	}
+	_backgroundSurface.loadBackground(_activeAnimation->roomNumber());
+	_codeSurface.create(_backgroundSurface.width(), _backgroundSurface.height(), 1);
+	_codeSurface.clear();
 
-	for (int seriesCtr = 0; seriesCtr < aaFile.seriesCount; ++seriesCtr)
-		assert(_vm->_resourceManager->resourceExists(aaFile.filenames[seriesCtr].c_str()));
-
-	// Start sound
-	if (aaFile.flags & AA_HAS_SOUND) {
-		char buffer[100];
-		strcpy(buffer, aaFile.soundName.c_str());
-		buffer[0] = 'A';	// A for AdLib resource
-
-		/*Common::SeekableReadStream *stream = */_vm->_resourceManager->get(buffer);
-
-		_vm->_resourceManager->toss(buffer);
-	}
-
-
-	char artFile[80];
-	sprintf(artFile, "rm%d.art", aaFile.roomNumber);
-
-	// Not all scenes have a background. If there is one, refresh it
-	if (_vm->_resourceManager->resourceExists(artFile)) {
-		if (_palData) {
-			_vm->_palette->deleteRange(_palData);
-			delete _palData;
-		}
-		_bgSurface.loadBackground(aaFile.roomNumber, &_palData);
-		_vm->_palette->addRange(_palData);
-		_bgSurface.translate(_palData);
-	}
-
-	// Grab what the final palete will be
-	RGB8 destPalette[256];
-	_vm->_palette->grabPalette(destPalette, 0, 256);
-
+	_spriteSlots.fullRefresh();
+/*
 	// Handle scene transition
 	switch (_transition) {
 		case kTransitionNone:
@@ -631,16 +612,14 @@
 			// nothing to do
 			break;
 	}
+*/
 
-	// Refresh the view
-	int yp = (height() - _bgSurface.height()) / 2;
-	_bgSurface.copyTo(this, 0, yp);
-
 	_vm->_resourceManager->toss(_currentLine);
 }
 
 
 void AnimviewView::scriptDone() {
+return;
 	AnimviewCallback fn = _callback;
 	MadsM4Engine *vm = _vm;
 
@@ -714,45 +693,4 @@
 	}
 }
 
-AAFile::AAFile(const char *resourceName, MadsM4Engine* vm): MadsPack(resourceName, vm) {
-	Common::MemoryReadStream stream1(*getItemStream(1));
-	Common::MemoryReadStream stream2(*getItemStream(2));
-
-	Common::MemoryReadStream stream(*getItemStream(0));
-
-	seriesCount = stream.readUint16LE();
-	frameCount = stream.readUint16LE();
-	frameEntryCount = stream.readUint16LE();
-	stream.skip(3);
-	flags = stream.readByte();
-	stream.skip(4);
-	roomNumber = stream.readUint16LE();
-	stream.skip(10);
-	frameTicks = stream.readUint16LE();
-
-	stream.skip(21);
-	for (int i = 0; i < 10; ++i) {
-		char filename[13];
-		stream.read(filename, 13);
-		filenames.push_back(Common::String(filename, 13));
-	}
-
-	stream.skip(81);
-	char name[100];
-	stream.read(name, 13);
-	lbmFilename = Common::String(name, 13);
-
-	stream.skip(365);
-	stream.read(name, 13);
-	spritesFilename = Common::String(name, 13);
-
-	stream.skip(48);
-	stream.read(name, 13);
-	soundName = Common::String(name, 13);
-
-	stream.skip(26);
-	stream.read(name, 14);
-	fontResource = Common::String(name, 14);
 }
-
-}

Modified: scummvm/trunk/engines/m4/mads_anim.h
===================================================================
--- scummvm/trunk/engines/m4/mads_anim.h	2010-06-07 09:10:22 UTC (rev 49477)
+++ scummvm/trunk/engines/m4/mads_anim.h	2010-06-07 09:19:42 UTC (rev 49478)
@@ -28,24 +28,12 @@
 
 #include "m4/viewmgr.h"
 #include "m4/compression.h"
+#include "m4/animation.h"
 
 #include "common/str-array.h"
 
 namespace M4 {
 
-enum SceneTransition {
-	kTransitionNone = 0,
-	kTransitionFadeIn = 1,
-	kTransitionFadeIn2 = 2,
-	kTransitionBoxInBottomLeft = 3,
-	kTransitionBoxInBottomRight = 4,
-	kTransitionBoxInTopLeft = 5,
-	kTransitionBoxInTopRight = 6,
-	kTransitionPanLeftToRight = 7,
-	kTransitionPanRightToLeft = 8,
-	kTransitionCircleIn = 9
-};
-
 typedef void (*TextviewCallback)(MadsM4Engine *vm);
 
 class TextviewView : public View {
@@ -89,36 +77,19 @@
 
 typedef void (*AnimviewCallback)(MadsM4Engine *vm);
 
-class AAFile : public MadsPack {
-public:
-	AAFile(const char *resourceName, MadsM4Engine* vm);
-
-	uint16 seriesCount;
-	uint16 frameCount;
-	uint16 frameEntryCount;
-	uint8 flags;
-	uint16 roomNumber;
-	uint16 frameTicks;
-	Common::StringArray filenames;
-	Common::String lbmFilename;
-	Common::String spritesFilename;
-	Common::String soundName;
-	Common::String fontResource;
-};
-
-enum AAFlags {AA_HAS_FONT = 0x20, AA_HAS_SOUND = 0x8000};
-
-class AnimviewView : public View {
+class AnimviewView : public View, MadsView {
 private:
 	char _resourceName[80];
 	Common::SeekableReadStream *_script;
 	uint32 _previousUpdate;
 	char _currentLine[80];
-	M4Surface _bgSurface;
+	M4Surface _backgroundSurface;
+	M4Surface _codeSurface;
 	AnimviewCallback _callback;
 	bool _soundDriverLoaded;
 	RGBList *_palData;
 	int _transition;
+	MadsAnimation *_activeAnimation;
 
 	void reset();
 	void readNextCommand();

Modified: scummvm/trunk/engines/m4/mads_menus.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_menus.cpp	2010-06-07 09:10:22 UTC (rev 49477)
+++ scummvm/trunk/engines/m4/mads_menus.cpp	2010-06-07 09:19:42 UTC (rev 49478)
@@ -49,7 +49,7 @@
 	_skipFlag = false;
 
 	// Load the background for the Rex Nebular game
-	_bgSurface = new M4Surface(width(), MADS_SURFACE_HEIGHT);
+	_bgSurface = new M4Surface();
 	_bgSurface->loadBackground(REX_MENUSCREEN, &_bgPalData);
 	_vm->_palette->addRange(_bgPalData);
 	_bgSurface->translate(_bgPalData);

Modified: scummvm/trunk/engines/m4/viewmgr.h
===================================================================
--- scummvm/trunk/engines/m4/viewmgr.h	2010-06-07 09:10:22 UTC (rev 49477)
+++ scummvm/trunk/engines/m4/viewmgr.h	2010-06-07 09:19:42 UTC (rev 49478)
@@ -42,6 +42,19 @@
 class View;
 class ViewManager;
 
+enum SceneTransition {
+	kTransitionNone = 0,
+	kTransitionFadeIn = 1,
+	kTransitionFadeIn2 = 2,
+	kTransitionBoxInBottomLeft = 3,
+	kTransitionBoxInBottomRight = 4,
+	kTransitionBoxInTopLeft = 5,
+	kTransitionBoxInTopRight = 6,
+	kTransitionPanLeftToRight = 7,
+	kTransitionPanRightToLeft = 8,
+	kTransitionCircleIn = 9
+};
+
 enum {SCREEN_DIALOG, SCREEN_BUFFER, SCREEN_TEXT, SCREEN_TRANSPARENT};
 enum ScreenEventType {SCREVENT_NONE = 0, SCREVENT_KEY = 1, SCREVENT_MOUSE = 2, SCREVENT_ALL = 3};
 enum ScreenLayers {


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