213
edits
(Added note about testbed) |
Ccawley2011 (talk | contribs) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 8: | Line 8: | ||
=== Overview === | === Overview === | ||
Essentially, you will have to implement a subclass of the OSystem class. Our Doxygen documentation is your friend and should hopefully explain enough about this, see [ | Essentially, you will have to implement a subclass of the OSystem class. Our Doxygen documentation is your friend and should hopefully explain enough about this, see [https://doxygen.scummvm.org/d2/d38/class_o_system.html OSystem class]. | ||
You also need to either hook yourself into the regular ScummVM build system, or provide your own. Finally, you need to make ScummVM aware of your new backend by updating a couple source files (see below). | You also need to either hook yourself into the regular ScummVM build system, or provide your own. Finally, you need to make ScummVM aware of your new backend by updating a couple source files (see below). | ||
Line 20: | Line 20: | ||
# Make sure to provide the <tt>main</tt> function in your backend (the actual main function of ScummVM is <tt>scummvm_main</tt>, which your backend must invoke at some point). | # Make sure to provide the <tt>main</tt> function in your backend (the actual main function of ScummVM is <tt>scummvm_main</tt>, which your backend must invoke at some point). | ||
# Instantiate the OSystem class and assign it to <tt>g_system</tt>, do that before calling <tt>scumm_main</tt>. | # Instantiate the OSystem class and assign it to <tt>g_system</tt>, do that before calling <tt>scumm_main</tt>. | ||
# Deinit properly after calling <tt>scumm_main</tt>, particularly call <tt>g_system-> | # Deinit properly after calling <tt>scumm_main</tt>, particularly call <tt>g_system->destroy()</tt>. | ||
# If appropriate, edit <tt>configure</tt> to add your backend (this is only necessary if you are going to use the "./configure && make" build system). | # If appropriate, edit <tt>configure</tt> to add your backend (this is only necessary if you are going to use the "./configure && make" build system). | ||
==== Example of minimal main() ==== | ==== Example of minimal main() ==== | ||
< | <syntaxhighlight lang="cpp">int main(int argc, char *argv[]) { | ||
// Create our OSystem instance | |||
g_system = new OSystem_Foobar(); | g_system = new OSystem_Foobar(); | ||
assert(g_system); | assert(g_system); | ||
Line 30: | Line 31: | ||
// Invoke the actual ScummVM main entry point: | // Invoke the actual ScummVM main entry point: | ||
int res = scummvm_main(argc, argv); | int res = scummvm_main(argc, argv); | ||
// Free OSystem | |||
g_system->destroy(); | |||
return res; | return res; | ||
}</ | }</syntaxhighlight> | ||
That's it. The difficult part is of course writing the OSystem subclass. More on that in the next section! | That's it. The difficult part is of course writing the OSystem subclass. More on that in the next section! | ||
=== Subclassing OSystem === | === Subclassing OSystem === | ||
TODO: This section is meant to give some specific hints on creating a useful OSystem subclass. For now I can't really think of anything useful besides the obvious, and besides what we already say in other places... Take a look at [ | TODO: This section is meant to give some specific hints on creating a useful OSystem subclass. For now I can't really think of anything useful besides the obvious, and besides what we already say in other places... Take a look at [https://doxygen.scummvm.org/d2/d38/class_o_system.html OSystem class] which contains lots of useful information. Also take a look at null.cpp to see what you have to implement, and peek at the SDL backend (which is our main backend and thus kind of a reference for all the others). And finally, take a look at <tt>common/system.h</tt> to see which methods are pure abstract, and thus '''must''' be implemented by you. Oh and of course: You can always talk to us on [[IRC Channel|IRC]] or via [[Mailing lists|email]] :-). | ||
=== Implementing subsystems === | |||
* [[HOWTO-Backends/File system]] | |||
* [[HOWTO-Backends/Mutexes and Timers]] | |||
* [[HOWTO-Backends/Graphics]] | |||
* [[HOWTO-Backends/Events]] | |||
* [[HOWTO-Backends/Audio]] | |||
* [[HOWTO-Backends/Plugins]] | |||
* [[HOWTO-Backends/Miscellaneous]] | |||
==== Testing your backend ==== | ==== Testing your backend ==== | ||
We have a special game engine, called 'testbed'. Its only purpose is to perform series of tests which help | We have a special game engine, called 'testbed'. Its only purpose is to perform series of tests which help backend authors to see correctness of their implementation. | ||
To run the game, point ScummVM to directory <tt><scummvm sources root>/dists/engine-data/testbed-audiocd-files/</tt> and then run. Follow the on-screen instructions. | To run the game, point ScummVM to directory <tt><scummvm sources root>/dists/engine-data/testbed-audiocd-files/</tt> and then run. Follow the on-screen instructions. | ||
Line 46: | Line 59: | ||
=== Misc notes === | === Misc notes === | ||
There is a [[Small Devices Backend]] in the works which is planned to be common for all devices with limited resources. If you are working on a backend for such a system, you may want to take a look on that page! | There is a [[Small Devices Backend]] in the works which is planned to be common for all devices with limited resources. If you are working on a backend for such a system, you may want to take a look on that page! | ||
edits