Game Development Reference
In-Depth Information
To create the archive, simply pass the name of the DCL file into the DZip utility,
ensuring you run the command from within a directory where the archive and
basedir entries can be located.
Using a Derbh archive in code
With a Derbh archive created, it is then really easy to make use of it in our game.
Firstly we need to add support for the Derbh API by adding derbh to the list of
subprojects in the MKB file. We also need to include the derbh.h file to provide
access to the API functions.
To make use of our archive file we just need to add a call to the function
dzArchiveAttach , which takes a single parameter—the filename of the Derbh
archive itself. From then on any call to open a file will first check to see if it exists in
the Derbh archive, and if it does the data will automatically be decompressed and
returned whenever we try to read from the file. It really is that simple!
We can attach more than one archive at a time as well by simply calling
dzArchiveAttach for each archive we wish to use.
If a request is made for a file that doesn't appear in the archive, Marmalade will then
look in the data and data-ram directories.
If we want to stop using a Derbh archive for any reason, we can either call
dzArchiveDetach to remove the last archive that was attached or we can specify
the archive to detach using the dzArchiveDetachNamed function.
It is important to note that only files loaded from within the application
code will be accessible from an attached Derbh archive. If you are
trying to start a music track with s3eAudio or a video clip with
s3eVideo, these files must exist as separate files as they are loaded by
the operating system native methods, which obviously will have no
way of accessing a Derbh file's contents.
The automatic Derbh method
For most projects there is actually an even easier way of making use of Derbh
archives, which doesn't require us to create a DCL file or build a Derbh file ourselves.
We don't even have to attach the archive in our code! To make use of this feature, all
we need to do is add the following to the deployments section of our MKB file (we'll
be covering this section of the MKB file in greater detail in just a moment).
 
Search WWH ::




Custom Search