aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/dc
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/dc')
-rw-r--r--backends/platform/dc/Makefile2
-rw-r--r--backends/platform/dc/dc.h18
-rw-r--r--backends/platform/dc/dcmain.cpp3
-rw-r--r--backends/platform/dc/dreamcast.mk4
-rw-r--r--backends/platform/dc/module.mk2
-rw-r--r--backends/platform/dc/plugins.cpp136
6 files changed, 160 insertions, 5 deletions
diff --git a/backends/platform/dc/Makefile b/backends/platform/dc/Makefile
index 637f474b4b..11d9421a0a 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 76c4b8cfd2..060eff2b48 100644
--- a/backends/platform/dc/dc.h
+++ b/backends/platform/dc/dc.h
@@ -26,11 +26,15 @@
#include "backends/base-backend.h"
#include <graphics/surface.h>
#include <graphics/colormasks.h>
+#include <graphics/palette.h>
#include <ronin/soundcommon.h>
#include "backends/timer/default/default-timer.h"
#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 +73,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 +258,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 bbd4f994f7..f9640130d3 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/dreamcast.mk b/backends/platform/dc/dreamcast.mk
index 8651a2936c..666e03eece 100644
--- a/backends/platform/dc/dreamcast.mk
+++ b/backends/platform/dc/dreamcast.mk
@@ -35,3 +35,7 @@ ip.txt : $(srcdir)/backends/platform/dc/ip.txt.in
ver="V$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)"; fi; \
sed -e 's/[@]VERSION[@]/'"$$ver"/ -e 's/[@]DATE[@]/$(shell date '+%Y%m%d')/' < $< > $@
+
+dcdist : dist
+ mkdir -p dcdist/scummvm
+ cp scummvm.elf SCUMMVM.BIN IP.BIN *.PLG dcdist/scummvm/
diff --git a/backends/platform/dc/module.mk b/backends/platform/dc/module.mk
index c52ca1a474..9ab287c080 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 0000000000..44b8960513
--- /dev/null
+++ b/backends/platform/dc/plugins.cpp
@@ -0,0 +1,136 @@
+/* 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"
+
+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();
+ const char *fn = filename.c_str();
+ 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);
+ if (fn[0] == '/') fn++;
+ lab1.create_texture("Loading plugins, please wait...");
+ lab2.create_texture(fn);
+ lab3.create_texture(buf);
+ ta_begin_frame();
+ draw_solid_quad(80.0, 270.0, 560.0, 300.0,
+ 0xff808080, 0xff808080, 0xff808080, 0xff808080);
+ draw_solid_quad(85.0, 275.0, 555.0, 295.0,
+ 0xff202020, 0xff202020, 0xff202020, 0xff202020);
+ draw_solid_quad(85.0, 275.0, 85.0+470.0*ffree, 295.0,
+ fcol, fcol, fcol, fcol);
+ ta_commit_end();
+ lab1.draw(100.0, 150.0, 0xffffffff);
+ lab2.draw(100.0, 190.0, 0xffaaffaa);
+ lab3.draw(100.0, 230.0, 0xffffffff);
+ ta_commit_frame();
+ ta_sync();
+ ta_txrelease(mark);
+}
+
+
+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);
+ drawPluginProgress(_filename);
+ _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)