Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
DooMBoy

Technical Question Regarding ZDoom

Recommended Posts

I'm just curious, exactly what happens when you load a wad into ZDoom?

Share this post


Link to post

Thank you, Julian, for that insightful post, and for telling me exactly what I already knew! :D

Share this post


Link to post
DooMBoy said:

I'm just curious, exactly what happens when you load a wad into ZDoom?

It gets ready to play it for you, er, with you, er, against you. Pfft.

Share this post


Link to post

Step 1: ZDoom opens it using one of the standard C file-open calls (durrr, fopen()?).

Step 2: It reads the first four bytes to ensure that the file is either an IWAD or a PWAD. If not, you get an error and ZDoom probably quits.

Step 3: Having completed step 2 successfully, ZDoom reads the next four bytes to determine the beginning of the WAD directory.

Step 4: Starting at the location in the file just given by the result of step 3 (fseek() this time, I think), it starts reading in the entire WAD directory, which consists of entry-name/location pairs (8 bytes for the entry name, 4 for the location).

...if you need more info, I'll try and figure out what goes on afterwards, but this is enough for now.

Share this post


Link to post
KDarigal said:

Step 1: ZDoom opens it using one of the standard C file-open calls (durrr, fopen()?).

Well, I guess ZDoom uses C++ classes and methods to do that.

Share this post


Link to post
DooMBoy said:

Hey, KDarigal, thanks for the info! I am enlightened! :)

Of what use shall you now make of your enlightment, DooMBoy? :)

Share this post


Link to post
KDarigal said:

Step 2: It reads the first four bytes to ensure that the file is either an IWAD or a PWAD. If not, you get an error and ZDoom probably quits.


Not sure about that one (like I would know) but Zdoom can read other files too. As, apparently can most ports, even the original doom.exe

If you present Zdoom with a file format it understands, it will read it and apply it:

eg, zdoom -file d_runnin.mp3 will happily load an mp3 called D_RUNNIN.MP3 and play it as the music on MAP01

eg2, zdoom -file mapinfo.txt will load a text file containing mapinfo style information and append it to any mapinfo information already present.

etc etc...

In addition, it supports other FPS game files to a certain extent:

It supports Blood format files to load the sounds for the Blood Bath Announcer.

It can read Build format maps and let you inspect them.

Share this post


Link to post
Biffy said:

Of what use shall you now make of your enlightment, DooMBoy? :)

I shall store it away in my brain, so that I might use this info when another person asks this very same question about a year from now :)

Share this post


Link to post

Enjay said:
It can read Build format maps and let you inspect them.


I did no know that! How do you load up, say, the first duke nukem 3d map?

Share this post


Link to post

Speak for yourself, you always refer to yourself in the third person like a friggin' caveman.

Share this post


Link to post

I am not amused. Seriously, even I don't act that stupid. And mind you, I do have my moments...

Share this post


Link to post
ravage said:

I am not amused. Seriously, even I don't act that stupid. And mind you, I do have my moments...

Well, not to antagonize anyone here, but, If I actually did care what anyone thinks of me, Do you think I would be like this?? Didn't think so. Warn me as you will, but I go here as I do in everything else: Till The bitter end.

Share this post


Link to post

I think you could scare some newbies with that "We are not amused" title. More so combined with the hooded skull avatar.

Share this post


Link to post
myk said:

I think you could scare some newbies with that "We are not amused" title. More so combined with the hooded skull avatar.

I have a animated gif of the hereskull Dee-Lee thingy I did, it changes appearances, but I have no where to host it.

But hey, I'd love to scare off annoying newbs, but by doing that I would have to radicate of myself, so, hmm...

Share this post


Link to post
DOOM Anomaly said:

I have a animated gif of the hereskull Dee-Lee thingy I did, it changes appearances, but I have no where to host it.

But hey, I'd love to scare off annoying newbs, but by doing that I would have to radicate of myself, so, hmm...

You don't need a host, check profile options. You can upload directly from your comp. See my new fish?

Share this post


Link to post
ravage said:

You don't need a host, check profile options. You can upload directly from your comp. See my new fish?

yes, but then its the matter of, I gotta figure out how.

Share this post


Link to post

1. The source port opens the file for reading. Like Mdenham says, this is done with standard OS calls such as fopen.

2. The 'header' of the file is read. This basically just says the type of wad (IWAD/PWAD), the location of the directory in the file and the number of entries.

3. Part of WAD files is the "directory" which lists all the data which is stored in the file. You can see the directory by loading the WAD in WinTex/NWT. The doom port reads the whole directory into memory. Smart ports store it in a hash table. A hash table is a way of sorting through data such that you can look up things stored in it very quickly. So, if I want to find information about the lump named "TITLEPIC", I can search the hash table for the entry named "TITLEPIC" and find it almost instantly. The original doom used a linear search which is much less efficient (a linear search means searching through every entry in the list until you find the one you want). I believe the boom team quoted something around a 200-300% increase in framerate from just switching to a hashtable. Some ports still use a linear search.

4. Some ports sort things into namespaces (sprites, flats etc) based on the ?_START..?_END lumps and keep different lists for different types of data.

5. Consecutively loaded wads are stored in a "chain". When searching for a lump, the WAD code searches through each entry in the chain until it finds a match. New WADs are placed at the start of the chain. In this way, WADs can be used as "patches" which replace things loaded earlier (like the IWAD).

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×