Mail Archives: djgpp/1997/04/30/13:46:04
From: | Shawn Hargreaves <shawn AT talula DOT demon DOT co DOT uk>
|
To: | djgpp AT delorie DOT com
|
MMDF-Warning: | Parse error in original version of preceding line at punt-1.mail.demon.net
|
Subject: | Re: Reading compressed files
|
Date: | Wed, 30 Apr 1997 16:22:29 +0100
|
MIME-Version: | 1.0
|
Message-ID: | <862416460.0514492.0@[194.129.18.166]>
|
Patrick J. Morris writes:
> I am currently writing a tile-based game and was thinking about
> how I could store the map in and Allegro DAT file. I was just wondering
> if I could read in the map file and change it if I need to and then
> save it again to the DAT file. If this is possible then please tell
> me how.
Reading in is easy. Import your map file into the grabber as a binary
object, read the datafile into your program, and datafile[MAP_NAME].dat
will point to the binary data for your map. If you want to load it into
some structure other than a simple binary block, import it into the grabber
as a custom object type (eg. "MAP "), and use the
register_datafile_object() function to provide your own load routine for
objects of this type (obviously you must call this before load_datafile()).
Saving is rather more tricky: the datafile format wasn't designed for doing
this, so it's quite slow and probably not a good idea to do from your
actual game. If you really need to do it, include tools/datedit.c in your
program, and include tools/datedit.h for the prototype of the
datedit_save_datafile() function. This isn't documented anywhere: look at
the source for details. Warning: this won't work if there are any compiled
sprites in the datafile, as they are converted from bitmaps into code when
the datafile is read into memory, so the original data isn't available to
be written back out again...
--
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"
- Raw text -