From: Shawn Hargreaves To: djgpp AT delorie DOT com MMDF-Warning: Parse error in original version of preceding line at relay-11.mail.demon.net Subject: Re: Loading mod files from allegro .dat file Date: Mon, 28 Apr 1997 11:22:07 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <862223239.0915030.0@[194.129.18.166]> Precedence: bulk Guan Foo Wah writes: > I have manage to make mikmod with allegro 2.2 by myself. But > there is a problem. I don't know how to load a mod and wav file from the > allegro's .dat file. If anyone know how to do this, please tell me how. This problem could range from medium-difficult to very easy, depending on how the MikMod loading functions work (I've never used MikMod myself, so I don't know how it is organised). The first step is to import the objects into the datafile, using custom object types, eg. "MOD" and "WAV" (not SAMP, as that is already used for the Allegro sample structure). Then in your program, before you load the datafile you must provide a loader routine for objects of your new types, eg: register_datafile_object(DAT_ID('M','O','D',' '), load_mod, unload_mod); Finally you have to provide the actual worker functions, eg: void *load_mod)(PACKFILE *f, long size) { /* do whatever you have to, eg: */ char *data = malloc(size); pack_fread(data, size, f); return data; } void unload_mod(void *data) { /* do whatever you have to, eg: */ free(data); } If you are lucky these routines will just be able to call MikMod functions to do the work, but the complication is that the data is read from an Allegro PACKFILE object, using the pack_*() routines, rather than a normal stdio FILE such as I suspect is used by MikMod. To make this work, you'll probably have to alter the MikMod loaders to use a PACKFILE object (this ought to be fairly easy, as the API is very similar to stdio so it would just be a matter of a few search-and-replace operations through the loading code). In theory it would be possible to use the djgpp filesystem extensions to integrate the Allegro file compression code with stdio, but I'm reluctant to do that because it would wreak havoc with any attempts to port the code to other systems with lesser C libraries... :-) -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk "Beauty is a French phonetic corruption of a short cloth neck ornament"