delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/27/21:28:51

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Quick question.
Date: Thu, 26 Mar 1998 19:14:29 +0000
Organization: None
Message-ID: <1vO+PEAVkqG1Ew4G@talula.demon.co.uk>
References: <0p6KNWK00YUs0LeXk0 AT andrew DOT cmu DOT edu>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 29
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

James W Sager Iii writes:
>I was wondering if there is a way to load up a single datafile,
>and strip individual arrayed objects from it, or can this simply
>not be done with this version?

The best way is simply to call load_datafile(), which reads the entire
thing into memory in one pass. This may not be ideal if you don't need
all the objects in the file, but generally I would suggest that you
don't worry about this (if worst comes to worst and you run out of
space, any objects that you don't use will automatically be swapped out
to disk).

If your objects can be organised in groups, eg. different graphics for
each level of a game, another option is to put several nested datafiles
within the main datafile, put all the objects for each level together in
one of the child datafiles, and use load_datafile_object() to load the
entire group of nested objects in one pass.

If this isn't good enough for what you need, you will have to write your
own code to scan through the datafile. This isn't so hard to do when
using the packfile functions: the format is described in grabber.txt,
and you can find an example of this technique in the patch loader from
digmid.c, but it is certainly much more work than using the standard
load routines.


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
"Pigs use it for a tambourine" - Frank Zappa

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019