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

Variable sizes in original source

Recommended Posts

Hi everyone. I'm once again working on my C# port of Doom and have a few questions.

I've been going through the source code and am confused as to the difference between int and short. I know short is 2 bytes, the problem is with int, I thought it was 4 bytes, but in r_defs.h some of the structures stored in the WADs that use 2-byte fields are stored as ints. fixed_t is a typedef for int and vertex_t is stored as two fixed_ts yet in the WAD it's two shorts.

Another one I don't understand is angle_t:

typedef unsigned angle_t;

Is this unsigned short or unsigned int?

Thanks.

Share this post


Link to post

int and unsigned int are 4 bytes. Many values that are stored as shorts in the map are either extended internally or converted to 16.16 fixed point numbers which technically means, the value is shifted 16 bits left.

Share this post


Link to post

It's also worth bearing in mind that the "long" type is also 32 bits. Long is used in several places in the original source, but on some architectures (and in C#) long is 64 bits.

Share this post


Link to post

I asked because I've worked on some architectures (embedded systems and 16-bit DOS programs) where int was 2-bytes in C, but being used to C# I used int everywhere thinking it would be 4-bytes. Having been written for DOS I thought Doom might have the same problem so I had to be sure.

Thanks guys.

Share this post


Link to post

Although Doom was for DOS it was 32 bit. Even in 1993 16 bit mode was far too limited for games.

Share this post


Link to post

Yeah my attempts at making real-mode 3D fpses in 1995 were horribly aggravating, having to use very low res textures and wacky hz sounds (8000hz), and even then you're lucky to have it running at all with sound and 3d and not playing like wolfenstein, trying to respect the strict 640kb limit. I sure don't miss those times (in development). Doom would have not been possible without protected mode

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  
×