[Scummvm-cvs-logs] scummvm master -> 8a8742930665010b83ed6518fe019b68b7b9ae7f

zeldin marcus at mc.pp.se
Wed Apr 20 23:48:14 CEST 2011


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
21421d2e86 DC: Move dynamic plugin handling into the platform
8a87429306 DC: Provide some feedback when loading plugins


Commit: 21421d2e86cf44a3236dd39da847ee15b366d95f
    https://github.com/scummvm/scummvm/commit/21421d2e86cf44a3236dd39da847ee15b366d95f
Author: Marcus Comstedt (marcus at mc.pp.se)
Date: 2011-04-20T14:46:44-07:00

Commit Message:
DC: Move dynamic plugin handling into the platform

Changed paths:
  A backends/platform/dc/plugins.cpp
  R backends/plugins/dc/dc-provider.cpp
  R backends/plugins/dc/dc-provider.h
    backends/module.mk
    backends/platform/dc/Makefile
    backends/platform/dc/dc.h
    backends/platform/dc/dcmain.cpp
    backends/platform/dc/module.mk



diff --git a/backends/module.mk b/backends/module.mk
index 426409a..cd0e2a5 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -75,11 +75,6 @@ MODULE_OBJS := \
 	vkeybd/virtual-keyboard-gui.o \
 	vkeybd/virtual-keyboard-parser.o
 
-ifeq ($(BACKEND),dc)
-MODULE_OBJS += \
-	plugins/dc/dc-provider.o
-endif
-
 ifeq ($(BACKEND),ds)
 MODULE_OBJS += \
 	fs/ds/ds-fs-factory.o \
diff --git a/backends/platform/dc/Makefile b/backends/platform/dc/Makefile
index 637f474..11d9421 100644
--- a/backends/platform/dc/Makefile
+++ b/backends/platform/dc/Makefile
@@ -65,7 +65,7 @@ ENABLE_TOUCHE = $(ENABLED)
 ENABLE_TUCKER = $(ENABLED)
 
 OBJS :=	dcmain.o time.o display.o audio.o input.o selector.o icon.o \
-	label.o vmsave.o softkbd.o dcloader.o cache.o dc-fs.o
+	label.o vmsave.o softkbd.o dcloader.o cache.o dc-fs.o plugins.o
 
 MODULE_DIRS += ./
 
diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h
index 76c4b8c..f0c8c1f 100644
--- a/backends/platform/dc/dc.h
+++ b/backends/platform/dc/dc.h
@@ -31,6 +31,9 @@
 #include "backends/audiocd/default/default-audiocd.h"
 #include "backends/fs/fs-factory.h"
 #include "audio/mixer_intern.h"
+#ifdef DYNAMIC_MODULES
+#include "backends/plugins/dynamic-plugin.h"
+#endif
 
 #define NUM_BUFFERS 4
 #define SOUND_BUFFER_SHIFT 3
@@ -69,7 +72,11 @@ class DCCDManager : public DefaultAudioCDManager {
   void updateCD();
 };
 
