Difference between revisions of "HOWTO-Engines"

From ScummVM :: Wiki
Jump to navigation Jump to search
m
(Added example module.mk)
Line 1: Line 1:
=== Introduction ===
== 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.  
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.  


Line 5: Line 5:




=== Overview ===
== 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.  
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.  


Line 13: Line 13:




=== Steps ===
== Steps ==
In the following I assume your engine is called "quux".
In the following I assume your engine is called "quux".


Line 26: Line 26:


Important note: Use a C++ namespace for all your work, e.g. "namespace Quux" in this case.
Important note: Use a C++ namespace for all your work, e.g. "namespace Quux" in this case.
=== Example: engines/quux/module.mk ===
<pre>
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
</pre>





Revision as of 13:15, 12 February 2006

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".

  1. Add a new directory engines/quux/
  2. Add engines/quux/module.mk (take a look at module.mk files of 2-3 existing engines to understand the content).
  3. 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).
  4. 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.
  5. Modify configure; you'll have to add your engine in multiple places. Again, just check out what is done for the existing engines.
  6. 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.