HOWTO-Engines
Introduction
This page is meant as a mini-HOWTO which roughly outlines the steps needed to add a new engine to ScummVM. It does not tell you how to create an engine for a given game; rather it is meant to tell a developer how to properly "hook" into ScummVM.
I will assume that you are at least roughly familiar with ScummVM, and have a fresh checkout of our Subversion repository. Note that it's strongly adviced to base your work on the current development version of ScummVM, and not on a release version. This will ease integration of your work.
Overview
Essentially, you will have to implement a subclass of the Engine class. Our Doxygen documentation is your friend and should hopefully explain enough about this, see here: http://scummvm.org/docs/doxygen/html/class Engine.php.
You also must hook yourself into the regular ScummVM main build system. Actually, some ports use custom build system, but their maintainers will usually add your new engine once it has been added to ScummVM.
Finally, you need to make ScummVM aware of your new engine by updating a couple source files (see below).
Steps
In the following I assume your engine is called "quux".
- Add a new directory engines/quux/
- Add engines/quux/module.mk (take a look at module.mk files of 2-3 existing engines to understand the content).
- Add engines/quux/quux.h and engines/quux/quux.cpp; this will contain your Engine subclass (or at least parts of it). It will also contain the plugin interface code (more on that in the next section).
- Modify engines/module.mk by adding your engine. It should be clear what to do by looking at what is done for the other engines there.
- Modify configure; you'll have to add your engine in multiple places. Again, just check out what is done for the existing engines.
- Modify base/plugins.cpp; in particular, you have to add your engine to the list in PluginManager::loadPlugins.
That's it. The difficult part is of course writing the Engine subclass. More on that in the next section!
Important note: Use a C++ namespace for all your work, e.g. "namespace Quux" in this case.
Example: engines/quux/module.mk
MODULE := engines/quux MODULE_OBJS := \ quux.o MODULE_DIRS += \ engines/quux # This module can be built as a plugin ifdef BUILD_PLUGINS PLUGIN := 1 endif # Include common rules include $(srcdir)/common.rules
Subclassing Engine
TODO: We should probably give some sample code, maybe even provide a full (empty) Engine demo class. Maybe even provide a real mini engine project somewhere on our site which demonstrates using events, drawing, etc. ? Not sure whether this would be worth the effort, though.
TODO: At the very least, describe the plugin interface: I.e. which functions *must* be implemented, and what they are supposed to do. Once again, sample code would be nice.