[Scummvm-cvs-logs] CVS: residual bitmap.cpp,1.31,1.32 bitmap.h,1.16,1.17 lua.cpp,1.126,1.127 primitives.cpp,1.2,1.3 primitives.h,1.2,1.3

Pawel Kolodziejski aquadran at users.sourceforge.net
Fri Apr 8 04:17:27 CEST 2005


Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2431

Modified Files:
	bitmap.cpp bitmap.h lua.cpp primitives.cpp primitives.h 
Log Message:
added *Image opcodes, so Grim logo in menu is displayed

Index: bitmap.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/bitmap.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- bitmap.cpp	12 Jan 2005 18:06:42 -0000	1.31
+++ bitmap.cpp	8 Apr 2005 11:16:56 -0000	1.32
@@ -33,6 +33,8 @@
 	if (len < 8 || memcmp(data, "BM  F\0\0\0", 8) != 0)
 		error("Invalid magic loading bitmap\n");
 
+	strcpy(_filename, filename);
+
 	int codec = READ_LE_UINT32(data + 8);
 //	_paletteIncluded = READ_LE_UINT32(data + 12);
 	_numImages = READ_LE_UINT32(data + 16);

Index: bitmap.h
===================================================================
RCS file: /cvsroot/scummvm/residual/bitmap.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- bitmap.h	21 Jan 2005 21:21:07 -0000	1.16
+++ bitmap.h	8 Apr 2005 11:16:56 -0000	1.17
@@ -39,9 +39,13 @@
 	int height() const { return _height; }
 	int x() const { return _x; }
 	int y() const { return _y; }
+	void setX(int x) { _x = x; }
+	void setY(int y) { _y = y; }
 
 	char *getData() { return _data[_currImage]; }
 
+	char *getFilename() { return _filename; }
+
 	~Bitmap();
 
 //private:
@@ -52,6 +56,7 @@
 	int _numTex;
 	void *_texIds;
 	bool _hasTransparency;
+	char _filename[32];
 };
 
 #endif

Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -d -r1.126 -r1.127
--- lua.cpp	8 Apr 2005 10:23:43 -0000	1.126
+++ lua.cpp	8 Apr 2005 11:16:56 -0000	1.127
@@ -71,6 +71,13 @@
 	return false;
 }
 
+static inline bool isBitmapObject(int num) {
+	lua_Object param = lua_getparam(num);
+	if (lua_isuserdata(param) && lua_tag(param) == MKID('VBUF'))
+		return true;
+	return false;
+}
+
 // Helper functions to ensure the arguments we get are what we expect
 static inline ObjectState *check_object(int num) {
 	lua_Object param = lua_getparam(num);
@@ -114,7 +121,7 @@
 
 static inline Bitmap *check_bitmapobject(int num) {
 	lua_Object param = lua_getparam(num);
-	if (lua_isuserdata(param) && lua_tag(param) == MKID('IMAG'))
+	if (lua_isuserdata(param) && lua_tag(param) == MKID('VBUF'))
 		return static_cast<Bitmap *>(lua_getuserdata(param));
 	luaL_argerror(num, "image object expected");
 	return NULL;
@@ -1201,6 +1208,37 @@
 	}
 }
 
+static void GetImage() {
+	char *bitmapName = luaL_check_string(1);
+	Bitmap *image = g_resourceloader->loadBitmap(bitmapName);
+	lua_pushusertag(image, MKID('VBUF'));
+}
+
+static void FreeImage() {
+	Bitmap *bitmap = check_bitmapobject(1);
+
+	for (Engine::PrimitiveListType::const_iterator i = g_engine->primitivesBegin(); i != g_engine->primitivesEnd(); i++) {
+		PrimitiveObject *p = *i;
+		if (p->isBitmap() && p->getBitmapHandle() == bitmap) {
+			g_engine->killPrimitiveObject(p);
+			break;
+		}
+	}
+
+	g_resourceloader->uncache(bitmap->getFilename());
+}
+
+static void BlastImage() {
+	Bitmap *bitmap = check_bitmapobject(1);
+	int x = check_int(2);
+	int y = check_int(3);
+	bool transparent = getbool(4);
+
+	PrimitiveObject *p = new PrimitiveObject();
+	p->createBitmap(bitmap, x, y, transparent);
+	g_engine->registerPrimitiveObject(p);
+}
+
 void getTextObjectParams(TextObject *textObject, lua_Object table_obj) {
 	char *key_text = NULL;
 	lua_Object key;
@@ -1823,9 +1861,6 @@
 STUB_FUNC(SetTextSpeed)
 STUB_FUNC(GetSaveGameData)
 STUB_FUNC(SubmitSaveGameData)
-STUB_FUNC(BlastImage)
-STUB_FUNC(FreeImage)
-STUB_FUNC(GetImage)
 STUB_FUNC(GetSaveGameImage)
 STUB_FUNC(ScreenShot)
 STUB_FUNC(TextFileGetLine)

Index: primitives.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/primitives.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- primitives.cpp	8 Apr 2005 09:33:21 -0000	1.2
+++ primitives.cpp	8 Apr 2005 11:16:57 -0000	1.3
@@ -35,9 +35,12 @@
 	_color._vals[2] = 0;
 	_filled = false;
 	_type = 0;
+	_bitmap = NULL;
 }
 
 PrimitiveObject::~PrimitiveObject() {
+	if (_type == 2)
+		g_driver->destroyBitmap(_bitmap);
 }
 
 void PrimitiveObject::createRectangle(int x1, int x2, int y1, int y2, Color color, bool filled) {
@@ -50,9 +53,20 @@
 	_type = 1;
 }
 
+void PrimitiveObject::createBitmap(Bitmap *bitmap, int x, int y, bool transparent) {
+	_type = 2;
+	_bitmap = bitmap;
+	_bitmap->setX(x);
+	_bitmap->setY(y);
+	// transparent: what to do ?
+	g_driver->createBitmap(_bitmap);
+}
+
 void PrimitiveObject::draw() {
 	assert(_type);
 
 	if (_type == 1)
 		g_driver->drawRectangle(this);
+	else if (_type == 2)
+		g_driver->drawBitmap(_bitmap);
 }

Index: primitives.h
===================================================================
RCS file: /cvsroot/scummvm/residual/primitives.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- primitives.h	8 Apr 2005 09:33:21 -0000	1.2
+++ primitives.h	8 Apr 2005 11:16:57 -0000	1.3
@@ -33,6 +33,7 @@
 	~PrimitiveObject();
 
 	void createRectangle(int x1, int x2, int y1, int y2, Color color, bool filled);
+	void createBitmap(Bitmap *bitmap, int x, int y, bool transparent);
 	int getX1() { return _x1; }
 	int getX2() { return _x2; }
 	int getY1() { return _y1; }
@@ -40,12 +41,15 @@
 	Color getColor() { return _color; }
 	bool isFilled() { return _filled; }
 	void draw();
+	bool isBitmap() { return _type == 2; }
+	Bitmap *getBitmapHandle() { assert(_bitmap); return _bitmap; }
 
 private:
 	int _x1, _x2, _y1, _y2;
 	Color _color;
 	bool _filled;
 	int _type;
+	Bitmap *_bitmap;
 };
 
 #endif





More information about the Scummvm-git-logs mailing list