Difference between revisions of "HOWTO-Engines"

Jump to navigation Jump to search
1,040 bytes added ,  15:08, 25 October 2018
m
Text replacement - "<source lang=" to "<syntaxhighlight lang="
m (Made changes to reflect changed way to register engines)
m (Text replacement - "<source lang=" to "<syntaxhighlight lang=")
(11 intermediate revisions by 5 users not shown)
Line 15: Line 15:


# Add a new directory <tt>engines/quux/</tt>
# Add a new directory <tt>engines/quux/</tt>
# Add <tt>engines/quux/module.mk</tt> (looking at module.mk files of existing engines should make it clear what you have to do).
# Add <tt>engines/quux/configure.engine</tt> (looking at configure.engine files of existing engines should make it clear what you have to do).
# Add <tt>engines/quux/module.mk</tt> (Again, just check out what is done for the existing engines).
# Add <tt>engines/quux/quux.h</tt> and <tt>engines/quux/quux.cpp</tt>; this will contain your Engine subclass (or at least parts of it).
# Add <tt>engines/quux/quux.h</tt> and <tt>engines/quux/quux.cpp</tt>; this will contain your Engine subclass (or at least parts of it).
# Add <tt>engines/quux/detection.cpp</tt>; It will contain the plugin interface code (more on that in the next section).
# Add <tt>engines/quux/detection.cpp</tt>; It will contain the plugin interface code (more on that in the next section).
# Modify <tt>engines/engines.mk</tt> by adding your engine. It should be clear what to do by looking at what is done for the other engines there.
# Modify <tt>engines/configure.engines</tt> by adding a new add_engine line. Again, just check out what is done for the existing engines.


That's it. The difficult part is of course writing the Engine subclass. More on that in the next section!
That's it. The difficult part is of course writing the Engine subclass. More on that in the next section!
Line 48: Line 47:
|inter.cpp, logic.cpp, script.cpp || Game logic, resp. script/bytecode interpreter
|inter.cpp, logic.cpp, script.cpp || Game logic, resp. script/bytecode interpreter
|}
|}
Additionally, the files saved by each engine should be consistent.
* '''Saves''': These should be named <targetid>.### (where ### is the slot id) or <gameid>.###. The latter should be used when the saves can be shared across all game variants.
* '''Other files''': These should be named <targetid>-<filename> or <gameid>-<filename>. Again the latter when the files can be shared acress all variants of the game (an example for these type of files would be when a minigame saves a high score record).
Here, only use the <gameid> scheme if you are '''absolutely''' sure that such files can be shared across '''all''' (that is every game platform, every game language, every game patch version, every game release, etc.) versions. If you are not sure whether this is the case, then stick to the <targetid> based scheme.


=== Subclassing MetaEngine ===
=== Subclassing MetaEngine ===
Line 108: Line 115:


=== Example: engines/quux/quux.h ===
=== Example: engines/quux/quux.h ===
<syntax type="C++">
<syntaxhighlight lang="cpp">
#ifndef QUUX_H
#ifndef QUUX_H
#define QUUX_H
#define QUUX_H
Line 152: Line 159:
   
   
#endif
#endif
</syntax>
</syntaxhighlight>


=== Example: engines/quux/quux.cpp ===
=== Example: engines/quux/quux.cpp ===
<syntax type="C++">
<syntaxhighlight lang="cpp">
#include "common/scummsys.h"
#include "common/scummsys.h"
   
   
Line 162: Line 169:
#include "common/debug-channels.h"
#include "common/debug-channels.h"
#include "common/error.h"
#include "common/error.h"
#include "common/EventRecorder.h"
#include "gui/EventRecorder.h"
#include "common/file.h"
#include "common/file.h"
#include "common/fs.h"
#include "common/fs.h"
Line 173: Line 180:
   
   
QuuxEngine::QuuxEngine(OSystem *syst)  
QuuxEngine::QuuxEngine(OSystem *syst)  
  : Engine(syst) {
  : Engine(syst), _console(nullptr) {
// Put your engine in a sane state, but do nothing big yet;
// Put your engine in a sane state, but do nothing big yet;
// in particular, do not load data from files; rather, if you
// in particular, do not load data from files; rather, if you
Line 179: Line 186:
   
   
// Do not initialize graphics here
// Do not initialize graphics here
// Do not initialize audio devices here
   
   
// However this is the place to specify all default directories
// However this is the place to specify all default directories
Line 242: Line 250:
   
   
} // End of namespace Quux
} // End of namespace Quux
</syntax>
</syntaxhighlight>


=== Example: engines/quux/detection.cpp ===
=== Example: engines/quux/detection.cpp ===
The following example implements a custom MetaEngine instead of using the AdvancedMetaEngine.
The following example implements a custom MetaEngine instead of using the AdvancedMetaEngine.
<syntax type="C++">
<syntaxhighlight lang="cpp">
#include "quux/quux.h"
#include "quux/quux.h"
   
   
Line 343: Line 351:
REGISTER_PLUGIN_STATIC(QUUX, PLUGIN_TYPE_ENGINE, QuuxMetaEngine);
REGISTER_PLUGIN_STATIC(QUUX, PLUGIN_TYPE_ENGINE, QuuxMetaEngine);
#endif
#endif
</syntax>
</syntaxhighlight>


=== Example: engines/quux/module.mk ===
=== Example: engines/quux/module.mk ===
<syntax type="make">
<syntaxhighlight lang="make">
MODULE := engines/quux
MODULE := engines/quux
   
   
Line 363: Line 371:
# Include common rules  
# Include common rules  
include $(srcdir)/rules.mk
include $(srcdir)/rules.mk
</syntax>
</syntaxhighlight>
 
=== Example: engines/quux/configure.engine ===
<syntaxhighlight lang="bash">
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
add_engine quux "Quux" no
</syntaxhighlight>
TrustedUser
2,147

edits

Navigation menu