<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Data packer via function calls</title>
		<link>http://www.allegro.cc/forums/view/550441</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 09 Dec 2005 03:11:09 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Okay, I&#39;ve got to the stage of my project where I really need to package up all the bits and bobs it loads into one lump. Thing is that the list of bits and bobs I need to package up is procedurally generated by the program so I don&#39;t want to hand-assemble the package. In addition to this I need them stored in a format whereby fmod can load them and not just Allegro (although streamed sounds like mp3s won&#39;t be packaged). Any advice on what route I should go down?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Graham Goring)</author>
		<pubDate>Mon, 05 Dec 2005 18:26:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Can&#39;t you just use the dat/pack file routines for storing then the same again in collaboration with the magic # for reading? e.g. find_datafile_object() or pack_open() with filename.dat#object_name</p><p>Or am I missing the question.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Mon, 05 Dec 2005 18:53:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>you should stick all your &#39;assets&#39; into a sub folder from your main application, and stop this completely daft idea that everything needs to compressed into a single file..  use the file system to orgainze your data, thats what its for.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (A J)</author>
		<pubDate>Mon, 05 Dec 2005 19:33:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s what I do, I use an XML file to reference everything, but Graham asked a question about packing files as he probably has a good reason for doing so (e.g. it stops the casual user from ripping graphics/sound).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Mon, 05 Dec 2005 19:36:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Okay, here are my options:</p><p>Either pack everything (to stop people just ripping off the assets - that&#39;s the main reason) or leave everything in the structure but obfuscate the assets by scrambling the pixels of the graphics and descrambling at load time. Alas I can&#39;t see a way to do that with the sound, so it kinda&#39; rules out that option.</p><p>Btw, Neil, I didn&#39;t realise that you could could use the packer as a library, I thought you had to manually build the packfiles via a program. Does it preserve directory structure when you pack stuff?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Graham Goring)</author>
		<pubDate>Mon, 05 Dec 2005 19:41:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The manual is your friend. The DatFile routines are for reading and the packfiles are the lower level functions used for reading/writing and what (I think) the DatFile routines use: </p><p>//the datfile functions and for setting up your own type<br /><a href="http://www.allegro.cc/manual/api/datafile-routines/">http://www.allegro.cc/manual/api/datafile-routines/</a></p><p>//packfile (the pack_ are probably what you want)<br /><a href="http://www.allegro.cc/manual/api/file-and-compression-routines/">http://www.allegro.cc/manual/api/file-and-compression-routines/</a></p><p>I&#39;ve never actually used them, but I think they are what you want.</p><p>If you&#39;re stuck, just go to the tools directory and look at grabber.c
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Mon, 05 Dec 2005 19:49:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
you should stick all your &#39;assets&#39; into a sub folder from your main application, and stop this completely daft idea that everything needs to compressed into a single file.. use the file system to orgainze your data, thats what its for.
</p></div></div><p>
There&#39;s something to be said for cleanliness. One file looks a lot nicer than an entire directory tree. Also, a bunch of files in a datafile will usually take up less room than a directory tree with multiple files.</p><p>I can already hear you saying &quot;but disk size isn&#39;t important these days&quot;, and ultimately, I&#39;d say that&#39;s wrong. I&#39;ve had to deal with running out of disk space before, and it&#39;s not fun. Every program that doesn&#39;t worry about size contributes more to the disk filling up, so the less of this that happens, the better. No matter what size drives you have, they will fill up. And I&#39;m not one that can go affording a new bigger drive everytime that happens.</p><p>If size wasn&#39;t an issue, then you might as well use all plain .bmp and .wav files. It&#39;s a lot more efficient to read them in since you don&#39;t need to decompress them (wasting RAM and CPU time).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Mon, 05 Dec 2005 20:18:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ta&#39; Neil, looking through them and at first it looked a bit bespoke with the object type stuff but if I treat everything as a binary data chunk I should be okay. I think...</p><p>EDIT(AGAIN): Oh, it&#39;s just been pointed out to me that fmod can load from memory pointers.</p><p>Now I just need to understand the grabber completely so I can pass it a filename and it&#39;ll return the index of it within the .dat file&#39;s structure. Erk.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Graham Goring)</author>
		<pubDate>Mon, 05 Dec 2005 20:47:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How about using the <tt>dat</tt> utility via a batch file to rebuild your datafile automatically. You can also set a password which will stop the casual hacker from nicking your stuff.</p><p>Pete
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Tue, 06 Dec 2005 13:15:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
If size wasn&#39;t an issue, then you might as well use all plain .bmp and .wav files. It&#39;s a lot more efficient to read them in since you don&#39;t need to decompress them (wasting RAM and CPU time).
</p></div></div><p>
Actually, with today&#39;s cpus, loading and playing an mp3 is faster than loading and playing wav - the bottleneck here isn&#39;t cpu clocks, but disk i/o.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 06 Dec 2005 17:13:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
the bottleneck here isn&#39;t cpu clocks, but disk i/o.
</p></div></div><p>Also even if all the data is loaded in ram it would probably be a bit faster to decode/present if it is as small as possible because the data path between CPU and ram is not exactly big compared to the processing power of the latest and greatest CPU&#39;s. The more data fits in L1/2/3 the better, especially on P4 CPU machines (high-end a64 usually has about 1/2 to 1/3 memopry latency of P4&#39;s, ~35-50ns vs 100-120ns according to everest home edition).<br />Sure, I doubt anyone has hundreds of MiB&#39;s of sounds to crunch through every second so generally this bottleneck doesn&#39;t show up in most scenarios.</p><p>[edit]</p><p>Fixed the program name.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Tue, 06 Dec 2005 17:29:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
will usually take up less room than
</p></div></div><p>
like the disk space savings your talking about can even be counted ?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
And I&#39;m not one that can go affording a new bigger drive everytime that happens.
</p></div></div><p>
yeah, cause a 1 gig of HD &lt; $1.. is just too much to spend <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
It&#39;s a lot more efficient to read them (BMP/WAV) in since you don&#39;t need to decompress them (wasting RAM and CPU time).
</p></div></div><p>
disk access is much slower than RAM/CPU, and bus bandwidth is considerably limited compared to CPU cycles.  The number of CPU cycles wasted whilst the disk churns is in the millions.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (A J)</author>
		<pubDate>Tue, 06 Dec 2005 18:14:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
like the disk space savings your talking about can even be counted ?
</p></div></div><p>
Depends on the file system, how many (sub)directories, how many files, the size of the files, etc...</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
yeah, cause a 1 gig of HD &lt; $1.. is just too much to spend <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" />
</p></div></div><p>
When you have a grand total of $0 to spend, yeah. Lucklly that is not currently the case with me, but as I&#39;ve learned through life, you can never depend on money being there when you want it. I couldn&#39;t even afford this computer when I got it. Luckilly a friend was willing to donate it to me because the parts were &quot;old&quot; (same with my current 80GB HD).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Tue, 06 Dec 2005 19:05:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Internal fragmentation should&#39;nt be too much of an issue, but if you have a few thousand (very) small files, it will add up.</p><p>Personally i prefer to have a few datafiles split up acording to content, ie music, graphics and so forth. Also, remember that it&#39;s faster to load a single file and jump around in it than it is to open lots of tiny files and read all data from it in one go... The problem with big files however is that they tend to get fragmented on fidk (assuming the average user), which can slow down reading a lot.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Wed, 07 Dec 2005 00:14:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, the solution I ended up with is somewhat bizarre. To create my data file I output a list of all the files I need to a batch file (as Peter suggested) inside lines of &quot;dat datapack.dat -a filename.ext -k&quot; and with whatever other flags I need to set, and then I call that with system() and then erase it. Somewhat roundabout but as it&#39;s really for the release version of the game it&#39;s a small price to pay. The main problem is that as I specify flags with each file I have to execute dat.exe a ton of times and obviously it gets incrementally slower as it adds more and more. Tsk, eh?</p><p>Anyhoo, it&#39;s all peachy now that it&#39;s been pointed out to me that fmod is just as happy loading from memory as from a file.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Graham Goring)</author>
		<pubDate>Wed, 07 Dec 2005 03:26:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>do you know about exedat ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (A J)</author>
		<pubDate>Wed, 07 Dec 2005 08:49:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Filesize is extremely important for download size.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Wed, 07 Dec 2005 14:09:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I assume that&#39;s the puppy which appends the dat file to the executable? I don&#39;t think I&#39;ll be taking that approach, thanks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Graham Goring)</author>
		<pubDate>Thu, 08 Dec 2005 03:55:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>While that is very true, it is also quite irrelevant for this discussion; When you distribute you program you will most certainly use some manner of compression which nullifies the problem. </p><p>EDIT: I was refering to Dustins post
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Thu, 08 Dec 2005 04:25:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, heaven forfend that I change the course of the discussion that I started. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>Anyhoo, now I have another problem. Generally to use a bitmap from the datapack it seems you just cast the pointer to it&#39;s data as a BITMAP * however what if the colour depth doesn&#39;t match the current one set up for Allegro? As it&#39;s not being loaded then surely it bypasses the conversion and will break?</p><p>I only ask as everything in my game is appearing as a big white rectangle. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/DATAFILE" target="_blank"><span class="a">DATAFILE</span></a> <span class="k3">*</span>data_pointer <span class="k3">=</span> <a href="http://www.allegro.cc/manual/find_datafile_object" target="_blank"><span class="a">find_datafile_object</span></a><span class="k2">(</span>datafile_dat, object_name<span class="k2">)</span><span class="k2">;</span>
bmps<span class="k2">[</span>total_bitmaps_loaded<span class="k2">]</span>.image <span class="k3">=</span> <span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span><span class="k2">)</span> data_pointer-&gt;dat<span class="k2">;</span>
</pre></div></div><p>
Is what I&#39;m using at the moment. Is there another way?</p><p>EDIT: Righty, I&#39;ve got the graphics displaying now I&#39;m in software mode but the RGB values are scrambled to GBR or something. So is there a way of properly loading a graphics from the PACK file instead of just casting a pointer so it undergoes the proper conversion routine?</p><p>EDIT: Oh, I should point out that I&#39;m using AllegroGL at the point where the packfile is loaded.</p><p>EDIT: Actually, I should make this a bit clearer, here&#39;s the order in which is does things.</p><p>1) Spawn a little 32 bit window to select the project<br />2) Set graphic mode back to text mode<br />3) Load the packfile<br />4) Set up an opengl window (set color conversion mode to total and preserve transparency) or a software window at either 16 or 32 bit depending on user preference.<br />5) fixup_datafile<br />6) Cast pointers to the bitmaps and upload them as textures.</p><p>Now, it should be noted that it seems to work okay in software mode, but if at the point that it turns them into textures, it all goes kerplooie. It seems that fixup_datafile isn&#39;t working at all as it doesn&#39;t convert the graphics sitting in it to the new colour depth in software mode so if the colour depths at point 1 and 4 don&#39;t match the graphics are all stretched. Either way, even if the depths match if I try uploading said textures in hardware graphics AllegroGL mode it doesn&#39;t work.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Graham Goring)</author>
		<pubDate>Thu, 08 Dec 2005 04:51:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think set_colour_conversion(COLORCONV_NONE) may be your friend? and maybe chuck in a fixup_datafile just for a laugh.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Thu, 08 Dec 2005 05:44:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve noticed that you can&#39;t us fixup to change from 16 to 32 bit and vice versa so I&#39;m gonna&#39; split my pack up (ouch!) and only load the graphics pack once the screen mode has been set up properly. Fingers crossed!</p><p>EDIT: Well, it&#39;s fixed the whole 16/32 bit thing, however when I try turning them into textures they still come out all white. Blecht!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Graham Goring)</author>
		<pubDate>Thu, 08 Dec 2005 06:03:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Did the set_colour_conversion(COLORCONV_NONE) not work?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Thu, 08 Dec 2005 06:13:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What code are you using to upload the textures?</p><p>Pete
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Thu, 08 Dec 2005 13:08:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>allegro_gl_make_masked_texture (BITMAP *);
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Graham Goring)</author>
		<pubDate>Thu, 08 Dec 2005 21:36:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
yeah, cause a 1 gig of HD &lt; $1.. is just too much to spend <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" />
</p></div></div><p>
Feel free to send me a $10 hd then, and let me know where to send the money <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Fri, 09 Dec 2005 02:06:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Eep! Ignore me, the texture upload thing wasn&#39;t working because I&#39;m an absolute bloody moron. So, the usual, then.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Graham Goring)</author>
		<pubDate>Fri, 09 Dec 2005 03:11:09 +0000</pubDate>
	</item>
</rss>
