Page 1 of 1

zLib and PAK files

PostPosted: May 23, 2001 @ 7:59pm
by Malmer
Hello Guys!<br><br>Since you are all (well some of you) PQ developers I have a Q for you. We need some way of putting a lot of files into one file and read them from inside Argentum. My first though naturally is to do it the way Quake does, with zLib and some kind of PAK file. Could someone explain how to get it working? And do I need any special DLL's? What functions in zlib are the vital ones?<br><br>Dan, I know you know the answer to this. Please help me. We need it for the game. <br><br>Thanks!<br><br>// Fredrik<br><br>PS. I bet it is really easy, I just havn't put enough effort into it. Anyways, you have a couple of days to answer. I'm going away. DS.

Re: zLib and PAK files

PostPosted: May 23, 2001 @ 10:31pm
by randall
I just read a very descriptive article about the structure of the Quake PAK file, and the functions that work with it. Too bad I can't remember where it was.<br><br>I think it was a reference for developers to write a PAK explorer.<br><br>If I come across it again, I'll post a link to it.

Re: zLib and PAK files

PostPosted: May 24, 2001 @ 3:49am
by Malmer
For me it isn't very important to have the best compression on earth or anything, or to have a ultra efficient storage system. I basically just want the files put into one file and have functions similiar to fread etc.<br><br>// Fredrik

Re: zLib and PAK files

PostPosted: May 24, 2001 @ 11:04am
by Moose or Chuck
talk to the guy that wrote PHexen, he had a really good compression scheme. It almost sped up the program when the .wad's were zipped. He used some kind of cache trick, which allowed frequently accessed parts of the file to  be cached. And i believe he made the file Random access instead of sequenstial.

Re: zLib and PAK files

PostPosted: May 24, 2001 @ 11:09am
by Dan East
The pak format is pretty straightforward. There's a table at the beginning of the file containing an entry for each file, with it's name, filesize, and offset into the pak. Extracting is just a matter of seeking in by the offset and reading filesize bytes. I just use the gzip algorithms for reading if the pak has a .gz extension. The problem is that the pak / gz combo is very slow. Seeking in a gzipped file means reading / decompressing. If you seek to a location before the current file pointer, then gzip resets back to beginning and decompresses up to the desired seek location. This makes for very poor random file access. Terry Whiterod, of PocketHexen fame, came up with a much more effecient technique of gzipping pak / wad files. He offered me more information on his technique , but he never responded to my emails.<br>Zlib decompressing is really not that slow. It is just not cool when various segments of the file have to be decompressed hundreds of times over due to file seeking. If I never hear back from Terry I will pursue my own optimized gz/pak routines in a month or so.<br><br>It took some minor tweaking for the zlib source to build for Pocket PC, so you ought to just grab the zlib files out of the PQ source.<br><br>Dan East

Re: zLib and PAK files

PostPosted: May 24, 2001 @ 11:10am
by Dan East
I hate it when people post the same thing I'm going to post while I'm typing it in. :)<br><br>Dan East

Re: zLib and PAK files

PostPosted: May 24, 2001 @ 12:08pm
by Moose or Chuck
yep dan i know i was to fast for you :)