[Scummvm-cvs-logs] SF.net SVN: scummvm:[47099] scummvm/trunk/engines/sci

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Wed Jan 6 22:56:31 CET 2010


Revision: 47099
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47099&view=rev
Author:   m_kiewitz
Date:     2010-01-06 21:56:31 +0000 (Wed, 06 Jan 2010)

Log Message:
-----------
SCI: added a new class for robot resources

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/console.h
    scummvm/trunk/engines/sci/graphics/gui.cpp
    scummvm/trunk/engines/sci/graphics/gui.h

Added Paths:
-----------
    scummvm/trunk/engines/sci/graphics/robot.cpp
    scummvm/trunk/engines/sci/graphics/robot.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-01-06 21:16:11 UTC (rev 47098)
+++ scummvm/trunk/engines/sci/console.cpp	2010-01-06 21:56:31 UTC (rev 47099)
@@ -111,6 +111,9 @@
 	DCmd_Register("set_palette",		WRAP_METHOD(Console, cmdSetPalette));
 	DCmd_Register("draw_pic",			WRAP_METHOD(Console, cmdDrawPic));
 	DCmd_Register("draw_cel",			WRAP_METHOD(Console, cmdDrawCel));
+#ifdef ENABLE_SCI32
+	DCmd_Register("draw_robot",			WRAP_METHOD(Console, cmdDrawRobot));
+#endif
 	DCmd_Register("undither",           WRAP_METHOD(Console, cmdUndither));
 	DCmd_Register("play_video",         WRAP_METHOD(Console, cmdPlayVideo));
 	// Segments
@@ -1018,6 +1021,22 @@
 	return true;
 }
 
+#ifdef ENABLE_SCI32
+bool Console::cmdDrawRobot(int argc, const char **argv) {
+	if (argc < 2) {
+		DebugPrintf("Draws a frame from a robot resource\n");
+		DebugPrintf("Usage: %s <resourceId>\n", argv[0]);
+		DebugPrintf("where <resourceId> is the id of the robot resource to draw\n");
+		return true;
+	}
+
+	uint16 resourceId = atoi(argv[1]);
+
+	_vm->_gamestate->_gui->drawRobot();
+	return true;
+}
+#endif
+
 bool Console::cmdUndither(int argc, const char **argv) {
 	if (argc != 2) {
 		DebugPrintf("Enable/disable undithering.\n");

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2010-01-06 21:16:11 UTC (rev 47098)
+++ scummvm/trunk/engines/sci/console.h	2010-01-06 21:56:31 UTC (rev 47099)
@@ -86,6 +86,9 @@
 	bool cmdSetPalette(int argc, const char **argv);
 	bool cmdDrawPic(int argc, const char **argv);
 	bool cmdDrawCel(int argc, const char **argv);
+#ifdef ENABLE_SCI32
+	bool cmdDrawRobot(int argc, const char **argv);
+#endif
 	bool cmdUndither(int argc, const char **argv);
 	bool cmdPlayVideo(int argc, const char **argv);
 	// Segments

Modified: scummvm/trunk/engines/sci/graphics/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui.cpp	2010-01-06 21:16:11 UTC (rev 47098)
+++ scummvm/trunk/engines/sci/graphics/gui.cpp	2010-01-06 21:56:31 UTC (rev 47099)
@@ -39,6 +39,7 @@
 #include "sci/graphics/animate.h"
 #include "sci/graphics/controls.h"
 #include "sci/graphics/menu.h"
+#include "sci/graphics/robot.h"
 #include "sci/graphics/text.h"
 #include "sci/graphics/transitions.h"
 #include "sci/graphics/view.h"
@@ -919,6 +920,11 @@
 		}
 	}
 }