-class OSystem_Dreamcast : private DCHardware, public BaseBackend, public PaletteManager, public FilesystemFactory {
+class OSystem_Dreamcast : private DCHardware, public BaseBackend, public PaletteManager, public FilesystemFactory
+#ifdef DYNAMIC_MODULES
+  , public FilePluginProvider
+#endif
+ {
 
  public:
   OSystem_Dreamcast();
@@ -250,6 +257,14 @@ public:
 
   void logMessage(LogMessageType::Type type, const char *message);
   Common::String getSystemLanguage() const;
+
+#ifdef DYNAMIC_MODULES
+  class DCPlugin;
+
+ protected:
+  Plugin* createPlugin(const Common::FSNode &node) const;
+  bool isPluginFilename(const Common::FSNode &node) const;
+#endif
 };
 
 
diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp
index bbd4f99..f964013 100644
--- a/backends/platform/dc/dcmain.cpp
+++ b/backends/platform/dc/dcmain.cpp
@@ -33,7 +33,6 @@
 #include <common/config-manager.h>
 #include <common/memstream.h>
 
-#include "backends/plugins/dc/dc-provider.h"
 #include "audio/mixer_intern.h"
 
 
@@ -336,7 +335,7 @@ int main()
   g_system = &osys_dc;
 
 #ifdef DYNAMIC_MODULES
-  PluginManager::instance().addPluginProvider(new DCPluginProvider());
+  PluginManager::instance().addPluginProvider(&osys_dc);
 #endif
 
   scummvm_main(argc, argv);
diff --git a/backends/platform/dc/module.mk b/backends/platform/dc/module.mk
index c52ca1a..9ab287c 100644
--- a/backends/platform/dc/module.mk
+++ b/backends/platform/dc/module.mk
@@ -1,7 +1,7 @@
 MODULE := backends/platform/dc
 
 MODULE_OBJS :=	dcmain.o time.o display.o audio.o input.o selector.o icon.o \
-	label.o vmsave.o softkbd.o dcloader.o cache.o dc-fs.o
+	label.o vmsave.o softkbd.o dcloader.o cache.o dc-fs.o plugins.o
 
 # We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
 MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
diff --git a/backends/platform/dc/plugins.cpp b/backends/platform/dc/plugins.cpp
new file mode 100644
index 0000000..7b07947
--- /dev/null
+++ b/backends/platform/dc/plugins.cpp
@@ -0,0 +1,100 @@
+/* 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/scummsys.h"
+
+#if defined(DYNAMIC_MODULES)
+
+#include "backends/plugins/dynamic-plugin.h"
+#include "common/fs.h"
+
+#include "dcloader.h"
+
+
+class OSystem_Dreamcast::DCPlugin : public DynamicPlugin {
+protected:
+	void *_dlHandle;
+
+	virtual VoidFunc findSymbol(const char *symbol) {
+		void *func = dlsym(_dlHandle, symbol);
+		if (!func)
+			warning("Failed loading symbol '%s' from plugin '%s' (%s)", symbol, _filename.c_str(), dlerror());
+
+		// FIXME HACK: This is a HACK to circumvent a clash between the ISO C++
+		// standard and POSIX: ISO C++ disallows casting between function pointers
+		// and data pointers, but dlsym always returns a void pointer. For details,
+		// see e.g. <http://www.trilithium.com/johan/2004/12/problem-with-dlsym/>.
+		assert(sizeof(VoidFunc) == sizeof(func));
+		VoidFunc tmp;
+		memcpy(&tmp, &func, sizeof(VoidFunc));
+		return tmp;
+	}
+
+public:
+	DCPlugin(const Common::String &filename)
+		: DynamicPlugin(filename), _dlHandle(0) {}
+
+	bool loadPlugin() {
+		assert(!_dlHandle);
+		_dlHandle = dlopen(_filename.c_str(), RTLD_LAZY);
+
+		if (!_dlHandle) {
+			warning("Failed loading plugin '%s' (%s)", _filename.c_str(), dlerror());
+			return false;
+		}
+
+		bool ret = DynamicPlugin::loadPlugin();
+
+		if (ret)
+			dlforgetsyms(_dlHandle);
+
+		return ret;
+	}
+
+	void unloadPlugin() {
+		DynamicPlugin::unloadPlugin();
+		if (_dlHandle) {
+			if (dlclose(_dlHandle) != 0)
+				warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());
+			_dlHandle = 0;
+		}
+	}
+};
+
+
+Plugin* OSystem_Dreamcast::createPlugin(const Common::FSNode &node) const {
+	return new DCPlugin(node.getPath());
+}
+
+bool OSystem_Dreamcast::isPluginFilename(const Common::FSNode &node) const {
+	// Check the plugin suffix
+	Common::String filename = node.getName();
+	if (!filename.hasSuffix(".PLG"))
+		return false;
+
+	return true;
+}
+
+#endif // defined(DYNAMIC_MODULES)
diff --git a/backends/plugins/dc/dc-provider.cpp b/backends/plugins/dc/dc-provider.cpp
deleted file mode 100644
index 86ef688..0000000
--- a/backends/plugins/dc/dc-provider.cpp
+++ /dev/null
@@ -1,101 +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 "common/scummsys.h"
-
-#if defined(DYNAMIC_MODULES) && defined(__DC__)
-
-#include "backends/plugins/dc/dc-provider.h"
-#include "backends/plugins/dynamic-plugin.h"
-#include "common/fs.h"
-
-#include "dcloader.h"
-
-
-class DCPlugin : public DynamicPlugin {
-protected:
-	void *_dlHandle;
-
-	virtual VoidFunc findSymbol(const char *symbol) {
-		void *func = dlsym(_dlHandle, symbol);
-		if (!func)
-			warning("Failed loading symbol '%s' from plugin '%s' (%s)", symbol, _filename.c_str(), dlerror());
-
-		// FIXME HACK: This is a HACK to circumvent a clash between the ISO C++
-		// standard and POSIX: ISO C++ disallows casting between function pointers
-		// and data pointers, but dlsym always returns a void pointer. For details,
-		// see e.g. <http://www.trilithium.com/johan/2004/12/problem-with-dlsym/>.
-		assert(sizeof(VoidFunc) == sizeof(func));
-		VoidFunc tmp;
-		memcpy(&tmp, &func, sizeof(VoidFunc));
-		return tmp;
-	}
-
-public:
-	DCPlugin(const Common::String &filename)
-		: DynamicPlugin(filename), _dlHandle(0) {}
-
-	bool loadPlugin() {
-		assert(!_dlHandle);
-		_dlHandle = dlopen(_filename.c_str(), RTLD_LAZY);
-
-		if (!_dlHandle) {
-			warning("Failed loading plugin '%s' (%s)", _filename.c_str(), dlerror());
-			return false;
-		}
-
-		bool ret = DynamicPlugin::loadPlugin();
-
-		if (ret)
-			dlforgetsyms(_dlHandle);
-
-		return ret;
-	}
-
-	void unloadPlugin() {
-		DynamicPlugin::unloadPlugin();
-		if (_dlHandle) {
-			if (dlclose(_dlHandle) != 0)
-				warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());
-			_dlHandle = 0;
-		}
-	}
-};
-
-
-Plugin* DCPluginProvider::createPlugin(const Common::FSNode &node) const {
-	return new DCPlugin(node.getPath());
-}
-
-bool DCPluginProvider::isPluginFilename(const Common::FSNode &node) const {
-	// Check the plugin suffix
-	Common::String filename = node.getName();
-	if (!filename.hasSuffix(".PLG"))
-		return false;
-
-	return true;
-}
-
-#endif // defined(DYNAMIC_MODULES) && defined(__DC__)
diff --git a/backends/plugins/dc/dc-provider.h b/backends/plugins/dc/dc-provider.h
deleted file mode 100644
index 55413ad..0000000
--- a/backends/plugins/dc/dc-provider.h
+++ /dev/null
@@ -1,42 +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 BACKENDS_PLUGINS_DC_H
-#define BACKENDS_PLUGINS_DC_H
-
-#include "base/plugins.h"
-
-#if defined(DYNAMIC_MODULES) && defined(__DC__)
-
-class DCPluginProvider : public FilePluginProvider {
-protected:
-	Plugin* createPlugin(const Common::FSNode &node) const;
-
-	bool isPluginFilename(const Common::FSNode &node) const;
-};
-
-#endif // defined(DYNAMIC_MODULES) && defined(__DC__)
-
-#endif


Commit: 8a8742930665010b83ed6518fe019b68b7b9ae7f
    https://github.com/scummvm/scummvm/commit/8a8742930665010b83ed6518fe019b68b7b9ae7f
Author: Marcus Comstedt (marcus at mc.pp.se)
Date: 2011-04-20T14:46:45-07:00

Commit Message:
DC: Provide some feedback when loading plugins

Display the names of the plugins being loaded, and display amount
of free memory while doing so.  This should make it easier to spot
the case that too many engine plugins have been placed on the boot
medium.

Changed paths:
    backends/platform/dc/plugins.cpp



diff --git a/backends/platform/dc/plugins.cpp b/backends/platform/dc/plugins.cpp
index 7b07947..be329ab 100644
--- a/backends/platform/dc/plugins.cpp
+++ b/backends/platform/dc/plugins.cpp
@@ -32,6 +32,39 @@
 
 #include "dcloader.h"
 
+extern void draw_solid_quad(float x1, float y1, float x2, float y2,
+			    int c0, int c1, int c2, int c3);
+
+static void drawPluginProgress(const Common::String &filename)
+{
+  ta_sync();
+  void *mark = ta_txmark();
+  Label lab1, lab2, lab3;
+  char buf[32];
+  unsigned memleft = 0x8cf00000-((unsigned)sbrk(0));
+  float ffree = memleft*(1.0/(16<<20));
+  int fcol = (memleft < (1<<20)? 0xffff0000:
+	      (memleft < (4<<20)? 0xffffff00: 0xff00ff00));
+  snprintf(buf, sizeof(buf), "%dK free memory", memleft>>10);
+  lab1.create_texture("Loading plugins, please wait...");
+  lab2.create_texture(filename.c_str());
+  lab3.create_texture(buf);
+  ta_begin_frame();
+  draw_solid_quad(80.0, 320.0, 560.0, 350.0,
+		  0xff808080, 0xff808080, 0xff808080, 0xff808080);
+  draw_solid_quad(85.0, 325.0, 555.0, 345.0, 
+		  0xff202020, 0xff202020, 0xff202020, 0xff202020);
+  draw_solid_quad(85.0, 325.0, 85.0+470.0*ffree, 345.0,
+		  fcol, fcol, fcol, fcol);
+  ta_commit_end();
+  lab1.draw(100.0, 200.0, 0xffffffff);
+  lab2.draw(100.0, 240.0, 0xffffffff);
+  lab3.draw(100.0, 280.0, 0xffffffff);
+  ta_commit_frame();
+  ta_sync();
+  ta_txrelease(mark);
+}
+
 
 class OSystem_Dreamcast::DCPlugin : public DynamicPlugin {
 protected:
@@ -58,6 +91,7 @@ public:
 
 	bool loadPlugin() {
 		assert(!_dlHandle);
+		drawPluginProgress(_filename);
 		_dlHandle = dlopen(_filename.c_str(), RTLD_LAZY);
 
 		if (!_dlHandle) {






More information about the Scummvm-git-logs mailing list