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

Confused and Befuddled

Recommended Posts

I am curious about the source code for Doom. Sure it was written up and everything, but HOW exactly does it tell the game what to do? Do the #include lines tell the exe how to function? (Excuse my ignorance, I am NOT a programmer :)
Example:
#include <sys/stat.h>
#include <direct.h>
#include <fcntl.h>
#include <stblib.h>

How do these things come together to tell the exe what to do?

Share this post


Link to post

the only way you can really start is with a C book. as for the includes, think about how many lines of #include you see compared to how many lines of other stuff you see. you think the #includes tell everything? :)

Share this post


Link to post

Dude go get a book on C or something else. That will let you know everything you could ever want.

Share this post


Link to post

I love C! i play with Doom's source at leat once a day...
on that note, make backups often.

Share this post


Link to post

If you notice, the source is broken up into different .c files (modules). The .h files are used so that pieces of code in that module can refer to code in other modules. In some cases, they are used to refer to code in libraries. "stdlib.h" for example, has the specification for part of the standard C library.

Hope this helps.

Share this post


Link to post

The ".c" files are the source code itself. Each of these will compile and build into its own program. There'll be one .c file that will finally combine all of these programs into doom.exe.

The ".h" files are called Header files. These contain variable declarations and little snippets of code with reference tags attached. These reference tags can be used n place of the block of code in the .c files and really help clean up and speed up the process of writing the program.

Like I said, each of the .c files will become its own .exe file. Each of these controls one aspect of the game: Monster AI, the positions and states of entites in the map, drawing the game to your computer screen, et al. Making each bit its own .c and .exe, and only bringing them together in the finished product, makes it a helluva lot easier for a team to cooperate in a project.

You know UFO: Alien Defense (aka X-COM)? Ever taken a look at the install directory? That's what Doom looks like before you combine it into doom.exe. That's likely what a playable version of Doom 3 looks like right now.

Share this post


Link to post
IMJack said:

Like I said, each of the .c files will become its own .exe file.

No. The .c files are compiled seperately into .o (object) files and then linked together by a linker program to form the .exe file. They cannot be run on their own.

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
×