+
+void SciGui::drawRobot() {
+	Robot *test = new Robot(_s->resMan, _screen, 91);
+	test->draw();
+}
 #endif
 
 bool SciGui::debugUndither(bool flag) {

Modified: scummvm/trunk/engines/sci/graphics/gui.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui.h	2010-01-06 21:16:11 UTC (rev 47098)
+++ scummvm/trunk/engines/sci/graphics/gui.h	2010-01-06 21:56:31 UTC (rev 47099)
@@ -161,6 +161,8 @@
 	virtual void frameOut();
 	virtual void globalToLocal(int16 *x, int16 *y, reg_t planeObj);
 	virtual void localToGlobal(int16 *x, int16 *y, reg_t planeObj);
+
+	virtual void drawRobot();
 #endif
 
 	virtual bool debugUndither(bool flag);

Copied: scummvm/trunk/engines/sci/graphics/robot.cpp (from rev 47087, scummvm/trunk/engines/sci/graphics/view.cpp)
===================================================================
--- scummvm/trunk/engines/sci/graphics/robot.cpp	                        (rev 0)
+++ scummvm/trunk/engines/sci/graphics/robot.cpp	2010-01-06 21:56:31 UTC (rev 47099)
@@ -0,0 +1,75 @@
+/* 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 "sci/sci.h"
+#include "sci/engine/state.h"
+#include "sci/graphics/gfx.h"
+#include "sci/graphics/screen.h"
+#include "sci/graphics/robot.h"
+
+namespace Sci {
+
+#ifdef ENABLE_SCI32
+Robot::Robot(ResourceManager *resMan, Screen *screen, GuiResourceId resourceId)
+	: _resMan(resMan), _screen(screen), _resourceId(resourceId) {
+	assert(resourceId != -1);
+	initData(resourceId);
+}
+
+Robot::~Robot() {
+	_resMan->unlockResource(_resource);
+}
+
+void Robot::initData(GuiResourceId resourceId) {
+	_resource = _resMan->findResource(ResourceId(kResourceTypeRobot, resourceId), true);
+	if (!_resource) {
+		error("robot resource %d not found", resourceId);
+	}
+	_resourceData = _resource->data;
+
+	_width = READ_LE_UINT16(_resourceData + 10);
+	_height = READ_LE_UINT16(_resourceData + 12);
+}
+
+// TODO: just trying around in here...
+
+void Robot::draw() {
+	byte *bitmapData = _resourceData + 0x48;
+	int x, y;
+	int frame;
+
+	//for (frame = 0; frame < 30; frame++) {
+	for (y = 0; y < _height; y++) {
+		for (x = 0; x < _width; x++) {
+			_screen->putPixel(x, y, SCI_SCREEN_MASK_VISUAL, *bitmapData, 0, 0);
+			bitmapData++;
+		}
+	}
+	//}
+	_screen->copyToScreen();
+}
+#endif
+
+} // End of namespace Sci

Copied: scummvm/trunk/engines/sci/graphics/robot.h (from rev 47087, scummvm/trunk/engines/sci/graphics/view.h)
===================================================================
--- scummvm/trunk/engines/sci/graphics/robot.h	                        (rev 0)
+++ scummvm/trunk/engines/sci/graphics/robot.h	2010-01-06 21:56:31 UTC (rev 47099)
@@ -0,0 +1,56 @@
+/* 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 SCI_GRAPHICS_ROBOT_H
+#define SCI_GRAPHICS_ROBOT_H
+
+namespace Sci {
+
+#ifdef ENABLE_SCI32
+class Robot {
+public:
+	Robot(ResourceManager *resMan, Screen *screen, GuiResourceId resourceId);
+	~Robot();
+
+	void draw();
+
+private:
+	void initData(GuiResourceId resourceId);
+
+	ResourceManager *_resMan;
+	Screen *_screen;
+
+	GuiResourceId _resourceId;
+	Resource *_resource;
+	byte *_resourceData;
+
+	uint16 _width;
+	uint16 _height;
+};
+#endif
+
+} // End of namespace Sci
+
+#endif


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