[Scummvm-cvs-logs] SF.net SVN: scummvm:[41509] scummvm/branches/gsoc2009-draci/engines/draci

dkasak13 at users.sourceforge.net dkasak13 at users.sourceforge.net
Sun Jun 14 14:44:15 CEST 2009


Revision: 41509
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41509&view=rev
Author:   dkasak13
Date:     2009-06-14 12:44:12 +0000 (Sun, 14 Jun 2009)

Log Message:
-----------
Added a Sprite class for handling sprites in the Draci format transparently. Modified the test animation to use it.

Modified Paths:
--------------
    scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
    scummvm/branches/gsoc2009-draci/engines/draci/module.mk

Added Paths:
-----------
    scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp
    scummvm/branches/gsoc2009-draci/engines/draci/sprite.h

Modified: scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp	2009-06-14 12:19:42 UTC (rev 41508)
+++ scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp	2009-06-14 12:44:12 UTC (rev 41509)
@@ -35,6 +35,7 @@
 #include "draci/barchive.h"
 #include "draci/gpldisasm.h"
 #include "draci/font.h"
+#include "draci/sprite.h"
 
 namespace Draci {
 
@@ -88,6 +89,13 @@
 	return 0;
 }
 
+// Temporary hack
+
+void drawFrame(OSystem *syst, BAFile *frame) {
+	Sprite sp(frame->_data, frame->_length, ((320 - 50) / 2), 60, true);	
+	syst->copyRectToScreen(sp._data, sp._width, sp._x, sp._y, sp._width, sp._height); 
+}
+
 int DraciEngine::go() {
 	debugC(1, kDraciGeneralDebugLevel, "DraciEngine::go()");
  
@@ -154,29 +162,11 @@
 
 		// Load frame to memory
 		f = ar[t];
-		Common::MemoryReadStream reader(f->_data, f->_length);
-	
-		// Read in frame width and height
-		uint16 w = reader.readUint16LE();
-		uint16 h = reader.readUint16LE();
-		
-		// Allocate frame memory
-		byte *scr = new byte[w * h];
-
-		// Draw frame
-		for (uint16 i = 0; i < w; ++i) {
-			for (uint16 j = 0; j < h; ++j) {
-				scr[j * w + i] = reader.readByte();
-			}
-		}
-		_system->copyRectToScreen(scr, w, (320 - w) / 2, 60, w, h);
+		drawFrame(_system, f);
 		_system->updateScreen();
 		_system->delayMillis(100);
 
 		debugC(5, kDraciGeneralDebugLevel, "Finished frame %d", t);	
-
-		// Free frame memory
-		delete[] scr;
 	}	
 
 	getchar();

Modified: scummvm/branches/gsoc2009-draci/engines/draci/module.mk
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/module.mk	2009-06-14 12:19:42 UTC (rev 41508)
+++ scummvm/branches/gsoc2009-draci/engines/draci/module.mk	2009-06-14 12:44:12 UTC (rev 41509)
@@ -5,7 +5,8 @@
 	detection.o \
 	barchive.o \
 	gpldisasm.o \
-	font.o
+	font.o \
+	sprite.o
  
 MODULE_DIRS += \
 	engines/draci

Added: scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp	2009-06-14 12:44:12 UTC (rev 41509)
@@ -0,0 +1,85 @@
+/* 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 "common/stream.h"
+
+#include "draci/sprite.h"
+
+namespace Draci {
+
+/**
+ *  Constructor for loading sprites from a raw data buffer, one byte per pixel.
+ */
+Sprite::Sprite(byte *raw_data, uint16 width, uint16 height, uint16 x, uint16 y, 
+	bool columnwise) : _width(width), _height(height), _x(x), _y(y), _data(NULL) {
+	
+		_data = new byte[width * height];
+		
+		if (!columnwise) {
+			memcpy(_data, raw_data, width * height);
+			return;			
+		}
+		else {
+			for (uint16 i = 0; i < width; ++i) {
+				for (uint16 j = 0; j < height; ++j) {
+					_data[j * width + i] = *raw_data++;
+				}
+			}
+		}
+	}
+
+/**
+ *  Constructor for loading sprites from a sprite-formatted buffer, one byte per 
+ *	pixel.
+ */
+Sprite::Sprite(byte *sprite_data, uint16 length, uint16 x, uint16 y, 
+	bool columnwise) : _x(x), _y(y), _data(NULL) {
+
+		Common::MemoryReadStream reader(sprite_data, length);
+
+		_width = reader.readUint16LE();
+		_height = reader.readUint16LE();
+
+		_data = new byte[_width * _height];
+		
+		if (!columnwise) {
+			reader.read(_data, _width * _height);
+		}
+		else {
+			for (uint16 i = 0; i < _width; ++i) {
+				for (uint16 j = 0; j < _height; ++j) {
+					_data[j * _width + i] = reader.readByte();
+				}
+			}
+		}		
+	}
+
+Sprite::~Sprite() { 
+	delete[] _data;
+}
+		
+			
+} // End of namespace Draci	
+		
+ 


Property changes on: scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Added: scummvm/branches/gsoc2009-draci/engines/draci/sprite.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.h	                        (rev 0)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.h	2009-06-14 12:44:12 UTC (rev 41509)
@@ -0,0 +1,60 @@
+/* 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$
+ *
+ */
+
+namespace Draci {
+
+/**
+ *  Represents a Draci Historie sprite. Supplies two constructors; one for
+ *  loading a sprite from a raw data buffer and one for loading a sprite in
+ *  the Draci sprite format. Supports loading the sprite from a column-wise
+ *  format (transforming them to row-wise) since that is the way the sprites 
+ *  are stored in the original game files.
+ *  
+ *  Sprite format:	
+ *	[uint16LE] sprite width
+ * 	[uint16LE] sprite height
+ *	[height * width bytes] image pixels stored column-wise, one byte per pixel
+ */
+
+class Sprite {
+
+public:
+	Sprite(byte *raw_data, uint16 width, uint16 height, uint16 x = 0, uint16 y = 0, 
+		bool columnwise = false); 
+	
+	Sprite(byte *sprite_data, uint16 length, uint16 x = 0, uint16 y = 0, 
+		bool columnwise = false); 
+
+	~Sprite();
+
+	byte *_data;
+	uint16 _width;
+	uint16 _height;	
+	uint16 _x, _y;
+};
+
+
+} // End of namespace Draci
+


Property changes on: scummvm/branches/gsoc2009-draci/engines/draci/sprite.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native


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